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



##########
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:
       I would really prefer the use of ("str1" "str2" "str3") as pylinter 
tends to re-organize the multi-line strings and therefore make the expected 
string different from the actual output.

##########
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:
       added

##########
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:
       done




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