Lunderberg commented on PR #14320: URL: https://github.com/apache/tvm/pull/14320#issuecomment-1473951122
@junrushao Thank you, and I can work around the issue by using an explicit `T.FloorDiv`, so this isn't by any means a blocking issue for me. It's more that it was an unexpected change, such as in the example below, and I wanted to avoid it becoming a similar issue for others. @cyx-6 Certainly. The example below shows the weird interaction between the dynamic parameter and the variable name, which is what led to my initial investigation. ```python import tvm from tvm.script import tir as T @pytest.mark.parametrize("split_factor", [1, 2, 4]) def test_function(split_factor): @T.prim_func def explicit_tir_node(A: T.Buffer(16, "int32"), B: T.Buffer(16, "int32")): for i in T.serial(T.FloorDiv(16, split_factor)): chunk_start = T.Mul(i, split_factor) for j in T.vectorized(split_factor): B[chunk_start + j] = A[chunk_start + j] @T.prim_func def using_operator(A: T.Buffer(16, "int32"), B: T.Buffer(16, "int32")): for i in T.serial(16 // split_factor): chunk_start = i * split_factor for j in T.vectorized(split_factor): B[chunk_start + j] = A[chunk_start + j] using_operator.show() tvm.ir.assert_structural_equal(explicit_tir_node, using_operator) ``` This passes when the dynamic parameter `split_factor` is 2 or 4, but fails when `split_factor == 1`. In that case, it generates the PrimFunc shown below. For this case, the `chunk_start = i * 1` was constant-folded to `chunk_start = i`, which was then used to rename `i` to `chunk_start` in the loop iterator. ```python @T.prim_func def main(A: T.Buffer((16,), "int32"), B: T.Buffer((16,), "int32")): for chunk_start in range(16): for j in T.vectorized(1): B[chunk_start + j] = A[chunk_start + j] ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org