This is an automated email from the ASF dual-hosted git repository.

junrushao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 0261b8ed8b [MetaSchedule][Minor] Fix Median Number (#12273)
0261b8ed8b is described below

commit 0261b8ed8b8b9c3df36964e6bbd785cfd7259b7d
Author: Xiyou Zhou <xi...@octoml.ai>
AuthorDate: Mon Aug 1 19:28:48 2022 -0700

    [MetaSchedule][Minor] Fix Median Number (#12273)
    
    The previous median number calculation util function used the wrong index 
which could cause out of bound issue as mentioned in #12199 . This PR fixed 
this issue.
---
 src/meta_schedule/utils.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/meta_schedule/utils.h b/src/meta_schedule/utils.h
index e3d726652e..cb84596eed 100644
--- a/src/meta_schedule/utils.h
+++ b/src/meta_schedule/utils.h
@@ -357,7 +357,7 @@ inline double GetRunMsMedian(const RunnerResult& 
runner_result) {
   std::sort(v.begin(), v.end());
   int n = v.size();
   if (n % 2 == 0) {
-    return (v[n / 2] + v[n / 2 + 1]) * 0.5 * 1000.0;
+    return (v[n / 2 - 1] + v[n / 2]) * 0.5 * 1000.0;
   } else {
     return v[n / 2] * 1000.0;
   }

Reply via email to