From e94903cacf985b7d934b43af98dcd1149e1ff295 Mon Sep 17 00:00:00 2001 From: Eric Lunderberg Date: Fri, 12 Apr 2024 13:09:27 -0500 Subject: [PATCH] [TVMScript][Bug] Add test case for missing symbolic bounds Because Relax struct inference is performed while the function is being built, all constraints on symbolic variables that are used for simplifications must be provided to the analyzer. This is not currently the case, nor is there a clear way to fix this issue. --- tests/python/relax/test_tvmscript_parser.py | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/python/relax/test_tvmscript_parser.py b/tests/python/relax/test_tvmscript_parser.py index e692768a1273..64014d1c49be 100644 --- a/tests/python/relax/test_tvmscript_parser.py +++ b/tests/python/relax/test_tvmscript_parser.py @@ -2293,5 +2293,29 @@ def subroutine(x: R.Tensor, _: R.Shape(["m", "n"])) -> R.Tensor(["m", "n"]): assert func.attrs is not None +@pytest.mark.xfail(reason="Bug: Implicit bounds not provided when parsing") +def test_function_symbolic_variables_are_annotated(): + """Symbolic variables must be exposed for struct inference + + Because Relax struct inference is performed while the function is + being built, all constraints on symbolic variables that are used + for simplifications must be provided to the analyzer. + """ + + @R.function(private=True) + def inferred_sinfo(A: R.Tensor(["extent"])): + extent = T.int64() + output = R.strided_slice(A, [0], [0], [extent - 1]) + return output + + @R.function(private=True) + def expected(A: R.Tensor(["extent"])) -> R.Tensor(["extent-1"]): + extent = T.int64() + output: R.Tensor([extent - 1]) = R.strided_slice(A, [0], [0], [extent - 1]) + return output + + tvm.ir.assert_structural_equal(inferred_sinfo, expected) + + if __name__ == "__main__": tvm.testing.main()