From: Дилшоджон Умронхонович Пошшоев/AI Tools Lab /SRR/Engineer/삼성전자 Date: Tue, 16 Jul 2019 10:13:44 +0000 (+0900) Subject: [neurun] Fix linear interpolation in ExecTime::getOperationExecTime (#5614) X-Git-Tag: submit/tizen/20190809.050447~536 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ea81ca432a701203f74dede304d86ff65da15d30;p=platform%2Fcore%2Fml%2Fnnfw.git [neurun] Fix linear interpolation in ExecTime::getOperationExecTime (#5614) In some cases ops with smaller inputs is executed slower than the one with larger inputs, more likely because of a backend's load difference. In such cases result of lin-interpolation is negative, which is wrong Signed-off-by: Dilshodzhon Poshshoev --- diff --git a/runtimes/neurun/core/src/backend/ExecTime.cc b/runtimes/neurun/core/src/backend/ExecTime.cc index b58885c..9cb1ff1 100644 --- a/runtimes/neurun/core/src/backend/ExecTime.cc +++ b/runtimes/neurun/core/src/backend/ExecTime.cc @@ -80,6 +80,15 @@ int64_t ExecTime::getOperationExecTime(const Backend *backend, const std::string int64_t interpolated_value = y0 + (x - x0) * (y1 - y0) / (x1 - x0); + // In some cases ops with smaller inputs is executed slower than the one + // with larger inputs, more likely because of a backend's load difference + if (interpolated_value < 0 && x > x1) + { + return y0; + } + // It must be non-positive ONLY if it's lesser than both of them + assert(interpolated_value > 0 || x < x0); + // execution time must be non-negative return std::max(interpolated_value, 1); }