ExecTime records for NYI ops should always read "not implemented" (#5309)
authorАндрей Шедько/AI Tools Lab /SRR/Engineer/삼성전자 <a.shedko@samsung.com>
Fri, 31 May 2019 06:29:25 +0000 (09:29 +0300)
committer오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Fri, 31 May 2019 06:29:25 +0000 (15:29 +0900)
* ExecTime records for NYI ops should always read "not implemented"

Added a guard against recods for ops with incomplete implementation

Signed-off-by: Andrei Shedko <a.shedko@samsung.com>
* Fix small typo in comment

Fix small typo in comment

Signed-off-by: Andrei Shedko <a.shedko@samsung.com>
runtimes/neurun/core/src/backend/ExecTime.cc

index 2c8fcef..f2f12f5 100644 (file)
@@ -19,6 +19,7 @@
 #include <fstream>
 #include <cassert>
 #include <limits>
+#include <algorithm>
 
 namespace neurun
 {
@@ -86,10 +87,22 @@ int64_t ExecTime::getOperationExecTime(const Backend *backend, const std::string
 void ExecTime::updateOperationExecTime(const Backend *backend, const std::string &operation,
                                        bool quant, uint32_t op_size, int64_t time)
 {
-  // NOTE Use map::insert() instaed of [] operator
-  //      because of bug on gnu buildtool 6.x -O optimization (coverage test build)
-  //_measurements[backend][operation][quant][op_size] = time;
-  _measurements[backend][operation][quant].emplace(op_size, time);
+  // If the op is not implemented for some input, it should not be scheduled
+  const auto &recs = _measurements[backend][operation][quant];
+  if (time == getMax() ||
+      std::any_of(recs.begin(), recs.end(),
+                  [](std::pair<const uint32_t, const int64_t> p) { return p.second == getMax(); }))
+  {
+    _measurements[backend][operation][quant].clear();
+    _measurements[backend][operation][quant].emplace(op_size, getMax());
+  }
+  else
+  {
+    // NOTE Use map::emplace() instead of operator[]
+    //      because of bug on gnu buildtool 6.x -O optimization (coverage test build)
+    //_measurements[backend][operation][quant][op_size] = time;
+    _measurements[backend][operation][quant].emplace(op_size, time);
+  }
 }
 
 void ExecTime::updatePermuteTime(const Backend *from_backend, const Backend *to_backend, bool quant,