tlopex commented on code in PR #18633:
URL: https://github.com/apache/tvm/pull/18633#discussion_r2661585587
##########
tests/python/relax/test_transform_to_mixed_precision.py:
##########
@@ -1064,5 +1064,58 @@ def tir_identity(
tvm.ir.assert_structural_equal(Expected, After)
+def test_dynamic_strided_slice():
+ @I.ir_module
+ class Input:
+ @R.function
+ def main(
+ x: R.Tensor((2, 3, 28, 28), "float32"),
+ w: R.Tensor((4, 3, 3, 3), "float32"),
+ begin: R.Tensor((4,), "int64"),
+ end: R.Tensor((4,), "int64"),
+ strides: R.Tensor((4,), "int64"),
+ ) -> R.Tensor(None, "float32", ndim=4):
+ with R.dataflow():
+ lv: R.Tensor((2, 4, 26, 26), "float32") = R.nn.conv2d(x, w,
out_dtype="float32")
+ gv = R.dynamic_strided_slice(lv, begin, end, strides)
+ R.output(gv)
+ return gv
+
+ @I.ir_module
+ class Expected:
+ @R.function
+ def main(
+ x: R.Tensor((2, 3, 28, 28), dtype="float32"),
+ w: R.Tensor((4, 3, 3, 3), dtype="float32"),
+ begin: R.Tensor((4,), dtype="int64"),
+ end: R.Tensor((4,), dtype="int64"),
+ strides: R.Tensor((4,), dtype="int64"),
+ ) -> R.Tensor(None, dtype="float32", ndim=4):
+ with R.dataflow():
+ lv: R.Tensor((2, 3, 28, 28), dtype="float16") = R.astype(x,
dtype="float16")
+ lv1: R.Tensor((4, 3, 3, 3), dtype="float16") = R.astype(w,
dtype="float16")
+ lv2: R.Tensor((2, 4, 26, 26), dtype="float32") = R.nn.conv2d(
+ lv,
+ lv1,
+ strides=[1, 1],
+ padding=[0, 0, 0, 0],
+ dilation=[1, 1],
+ groups=1,
+ data_layout="NCHW",
+ kernel_layout="OIHW",
+ out_layout="NCHW",
+ out_dtype="float32",
+ )
+ lv3: R.Tensor((2, 4, 26, 26), dtype="float16") = R.astype(lv2,
dtype="float16")
+ lv4: R.Tensor((2, 4, 26, 26), dtype="float32") = R.astype(lv3,
dtype="float32")
+ gv: R.Tensor(None, dtype="float32", ndim=4) =
R.dynamic_strided_slice(
+ lv4, begin, end, strides
+ )
+ R.output(gv)
+ return gv
+
+ _assert_test(Input, Expected)
Review Comment:
Why we don't use `tvm.ir.assert_structural_equal` here?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]