abhikran-quic commented on code in PR #13429:
URL: https://github.com/apache/tvm/pull/13429#discussion_r1026749477
##########
tests/python/unittest/test_tir_schedule_transform_layout.py:
##########
@@ -533,6 +533,21 @@ def before():
expected = tvm.tir.schedule.schedule.ScheduleError
+class TestErrorOnNonMatchingTypes(BasePaddingCompare):
+ """The padding must have the same dtype as the buffer"""
+
+ pad_value = tvm.testing.parameter(0)
+
+ def before():
+ A = T.alloc_buffer(14, "float32")
+ for i in T.serial(14):
+ with T.block("block"):
+ vi = T.axis.remap("S", [i])
+ A[vi] = 0
+
+ expected = TypeError
Review Comment:
Yes. `TestErrorOnWrongPaddingType` has the buffer dtype and `pad_value` type
as a variant of `int`. However, for a version of `resnet`, I encountered a
corner case where buffer was of `float32` type whereas `pad_value` was being
passed as `int` to `padded layout_transform` which led to failure while
creating `pad_value` array using `IntImm` in the original code in
`schedule.py`.
Here, I'm trying to add a test case to catch similar behavior. Instead of
catching `TypeError`, I've update the code to catch `ScheduleError`
##########
python/tvm/tir/schedule/schedule.py:
##########
@@ -2751,10 +2751,14 @@ def two_elementwise_transformed_intermediate_buffer(a:
T.handle, c: T.handle) ->
# buffer's type. If the default `tvm.runtime.convert`
# behavior is applied, these would be converted to
# int32/float32, which may not match the buffer's type.
- if isinstance(pad_value, int):
+ if "int" in buffer_obj.dtype and isinstance(pad_value, int):
pad_value = IntImm(buffer_obj.dtype, pad_value)
- elif isinstance(pad_value, float):
+ elif "float" in buffer_obj.dtype and isinstance(pad_value, float):
pad_value = FloatImm(buffer_obj.dtype, pad_value)
+ else:
Review Comment:
Sure. Agree with you as I was not aware of the C++ check.
--
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]