[Bugfix] Fix AutoTVM bug (#3462)
authorHaichen Shen <shenhaichen@gmail.com>
Sat, 29 Jun 2019 03:30:06 +0000 (20:30 -0700)
committereqy <eddieyan101@gmail.com>
Sat, 29 Jun 2019 03:30:06 +0000 (20:30 -0700)
* fix autotvm

* fix bug when heap_items is empty

python/tvm/autotvm/tuner/sa_model_optimizer.py

index 39934b3..babc612 100644 (file)
@@ -78,7 +78,7 @@ class SimulatedAnnealingOptimizer(ModelOptimizer):
         heap_items = [(float('-inf'), - 1 - i) for i in range(num)]
         heapq.heapify(heap_items)
         in_heap = set(exclusive)
-        in_heap.update([x for x in heap_items])
+        in_heap.update([x[1] for x in heap_items])
 
         for s, p in zip(scores, points):
             if s > heap_items[0][0] and p not in in_heap:
@@ -128,9 +128,9 @@ class SimulatedAnnealingOptimizer(ModelOptimizer):
                              time.time() - tic)
 
         heap_items.sort(key=lambda item: -item[0])
-        heap_items = [x for x in heap_items if x >= 0]
-        logger.debug("SA iter: %d\tlast_update: %d\tmax-0: %.2f\tmax-1: %.2f\telapsed: %.2f",
-                     k, k_last_modify, heap_items[-1][0], heap_items[0][0], time.time() - tic)
+        heap_items = [x for x in heap_items if x[0] >= 0]
+        logger.debug("SA iter: %d\tlast_update: %d\telapsed: %.2f",
+                     k, k_last_modify, time.time() - tic)
         logger.debug("SA Maximums: %s", heap_items)
 
         if self.persistent: