From f2ab977de0ac543cae77d3bef76af1b56dd61eed Mon Sep 17 00:00:00 2001 From: roger-zhao Date: Wed, 30 Dec 2020 15:45:52 +0800 Subject: [PATCH] [AutoTVM-FIX] avoid unexpected value(1) of search space when get length for uninitiated search space (#7175) * [AutoTVM-FIX] avoid unexpected value(1) of search space when get length for uninitiated search space * Update python/tvm/autotvm/task/space.py Co-authored-by: Cody Yu Co-authored-by: ZhaoYanjie Co-authored-by: Cody Yu --- python/tvm/autotvm/task/space.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/tvm/autotvm/task/space.py b/python/tvm/autotvm/task/space.py index cf9cd809aa8d..b24ab415c60a 100644 --- a/python/tvm/autotvm/task/space.py +++ b/python/tvm/autotvm/task/space.py @@ -836,6 +836,8 @@ def _add_new_transform(self, space_class, name, axes, policy, **kwargs): return [Axis(None, i) for i in range(space_class.get_num_output(axes, policy, **kwargs))] def __len__(self): + if not self.space_map: + return 0 if self._length is None: self._length = int(np.prod([len(x) for x in self.space_map.values()])) return self._length