[TIRx][Script] Canonicalize buffer-like tile op arguments#19599
Open
tlopex wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request enhances the TIRx script by allowing BufferLoad objects to be used directly in tile operators, where they are automatically canonicalized to BufferRegion. Key additions include the buffer_from_ptr utility for creating buffer views and new static methods in BufferRegion (full_region, from_point) with corresponding FFI support. The reviewer suggested adding a return type hint to the _to_region helper function and updating the type hints for the silu operator to include BufferLoad for consistency with the new logic.
Member
|
@tvm-bot rerun |
Contributor
|
Failed to re-run CI in https://github.com/apache/tvm/actions/runs/26423833336 Detailswith response |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR improves TIRX buffer-like argument handling for tile ops.
Now TIRX already canonicalizes
BufferLoadintoBufferRegionin several C++ builder paths such asT.reads,T.writes, andT.match_buffer. However, the Python tile-op builder path had separate handling: it only converted plainBufferarguments into full-buffer regions, whileBufferLoadarguments could still be passed through as scalar loads.This PR makes the tile-op path use the same buffer-like canonicalization model:
Bufferbecomes a fullBufferRegionBufferLoadbecomes a single-pointBufferRegionBufferRegionremains unchangedTo avoid duplicating region construction logic in Python, this PR exposes the existing C++ helpers
BufferRegion::FullRegionandBufferRegion::FromPointto Python, and updates both Python tile-op canonicalization and the existing C++BufferRegionFromLoadhelper to useFromPoint.The PR also adds
T.buffer_from_ptr(...)as a script-level convenience for constructing a buffer view from a pointer orBufferLoad. And care is taken to preserve scalar expression behavior for ambiguous overloads. For example,T.max(A[i], B[j])remains a scalar expression, while explicit tile-op forms such asT.max(A[i], B[j], axes=0)canonicalize theBufferLoadarguments into single-point regions.