slyubomirsky commented on code in PR #14282:
URL: https://github.com/apache/tvm/pull/14282#discussion_r1134351936


##########
tests/python/relax/test_relax_operators.py:
##########
@@ -193,5 +193,20 @@ def test_op_shape_of():
     assert constrained_shape == tvm.runtime.ShapeTuple([1])
 
 
[email protected]_module
+class TensorToShapeTest:
+    @R.function
+    def run_tensor_to_shape(t: R.Tensor(ndim=1, dtype="int64")) -> R.Shape((1, 
2, 3)):
+        gv: R.Shape(ndim=3) = R.tensor_to_shape(t)
+        return gv
+
+
+def test_op_tensor_to_shape():
+    out_shape = run_cpu(
+        TensorToShapeTest, "run_tensor_to_shape", tvm.nd.array(np.array([1, 2, 
3]).astype("int64"))

Review Comment:
   I think this is correct. We are converting the rank-1 tensor [1, 2, 3] into 
a shape (1, 2, 3). I think the problem here is that `ndim` means different 
things for tensors (where it means the rank) and shapes (where it means the 
number of dimensions denoted by the shape).



##########
tests/python/relax/test_relax_operators.py:
##########
@@ -193,5 +193,20 @@ def test_op_shape_of():
     assert constrained_shape == tvm.runtime.ShapeTuple([1])
 
 
[email protected]_module
+class TensorToShapeTest:
+    @R.function
+    def run_tensor_to_shape(t: R.Tensor(ndim=1, dtype="int64")) -> R.Shape((1, 
2, 3)):
+        gv: R.Shape(ndim=3) = R.tensor_to_shape(t)
+        return gv
+
+
+def test_op_tensor_to_shape():
+    out_shape = run_cpu(
+        TensorToShapeTest, "run_tensor_to_shape", tvm.nd.array(np.array([1, 2, 
3]).astype("int64"))

Review Comment:
   I think the demonstrated behavior is correct. We are converting the rank-1 
tensor [1, 2, 3] into a shape (1, 2, 3). I think the problem here is that 
`ndim` means different things for tensors (where it means the rank) and shapes 
(where it means the number of dimensions denoted by the shape).



-- 
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]

Reply via email to