This is an automated email from the ASF dual-hosted git repository.

tqchen pushed a commit to branch script/canonical-parser-df
in repository https://gitbox.apache.org/repos/asf/tvm.git

commit 2b486205ba8a5c062bb39d45a0ad690815749bd2
Author: Tianqi Chen <[email protected]>
AuthorDate: Wed Sep 23 08:48:06 2026 +0000

    Check explicit body symbols in portable script output
---
 tests/python/relax/test_bind_symbolic_vars.py        | 3 +--
 tests/python/relax/test_tvmscript_type_vars.py       | 4 +++-
 tests/python/tirx/test_tvmscript_type_vars.py        | 4 +++-
 tests/python/tvmscript/test_tvmscript_printer_tir.py | 2 +-
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/tests/python/relax/test_bind_symbolic_vars.py 
b/tests/python/relax/test_bind_symbolic_vars.py
index b2f680c4d7..f42271b65a 100644
--- a/tests/python/relax/test_bind_symbolic_vars.py
+++ b/tests/python/relax/test_bind_symbolic_vars.py
@@ -14,8 +14,6 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-# ruff: noqa: F821
-
 import pytest
 
 import tvm
@@ -197,6 +195,7 @@ def test_bind_symbolic_vars_in_shape_expr():
 
     @R.function(private=True)
     def expected(A: R.Tensor(["M * 16"]), x: R.Shape(["M", 16])):
+        M = T.int64()
         B = R.call_dps_packed("dummy_func", [A], out_ty=R.Tensor([M * 32]))
         return B
 
diff --git a/tests/python/relax/test_tvmscript_type_vars.py 
b/tests/python/relax/test_tvmscript_type_vars.py
index 990a9582f7..9dedab1bc0 100644
--- a/tests/python/relax/test_tvmscript_type_vars.py
+++ b/tests/python/relax/test_tvmscript_type_vars.py
@@ -38,6 +38,7 @@ def test_type_vars_roundtrip():
         assert script.startswith("from __future__ import annotations\n\n")
         assert "def main[M](" in script
         assert 'R.Tensor((M, M * 2), dtype="float32")' in script
+        assert "M = T.int64()" not in script
         typed = tvm.script.from_source(
             """
 @R.function(private=True)
@@ -49,13 +50,14 @@ def func[M: int](x: R.Tensor((M, M * 2), "float32")):
     else:
         assert "from __future__ import annotations" not in script
         assert 'M = TypeVar("M")' in script
+        assert "M = T.int64()" in script
         assert 'R.Tensor((M, "M * 2"), dtype="float32")' in script
 
     portable = func.script(extra_config={"relax.use_pep695": False})
     assert "from __future__ import annotations" not in portable
     assert 'M = TypeVar("M")' in portable
     assert 'R.Tensor((M, "M * 2"), dtype="float32")' in portable
-    assert "M = T.int64()" not in script
+    assert "M = T.int64()" in portable
     assert "UNUSED_GENERIC" not in script
     assert [param.name for param in func.params] == ["x"]
     assert not hasattr(func, "type_params")
diff --git a/tests/python/tirx/test_tvmscript_type_vars.py 
b/tests/python/tirx/test_tvmscript_type_vars.py
index c3d13f122b..eb35952d2b 100644
--- a/tests/python/tirx/test_tvmscript_type_vars.py
+++ b/tests/python/tirx/test_tvmscript_type_vars.py
@@ -38,6 +38,7 @@ def func(A: T.Buffer((M, M * 2), "float32")):
         assert script.startswith("from __future__ import annotations\n\n")
         assert "def main[M](" in script
         assert 'T.Buffer((M, M * T.int64(2)), "float32")' in script
+        assert "M = T.int64()" not in script
         typed = tvm.script.from_source(
             """
 @T.prim_func(private=True)
@@ -49,13 +50,14 @@ def func[M: int](A: T.Buffer((M, M * 2), "float32")):
     else:
         assert "from __future__ import annotations" not in script
         assert 'M = TypeVar("M")' in script
+        assert "M = T.int64()" in script
 
     portable = func.script(extra_config={"script.use_pep695": False})
     assert "from __future__ import annotations" not in portable
     assert 'M = TypeVar("M")' in portable
     assert 'T.Buffer((M, "M * T.int64(2)"), "float32")' in portable
     assert "UNUSED" not in script
-    assert "M = T.int64()" not in script
+    assert "M = T.int64()" in portable
     assert len(func.params) == 1
     assert not hasattr(func, "type_params")
     assert func.attrs.get("tirx.type_vars") is None
diff --git a/tests/python/tvmscript/test_tvmscript_printer_tir.py 
b/tests/python/tvmscript/test_tvmscript_printer_tir.py
index b1a911797d..0644b288f4 100644
--- a/tests/python/tvmscript/test_tvmscript_printer_tir.py
+++ b/tests/python/tvmscript/test_tvmscript_printer_tir.py
@@ -66,7 +66,7 @@ def test_prim_func_symbolic_buffer_param_roundtrip():
     )
 
     source = func.script()
-    assert 'T.Buffer(("n + 1", n)' in source
+    assert 'T.Buffer(("n + 1", "n")' in source
     assert source.index("n = T.int32()") < source.index("T.evaluate(n)")
     tvm.ir.assert_structural_equal(tvm.script.from_source(source), func)
 

Reply via email to