-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[TensorExpr] Add support for Axis reordering in LoopNest #36540
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
Conversation
342c0ce
to
04ae0bc
Compare
💊 Build failures summary and remediationsAs of commit 5ae30e4 (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker. This comment has been revised 19 times. |
89658c4
to
ac0f9e7
Compare
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.
Looks good! I didn't follow all the logic but I trust your tests :) I left some questions inline - they are not to request changes but rather to double check my own understanding.
torch/csrc/jit/tensorexpr/stmt.h
Outdated
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.
Do you feel this methods will generally be helpful in other use-cases? If not, I'd rather make it a local helper method rather than pulling it into the For class itself.
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 did use it in the ReductionExpander as well - but they're both in loopnest.cpp so for now could be local (could be complicated if we pull the mutators out of loopnest). I think this is generally a useful helper though, I think we'll reuse it again.
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.
Nit: according to std convention, it's probably better to change nparams
to return size_t
.
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.
You're right. That would touch quite a few different places in the code though so rather not roll into this diff.
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.
Just curious: why do we clone here?
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.
root_stmt returns the internal pointer, which is modified by reorderAxis below. We need to clone to preserve the original behaviour.
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.
We don't really use the tensor here, only its loops: maybe take std::vector<For*>
as the first parameter instead (on the callsite we'll get it by l.getLoopStmtsFor(t)
)?
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.
Not sure about this. It would save the extra call to getLoopStatementsFor but it's not longer really a loopNest thing. Prefer to refactor when we pull this and maybe rfactor/split out
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 was thinking about it mostly from the data we're accessing here: we pass the tensor, but only use part of it that's responsible for the corresponding loops. That made me think that we should pass only the loops since we're not using anything else from the tensor. I don't have a strong preference on it though since we don't have clear guidelines on it yet anyways :)
ac0f9e7
to
5ae30e4
Compare
addressed comments |
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.
@nickgg is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Adds a capability for reordering axes in the LoopNest. This was fairly straightforward except when handling Reduction initializers which required more changes, UPDATE: actually the complicated bit was preserving the ordering of statements in the loopnest which should not be reordered.
Usage looks something like this: