Add fallback for ApplyGraphBest (#2485)
authorYao Wang <kevinthesunwy@gmail.com>
Fri, 1 Feb 2019 02:43:40 +0000 (18:43 -0800)
committerLianmin Zheng <mercy_zheng@sjtu.edu.cn>
Fri, 1 Feb 2019 02:43:40 +0000 (10:43 +0800)
python/tvm/autotvm/task/dispatcher.py

index c5464f94f285cecd50f9ad345ebc756ad5049dec..f497ddc038db3246a3d51285fb254a91ba1c027a 100644 (file)
@@ -460,7 +460,16 @@ class ApplyGraphBest(DispatchContext):
             self.update(target, workload, cfg)
             return cfg
         key = (str(target), workload)
-        return self._global_cfg_dict[key]
+        if key not in self._global_cfg_dict:
+            msg = "Config for target=%s, workload=%s is missing in ApplyGraphBest context. " \
+                  "A fallback configuration is used, which may bring great performance " \
+                  "regression." % (target, workload)
+            logger.warning(msg)
+            cfg = FallbackConfigEntity()
+            self._global_cfg_dict[key] = cfg
+        else:
+            cfg = self._global_cfg_dict[key]
+        return cfg
 
     def update(self, target, workload, cfg):
         key = (str(target), workload)