[nnpackage_run] Make csv, memory poller options off (#9273)
author김용섭/On-Device Lab(SR)/Engineer/삼성전자 <yons.kim@samsung.com>
Fri, 29 Nov 2019 03:59:26 +0000 (12:59 +0900)
committer이춘석/On-Device Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Fri, 29 Nov 2019 03:59:26 +0000 (12:59 +0900)
* [nnpackage_run] Make csv, memory poller options off

Make nnpackage_run's options 'csv & memory poller' off. It makes ci
slow.

Signed-off-by: Yongseop Kim <yons.kim@samsung.com>
* Fix svace error

* Fix argument to write_report

tests/tools/nnpackage_run/src/args.cc
tests/tools/nnpackage_run/src/args.h
tests/tools/nnpackage_run/src/nnpackage_run.cc

index e34c291..a01dec5 100644 (file)
@@ -42,6 +42,8 @@ void Args::Initialize(void)
     ("num_runs,r", po::value<int>()->default_value(1), "The number of runs")
     ("warmup_runs,w", po::value<int>()->default_value(0), "The number of warmup runs")
     ("gpumem_poll,g", po::value<bool>()->default_value(false), "Check gpu memory polling separately")
+    ("mem_poll,m", po::value<bool>()->default_value(false), "Check memory polling")
+    ("write_report,p", po::value<bool>()->default_value(false), "Write report")
     ;
   // clang-format on
 
@@ -122,6 +124,16 @@ void Args::Parse(const int argc, char **argv)
   {
     _gpumem_poll = vm["gpumem_poll"].as<bool>();
   }
+
+  if (vm.count("mem_poll"))
+  {
+    _mem_poll = vm["mem_poll"].as<bool>();
+  }
+
+  if (vm.count("write_report"))
+  {
+    _write_report = vm["write_report"].as<bool>();
+  }
 }
 
 } // end of namespace NNPackageRun
index 268c3af..9af514a 100644 (file)
@@ -37,6 +37,8 @@ public:
   const int getNumRuns(void) const { return _num_runs; }
   const int getWarmupRuns(void) const { return _warmup_runs; }
   const bool getGpuMemoryPoll(void) const { return _gpumem_poll; }
+  const bool getMemoryPoll(void) const { return _mem_poll; }
+  const bool getWriteReport(void) const { return _write_report; }
 
 private:
   void Initialize();
@@ -52,6 +54,8 @@ private:
   int _num_runs;
   int _warmup_runs;
   bool _gpumem_poll;
+  bool _mem_poll;
+  bool _write_report;
 };
 
 } // end of namespace NNPackageRun
index 3745250..d84bad2 100644 (file)
@@ -143,8 +143,21 @@ int main(const int argc, char **argv)
   NNPackageRun::Args args(argc, argv);
   auto nnpackage_path = args.getPackageFilename();
 
-  benchmark::MemoryPoller mp(std::chrono::milliseconds(5), args.getGpuMemoryPoll());
-  std::vector<uint32_t> mp_results;
+  std::unique_ptr<benchmark::MemoryPoller> mp{nullptr};
+  if (args.getMemoryPoll())
+  {
+    try
+    {
+      mp.reset(new benchmark::MemoryPoller(std::chrono::milliseconds(5), args.getGpuMemoryPoll()));
+    }
+    catch (const std::runtime_error &error)
+    {
+      std::cerr << error.what() << std::endl;
+      return 1;
+    }
+  }
+
+  std::vector<uint32_t> mp_results({0, 0});
 
   nnfw_session *session = nullptr;
   NNPR_ENSURE_STATUS(nnfw_create_session(&session));
@@ -197,11 +210,13 @@ int main(const int argc, char **argv)
   // prepare execution
 
   // TODO When nnfw_{prepare|run} are failed, can't catch the time
-  mp.Start("Compiling");
+  if (mp)
+    mp->Start("Compiling");
   uint64_t prepare_us = benchmark::NowMicros();
   NNPR_ENSURE_STATUS(nnfw_prepare(session));
   prepare_us = benchmark::NowMicros() - prepare_us;
-  mp_results.emplace_back(mp.End("Compiling"));
+  if (mp)
+    mp_results[0] = mp->End("Compiling");
 
   // prepare input
 
@@ -304,11 +319,13 @@ int main(const int argc, char **argv)
   }
 
   // poll memories before warming up
-  mp.Start("Executing");
+  if (mp)
+    mp->Start("Executing");
   uint64_t run_us = benchmark::NowMicros();
   NNPR_ENSURE_STATUS(nnfw_run(session));
   run_us = benchmark::NowMicros() - run_us;
-  mp_results.emplace_back(mp.End("Executing"));
+  if (mp)
+    mp_results[1] = mp->End("Executing");
 
   // warmup runs
   for (uint32_t i = 1; i < args.getWarmupRuns(); i++)
@@ -379,13 +396,19 @@ int main(const int argc, char **argv)
     std::cout << "- Max:  " << acc.max() / 1e3 << "ms" << std::endl;
     std::cout << "- Mean: " << acc.mean() / 1e3 << "ms" << std::endl;
 
-    assert(mp_results.size() == 2);
-    std::cout << "===================================" << std::endl;
-    std::cout << "nnfw_prepare takes " << mp_results[0] << " kb" << std::endl;
-    std::cout << "nnfw_run     takes " << mp_results[1] << " kb" << std::endl;
+    if (mp)
+    {
+      assert(mp_results.size() == 2);
+      std::cout << "===================================" << std::endl;
+      std::cout << "nnfw_prepare takes " << mp_results[0] << " kb" << std::endl;
+      std::cout << "nnfw_run     takes " << mp_results[1] << " kb" << std::endl;
+    }
     std::cout << "===================================" << std::endl;
   }
 
+  if (args.getWriteReport() == false)
+    return 0;
+
   // prepare csv task
   std::string csv_filename;
   std::string model_name;