From eb056bd41432215b89725d396760b56dc7266924 Mon Sep 17 00:00:00 2001 From: Haichen Shen Date: Fri, 28 Jun 2019 20:30:06 -0700 Subject: [PATCH] [Bugfix] Fix AutoTVM bug (#3462) * fix autotvm * fix bug when heap_items is empty --- python/tvm/autotvm/tuner/sa_model_optimizer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/tvm/autotvm/tuner/sa_model_optimizer.py b/python/tvm/autotvm/tuner/sa_model_optimizer.py index 39934b3..babc612 100644 --- a/python/tvm/autotvm/tuner/sa_model_optimizer.py +++ b/python/tvm/autotvm/tuner/sa_model_optimizer.py @@ -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: -- 2.7.4