vinx13 commented on a change in pull request #9306:
URL: https://github.com/apache/tvm/pull/9306#discussion_r734110251



##########
File path: tests/python/unittest/test_tir_schedule_reorder.py
##########
@@ -275,8 +275,37 @@ def test_reorder_fail_not_affine_bindings():
     sch = tir.Schedule(elementwise_not_affine, debug_mask="all")
     block_b = sch.get_block("B")
     i, j, k, l = sch.get_loops(block_b)
-    with pytest.raises(tvm.tir.ScheduleError):
+    with pytest.raises(tvm.tir.ScheduleError) as msg:
+        sch.reorder(l, i)
+
+
+def test_reorder_fail_error_msg():

Review comment:
       move error rendering test cases to `test_tvmscript_error_report.py`

##########
File path: tests/python/unittest/test_tir_schedule_reorder.py
##########
@@ -275,8 +275,37 @@ def test_reorder_fail_not_affine_bindings():
     sch = tir.Schedule(elementwise_not_affine, debug_mask="all")
     block_b = sch.get_block("B")
     i, j, k, l = sch.get_loops(block_b)
-    with pytest.raises(tvm.tir.ScheduleError):
+    with pytest.raises(tvm.tir.ScheduleError) as msg:
+        sch.reorder(l, i)
+
+
+def test_reorder_fail_error_msg():
+    sch = tir.Schedule(elementwise_not_affine, debug_mask="all")
+    block_b = sch.get_block("B")
+    i, j, k, l = sch.get_loops(block_b)
+    with pytest.raises(tvm.tir.ScheduleError) as execinfo:
         sch.reorder(l, i)
+    expected_sub_error_message = (
+        "                # tir.Block#0\n"

Review comment:
       let's use python's multi-line string, i.e. 
   ```
   """
   tir.Block#0
   ...
   """
   ```

##########
File path: tests/python/unittest/test_tir_schedule_reorder.py
##########
@@ -275,8 +275,37 @@ def test_reorder_fail_not_affine_bindings():
     sch = tir.Schedule(elementwise_not_affine, debug_mask="all")
     block_b = sch.get_block("B")
     i, j, k, l = sch.get_loops(block_b)
-    with pytest.raises(tvm.tir.ScheduleError):
+    with pytest.raises(tvm.tir.ScheduleError) as msg:
+        sch.reorder(l, i)
+
+
+def test_reorder_fail_error_msg():
+    sch = tir.Schedule(elementwise_not_affine, debug_mask="all")
+    block_b = sch.get_block("B")
+    i, j, k, l = sch.get_loops(block_b)
+    with pytest.raises(tvm.tir.ScheduleError) as execinfo:
         sch.reorder(l, i)
+    expected_sub_error_message = (
+        "                # tir.Block#0\n"
+        '                with tir.block("B"):\n'
+        "                ^^^^^^^^^^^^^^^^^^^^\n"
+    )
+    assert expected_sub_error_message in str(execinfo.value)
+
+
+def test_reorder_fail_nested_loop():
+    sch = tir.Schedule(elementwise_non_single_branch, debug_mask="all")
+    block_b = sch.get_block("B")
+    i, j, k = sch.get_loops(block_b)
+    with pytest.raises(tvm.tir.ScheduleError) as execinfo:
+        sch.reorder(k, i)
+    expected_sub_error_message = (
+        "        for i in tir.serial(0, 128):\n"
+        "            # tir.For#0\n"
+        "            for j in tir.serial(0, 128):\n"
+        "            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"
+    )
+    assert expected_sub_error_message in str(execinfo.value)

Review comment:
       let's add another similar test case where `loop i` is annotated showing 
in this case `i, j` won't be compressed 
   ```
   # tir.For#0
   for i in tir.serial(...)
   ^^^^^^^^^^^^^^
      for j in ...
   ```




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


Reply via email to