Lunderberg commented on code in PR #12926:
URL: https://github.com/apache/tvm/pull/12926#discussion_r982674487


##########
tests/python/unittest/test_transform_layout.py:
##########
@@ -575,5 +575,18 @@ def test_size_one_buffer(shape, transform):
     s[B].transform_layout(transform)
 
 
+def test_non_divisible_transform_raises_error():
+    A = te.placeholder([1, 3, 8, 8])
+    B = te.compute(A.shape, lambda *indices: A[indices])
+    s = te.create_schedule(B.op)
+
+    transform = lambda n, c, h, w: [n, c // 4, h, w, c % 4]
+    # Error occurs here, because the transformation would introduce
+    # padding.  Padded transforms are supported in TIR-based
+    # schedules.
+    with pytest.raises(tvm.TVMError):
+        s[B].transform_layout(transform)
+
+

Review Comment:
   It could, but I think it would make the test less readable as an example use 
case, specifically what behavior is being tested, because the desired behavior 
differs in each case.  It would look something like below, but there's nothing 
to call attention to the fact that `is_valid` changes the expected behavior, 
and isn't just a parameter being used in the setup.
   
   ```python
   shape, transform, is_valid = tvm.testing.parameters(
       ([1, 8], lambda n, i: [i, n], True),
       ([1, 1, 8], lambda i, j, k: [j, te.AXIS_SEPARATOR, i, k], True),
       ([1, 1, 8], lambda i, j, k: [i, te.AXIS_SEPARATOR, j, k], True),
       ([1, 3, 8, 8], lambda i, j, k: [i, te.AXIS_SEPARATOR, j, k], False),
   )
   
   
   def test_transform_validity(shape, transform, is_valid):
       dtype = "int8"
       A = te.placeholder(shape, dtype, name="A")
       B = te.compute(
           shape=A.shape,
           fcompute=lambda *indices: A[indices].astype(dtype),
           name="B",
       )
       s = te.create_schedule(B.op)
   
       if is_valid:
           s[B].transform_layout(transform)
       else:
           with pytest.raises(tvm.TVMError):
               s[B].transform_layout(transform)
   ```



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