[AutoTVM] select model with the most tuned schedules (#4404)
authorXingyu Zhou <zhoxingy@amazon.com>
Tue, 26 Nov 2019 18:17:25 +0000 (10:17 -0800)
committerYao Wang <kevinthesunwy@gmail.com>
Tue, 26 Nov 2019 18:17:25 +0000 (10:17 -0800)
* select model with the most tuned schedules

* change detect empty map method

* modify model description for load_reference_log

python/tvm/autotvm/tophub.py

index 12f2b80..95e9acb 100644 (file)
@@ -198,7 +198,7 @@ def load_reference_log(backend, model, workload_name, template_key):
     backend: str
         The backend name
     model: str
-        The name of the model
+        The name of the device model
     workload_name: str
         The name of the workload. (The first item in the workload tuple)
     template_key: str
@@ -218,12 +218,15 @@ def load_reference_log(backend, model, workload_name, template_key):
         if os.path.isfile(os.path.join(AUTOTVM_TOPHUB_ROOT_PATH, package_name)):
             find = False
             inp = None
+            counts = {}
             for inp, res in load_from_file(filename):
+                counts[inp.target.model] = counts.get(inp.target.model, 0) + 1
                 if model == inp.target.model:
                     find = True
                     break
-            if not find and inp:
-                model = inp.target.model
+            # if device model is not find, use the device model with the most tuned worklaods
+            if not find and counts:
+                model = max(counts.items(), key=lambda k: k[1])[0]
 
             for inp, res in load_from_file(filename):
                 if (model == inp.target.model and inp.task.workload[0] == workload_name and