This is an automated email from the ASF dual-hosted git repository. tqchen pushed a commit to branch refactor-s1 in repository https://gitbox.apache.org/repos/asf/tvm.git
commit fd75d57c4c8134276073ff226e0c16cec6ae892b Author: tqchen <[email protected]> AuthorDate: Sun Apr 13 15:38:53 2025 -0400 Legacy always returns raw string to keep things simple --- python/tvm/runtime/container.py | 7 ++++--- python/tvm/target/target.py | 4 ++-- tests/python/ir/test_ir_container.py | 1 - tests/python/ir/test_node_reflection.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/python/tvm/runtime/container.py b/python/tvm/runtime/container.py index 17d9af464b..5fe5a303fe 100644 --- a/python/tvm/runtime/container.py +++ b/python/tvm/runtime/container.py @@ -73,9 +73,10 @@ class String(str, PyNativeObject): def __new__(cls, content): """Construct from string content.""" - val = str.__new__(cls, content) - val.__init_tvm_object_by_constructor__(_ffi_api.String, content) - return val + return str.__new__(str, content) + # val = str.__new__(cls, content) + # val.__init_tvm_object_by_constructor__(_ffi_api.String, content) + # return val # pylint: disable=no-self-argument def __from_tvm_object__(cls, obj): diff --git a/python/tvm/target/target.py b/python/tvm/target/target.py index f54d925ece..41596e4244 100644 --- a/python/tvm/target/target.py +++ b/python/tvm/target/target.py @@ -128,10 +128,10 @@ class Target(Object): target = convert(target) if isinstance(host, (dict, str)): host = convert(host) - if target is None or not isinstance(target, (Map, String, Target)): + if target is None or not isinstance(target, (Map, String, Target, str)): raise ValueError(f"target has to be a string or dictionary. instead get {type(target)}") if host is not None: - if not isinstance(host, (Map, String, Target)): + if not isinstance(host, (Map, String, Target, str)): raise ValueError("target host has to be a string or dictionary.") self.__init_handle_by_constructor__(_ffi_api.Target, Target(target), Target(host)) else: diff --git a/tests/python/ir/test_ir_container.py b/tests/python/ir/test_ir_container.py index 8f408c5a06..eb9f0a983f 100644 --- a/tests/python/ir/test_ir_container.py +++ b/tests/python/ir/test_ir_container.py @@ -122,7 +122,6 @@ def test_return_variant_type(): assert res_even == 21 res_odd = func(17) - assert isinstance(res_odd, tvm.runtime.String) assert res_odd == "argument was odd" diff --git a/tests/python/ir/test_node_reflection.py b/tests/python/ir/test_node_reflection.py index 595067866f..fe16015891 100644 --- a/tests/python/ir/test_node_reflection.py +++ b/tests/python/ir/test_node_reflection.py @@ -75,7 +75,7 @@ def test_make_node(): assert x.value == 10 A = te.placeholder((10,), name="A") AA = tvm.ir.make_node( - "Tensor", shape=A.shape, dtype=A.dtype, op=A.op, value_index=A.value_index + "te.Tensor", shape=A.shape, dtype=A.dtype, op=A.op, value_index=A.value_index ) assert AA.op == A.op assert AA.value_index == A.value_index
