From ea81ca432a701203f74dede304d86ff65da15d30 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=94=D0=B8=D0=BB=D1=88=D0=BE=D0=B4=D0=B6=D0=BE=D0=BD=20?= =?utf8?q?=D0=A3=D0=BC=D1=80=D0=BE=D0=BD=D1=85=D0=BE=D0=BD=D0=BE=D0=B2?= =?utf8?q?=D0=B8=D1=87=20=D0=9F=D0=BE=D1=88=D1=88=D0=BE=D0=B5=D0=B2/AI=20T?= =?utf8?q?ools=20Lab=20/SRR/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Tue, 16 Jul 2019 19:13:44 +0900 Subject: [PATCH] [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 --- runtimes/neurun/core/src/backend/ExecTime.cc | 9 +++++++++ 1 file changed, 9 insertions(+) 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); } -- 2.7.4