-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIR][Schedule] Transform layout quality of life #11269
[TIR][Schedule] Transform layout quality of life #11269
Conversation
@vinx13 A draft of some ease-of-use changes I'd been experimenting with this afternoon. These are python-only, and unpack to the same C++ calls, so it (hopefully) shouldn't cause issues elsewhere. |
This is super cool, thanks for the PR. Shall we consider more informative names on what's being sugared. For example, |
I'd definitely be up for a better name, as Another alternative would be to merge this as the input handling of |
Something sort of like the changes here are what I'm picturing. Not complete, because |
#11289 should resolve the type-checking annotation issue with Tuples, if we want to go forward with the other changes here. |
Previously, the implementations of `tir.IndexMap.from_func` and `te.Stage.transform_layout` had significant duplication to handle argument parsing. This commit extracts the shared logic into `tir.IndexMap`.
5ce8acb
to
ec66ff1
Compare
CI functionality tests all passed, updates to resolve sphinx documentation tests, and rebase to resolve merge conflict. |
buffer_index: int, | ||
buffer_index_type: str, | ||
block: Union[BlockRV, str], | ||
buffer: Union[Tuple[str, int], str, Buffer], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will break trace to python conversion. It is implemented here https://github.com/apache/tvm/blob/main/src/tir/schedule/primitive/layout_transformation.cc#L288. Unfortunately CI didn’t catch this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the catch, and I'll update TransformLayoutTraits::UnpackedAsPython
with the updated arguments. Is there somewhere that should have an additional test for round-tripping the python conversion? It looks like this UnpackedAsPython
is used in Trace.as_python
, but I don't see any tests that call it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found it. The verify_trace_roundtrip
helper function verifies that the trace can be round-tripped through JSON, and that the trace can be converted to python, but doesn't verify that the trace can be round-tripped through python.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be corrected now, including updates to verify_trace_roundtrip
to validate the python roundtrip by default. If this finds other breakages unrelated to this PR, I'll limit the python roundtrip checks to opt-in tests, with a tracking issue to resolve any other breakages.
This wasn't checked before, but was the only other issue caught by the updates to verify_trace_roundtrip.
All tests passing, including tests for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! I really like the new interface and refactoring under IndexMap for reuse in TE and TIR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM
Disabled while waiting for apache#11289, which was required for the `Tuple` argument.
Current CI failures due to Scipy URL change, should restart CI after #11399 lands. |
a7251f2
to
a513f18
Compare
CI failure in |
CI failure this time was due to CUDA version in |
5af3cfd
to
00e7eb6
Compare
Retriggering CI following #11456. |
Similar to apache#11269, which added this functionality to `Schedule.transform_layout`.
…11624) * [Schedule] Allowed string argument as block arg This has previously been implemented for `Schedule.transform_layout` in #11296, extending to allow for block arguments in all `Schedule` methods. This change was only made for arguments that must be a `BlockRV`. For arguments that may be either a `BlockRV` or another type (e.g. `Schedule.get_child_blocks` accepts either `BlockRV` or `LoopRV`), this sugar is not implemented, to avoid ambiguity. * [Schedule] Allowed string argument to Schedule.reindex Similar to #11269, which added this functionality to `Schedule.transform_layout`. * CI test update
…pache#11624) * [Schedule] Allowed string argument as block arg This has previously been implemented for `Schedule.transform_layout` in apache#11296, extending to allow for block arguments in all `Schedule` methods. This change was only made for arguments that must be a `BlockRV`. For arguments that may be either a `BlockRV` or another type (e.g. `Schedule.get_child_blocks` accepts either `BlockRV` or `LoopRV`), this sugar is not implemented, to avoid ambiguity. * [Schedule] Allowed string argument to Schedule.reindex Similar to apache#11269, which added this functionality to `Schedule.transform_layout`. * CI test update
Follow-up from apache#11269, which allowed schedule arguments of the buffer to be transformed to be specified as a string, or as a `tir::Buffer`. The string handling worked correctly, but the `tir::Buffer` object was handled incorrectly. This commit corrects the handling of `tir::Buffer` arguments when scheduling, and adds a unit test to validate this behavior.
…2816) Follow-up from #11269, which allowed schedule arguments of the buffer to be transformed to be specified as a string, or as a `tir::Buffer`. The string handling worked correctly, but the `tir::Buffer` object was handled incorrectly. This commit corrects the handling of `tir::Buffer` arguments when scheduling, and adds a unit test to validate this behavior.
…ache#12816) Follow-up from apache#11269, which allowed schedule arguments of the buffer to be transformed to be specified as a string, or as a `tir::Buffer`. The string handling worked correctly, but the `tir::Buffer` object was handled incorrectly. This commit corrects the handling of `tir::Buffer` arguments when scheduling, and adds a unit test to validate this behavior.
Draft PR, seeing whether some of the TE-specific interface features can be pulled over into the TIR-based schedules. These are implemented as
Schedule.transform_layout_sugared
, which wraps around the existingSchedule.transform_layout
.Schedule.get_block
.*args
in the index mapping function.AXIS_SEPARATOR
in the index mapping function, delegate toSchedule.set_axis_separators