From e31b648f3cf0084bbd62d8fd5ea3a2962ad4fd45 Mon Sep 17 00:00:00 2001 From: Egor Churaev Date: Mon, 17 Oct 2022 16:11:48 +0300 Subject: [PATCH 1/2] [HotFix] Fix python import Tuning doesn't work after #12969. It reports the following error: ``` ImportError: cannot import name 'get_const_float' from partially initialized module 'tvm.topi.utils' (most likely due to a circular import) ``` In this commit I moved import relay to a function which used in a test. And it helps to fix this circular import --- python/tvm/topi/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/tvm/topi/utils.py b/python/tvm/topi/utils.py index f6ca03d32742..746af95afe36 100644 --- a/python/tvm/topi/utils.py +++ b/python/tvm/topi/utils.py @@ -22,7 +22,7 @@ import numpy as np import tvm -from tvm import relay, te +from tvm import te from tvm.tir import bijective_layout, layout from . import cpp, tag @@ -452,6 +452,8 @@ def change_constant_shape(src, src_layout, dst_layout): dst_shape : relay.Constant A copy of the Constant with the new layout. """ + from tvm import relay + assert src_layout.isalpha() and dst_layout.isalpha() axis_order = [src_layout.index(c) for c in dst_layout] reshaped = np.transpose(src.data.numpy(), axis_order) From 82a4393c614563c28ef3ed2f0420e1e2384a4fd8 Mon Sep 17 00:00:00 2001 From: Egor Churaev Date: Mon, 17 Oct 2022 17:15:11 +0300 Subject: [PATCH 2/2] Fix lint --- python/tvm/topi/utils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/python/tvm/topi/utils.py b/python/tvm/topi/utils.py index 746af95afe36..91e29665cda3 100644 --- a/python/tvm/topi/utils.py +++ b/python/tvm/topi/utils.py @@ -452,12 +452,10 @@ def change_constant_shape(src, src_layout, dst_layout): dst_shape : relay.Constant A copy of the Constant with the new layout. """ - from tvm import relay - assert src_layout.isalpha() and dst_layout.isalpha() axis_order = [src_layout.index(c) for c in dst_layout] reshaped = np.transpose(src.data.numpy(), axis_order) - return relay.Constant(tvm.nd.array(reshaped)) + return tvm.relay.Constant(tvm.nd.array(reshaped)) def within_index(b, e, s, i):