You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/08/17 22:21:32 UTC
[GitHub] [tvm] AndrewZhaoLuo opened a new pull request, #12481: [MetaSchedule] Handle deserializing empty string RVs in trace
AndrewZhaoLuo opened a new pull request, #12481:
URL: https://github.com/apache/tvm/pull/12481
It seems sometimes we can have random variables with names such as "" (this is not the empty string, but two quotation marks).
I believe this is suppose to hit "Case 2" in `TranslateInputRVs` and become an empty string but this does not seem to be the case.
Unsure if having an RV as "" may be problematic, if it is, this will certainly hide another bug
cc @junrushao1994
--
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-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] AndrewZhaoLuo merged pull request #12481: [MetaSchedule] Handle deserializing empty string RVs in trace
Posted by GitBox <gi...@apache.org>.
AndrewZhaoLuo merged PR #12481:
URL: https://github.com/apache/tvm/pull/12481
--
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-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] zxybazh commented on a diff in pull request #12481: [MetaSchedule] Handle deserializing empty string RVs in trace
Posted by GitBox <gi...@apache.org>.
zxybazh commented on code in PR #12481:
URL: https://github.com/apache/tvm/pull/12481#discussion_r948491602
##########
tests/python/unittest/test_tir_schedule_trace.py:
##########
@@ -275,5 +284,53 @@ def test_apply_json_to_schedule_1():
tvm.ir.assert_structural_equal(elementwise_inlined, sch.mod["main"])
+def _test_apply_annotation_trace_from_json(annotation: str):
+ """Test applying an annotation works without crashing.
+
+ Designed to handle some previously failing edge cases like the
+ empty string.
+ """
+ b0 = BlockRV()
+ trace = Trace(
+ insts=[
+ _make_get_block(name="B", output=b0),
+ _make_annotate(block=b0, annotation=annotation),
+ ],
+ decisions={},
+ )
+ json_obj = trace.as_json()
+ sch = tir.Schedule(elementwise, debug_mask="all")
+ Trace.apply_json_to_schedule(json_obj, sch)
+
+ @T.prim_func
+ def elementwise_expected(a: T.handle, c: T.handle) -> None:
+ A = T.match_buffer(a, (128, 128))
+ B = T.alloc_buffer((128, 128))
+ C = T.match_buffer(c, (128, 128))
+ for i, j in T.grid(128, 128):
+ with T.block("B"):
+ T.block_attr({"meta_schedule.auto_tensorize":annotation})
+ vi, vj = T.axis.remap("SS", [i, j])
+ B[vi, vj] = A[vi, vj] * 2.0
+ for i, j in T.grid(128, 128):
+ with T.block("C"):
+ vi, vj = T.axis.remap("SS", [i, j])
+ C[vi, vj] = B[vi, vj] + 1.0
+
+ tvm.ir.assert_structural_equal(elementwise_expected, sch.mod["main"])
+
+def test_apply_annotation_from_json():
+ # Something reasonable
+ _test_apply_annotation_trace_from_json("SSRSSR")
+
+ # The empty string
+ _test_apply_annotation_trace_from_json("")
+
+ # A string of two quotation marks
+ _test_apply_annotation_trace_from_json('""')
+
+ # A string of one quotation mark
+ _test_apply_annotation_trace_from_json('"')
Review Comment:
Nit picking, I find this quotation mark evil, because it's not matched and any single character would be good enough for this test case right?
--
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-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] AndrewZhaoLuo commented on a diff in pull request #12481: [MetaSchedule] Handle deserializing empty string RVs in trace
Posted by GitBox <gi...@apache.org>.
AndrewZhaoLuo commented on code in PR #12481:
URL: https://github.com/apache/tvm/pull/12481#discussion_r948494081
##########
tests/python/unittest/test_tir_schedule_trace.py:
##########
@@ -275,5 +284,53 @@ def test_apply_json_to_schedule_1():
tvm.ir.assert_structural_equal(elementwise_inlined, sch.mod["main"])
+def _test_apply_annotation_trace_from_json(annotation: str):
+ """Test applying an annotation works without crashing.
+
+ Designed to handle some previously failing edge cases like the
+ empty string.
+ """
+ b0 = BlockRV()
+ trace = Trace(
+ insts=[
+ _make_get_block(name="B", output=b0),
+ _make_annotate(block=b0, annotation=annotation),
+ ],
+ decisions={},
+ )
+ json_obj = trace.as_json()
+ sch = tir.Schedule(elementwise, debug_mask="all")
+ Trace.apply_json_to_schedule(json_obj, sch)
+
+ @T.prim_func
+ def elementwise_expected(a: T.handle, c: T.handle) -> None:
+ A = T.match_buffer(a, (128, 128))
+ B = T.alloc_buffer((128, 128))
+ C = T.match_buffer(c, (128, 128))
+ for i, j in T.grid(128, 128):
+ with T.block("B"):
+ T.block_attr({"meta_schedule.auto_tensorize":annotation})
+ vi, vj = T.axis.remap("SS", [i, j])
+ B[vi, vj] = A[vi, vj] * 2.0
+ for i, j in T.grid(128, 128):
+ with T.block("C"):
+ vi, vj = T.axis.remap("SS", [i, j])
+ C[vi, vj] = B[vi, vj] + 1.0
+
+ tvm.ir.assert_structural_equal(elementwise_expected, sch.mod["main"])
+
+def test_apply_annotation_from_json():
+ # Something reasonable
+ _test_apply_annotation_trace_from_json("SSRSSR")
+
+ # The empty string
+ _test_apply_annotation_trace_from_json("")
+
+ # A string of two quotation marks
+ _test_apply_annotation_trace_from_json('""')
+
+ # A string of one quotation mark
+ _test_apply_annotation_trace_from_json('"')
Review Comment:
It's supposed to be evil :^).
Any single other character would work but it's still an edge case from a black box point of unittesting.
--
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-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] junrushao1994 commented on a diff in pull request #12481: [MetaSchedule] Handle deserializing empty string RVs in trace
Posted by GitBox <gi...@apache.org>.
junrushao1994 commented on code in PR #12481:
URL: https://github.com/apache/tvm/pull/12481#discussion_r948539690
##########
tests/python/unittest/test_tir_schedule_trace.py:
##########
@@ -275,5 +284,53 @@ def test_apply_json_to_schedule_1():
tvm.ir.assert_structural_equal(elementwise_inlined, sch.mod["main"])
+def _test_apply_annotation_trace_from_json(annotation: str):
+ """Test applying an annotation works without crashing.
+
+ Designed to handle some previously failing edge cases like the
+ empty string.
+ """
+ b0 = BlockRV()
+ trace = Trace(
+ insts=[
+ _make_get_block(name="B", output=b0),
+ _make_annotate(block=b0, annotation=annotation),
+ ],
+ decisions={},
+ )
+ json_obj = trace.as_json()
+ sch = tir.Schedule(elementwise, debug_mask="all")
+ Trace.apply_json_to_schedule(json_obj, sch)
+
+ @T.prim_func
+ def elementwise_expected(a: T.handle, c: T.handle) -> None:
+ A = T.match_buffer(a, (128, 128))
+ B = T.alloc_buffer((128, 128))
+ C = T.match_buffer(c, (128, 128))
+ for i, j in T.grid(128, 128):
+ with T.block("B"):
+ T.block_attr({"meta_schedule.auto_tensorize":annotation})
+ vi, vj = T.axis.remap("SS", [i, j])
+ B[vi, vj] = A[vi, vj] * 2.0
+ for i, j in T.grid(128, 128):
+ with T.block("C"):
+ vi, vj = T.axis.remap("SS", [i, j])
+ C[vi, vj] = B[vi, vj] + 1.0
+
+ tvm.ir.assert_structural_equal(elementwise_expected, sch.mod["main"])
+
+def test_apply_annotation_from_json():
+ # Something reasonable
+ _test_apply_annotation_trace_from_json("SSRSSR")
+
+ # The empty string
+ _test_apply_annotation_trace_from_json("")
+
+ # A string of two quotation marks
+ _test_apply_annotation_trace_from_json('""')
+
+ # A string of one quotation mark
+ _test_apply_annotation_trace_from_json('"')
Review Comment:
super evil. i love that!
--
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-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org