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.
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
[Relax] Implement R.ensure_zero_offset and update memory planning for R.view #17145
[Relax] Implement R.ensure_zero_offset and update memory planning for R.view #17145
Changes from 1 commit
2f5d036
59fada7
c742a07
c4e1f29
d1a3243
c931b45
25cc462
7ed6b38
cd553b6
0abe71d
a07aa4f
d5b1588
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 change means that
R.memory.view
is still present in the output ofLegalizeOps
, but a legalization function should replace the operator with a lowered form.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 only does the inference of
void
type args and leave the lowering to the later pass.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.
I don't think we want to do the inference of the shape/dtype prior to lowering, because it could result in unexpected StructInfo inference later on.
Suppose we have
R.memory.view(arg, shape=[16])
. This returns a view into the first 16 elements ofarg
, without changing the dtype. If anIRModule
pass updates the datatype ofarg
, then that new datatype should also propagate to the view. However, legalizing it toR.memory.view(arg, shape=[16], dtype="float16")
would return a view intoarg
, interpreting the first 32 bytes as if they were"float16"
. Now, if anIRModule
pass updates the datatype ofarg
, the view would still be"float16"
. To avoid this issue, the unknown arguments shouldn't be filled in until the lowering is about to occur.What if we were to remove
.set_attr<FLegalize>
altogether, and only have.set_attr<FLowerBuiltin>
? That way, we preserve theR.memory.view
as-is until it is ready to be lowered. TheLegalizeOps
pass would then be a no-op forR.memory.view
, and only theLowerRuntimeBuiltin
pass would change it at all.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.
After replacing the
.set_attr<FLegalize>
forR.memory.view
with.set_attr<FLowerBuiltin>
, the changes to these unit tests can be reverted. Instead, any use ofLegalizeOps
in the unit tests would instead callLowerRuntimeBuiltin
.