-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Support Python Slice class in TorchScript #44335
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
💊 CI failures summary and remediationsAs of commit dc08fe7 (more details on the Dr. CI page):
ci.pytorch.org: 1 failedThis 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 or post in the (internal) Dr. CI Users group. This comment has been revised 86 times. |
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.
Note to reviewer:
I changed name of this argument from "begin" to "start" to match the schema of aten::slice. I think it worked before because this argument is always used as positional argument. Let me know if there are other things to consider.
SplitInfinity
left a comment
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.
What is the motivation for this work? What can slice objects support that slice expressions do not already support?
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.
Consider adding a comment like the one above which explains that this code handles slice objects.
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.
Done.
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.
Maybe SliceValue because this is a regular SugaredValue?
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 is actually something I want to get advice on. It is a vanilla SugaredValue only because ir_emitter needs it and ir_emitter can't depend on python_sugared_value. In reality, PythonSliceValue does represent a python object, thus the python prefix. Let me know what you think.
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.
Hm, there is a ClassValue class that also extends SugaredValue that represents Python classes. So I think SliceValue would be better 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.
Done.
gmagogsfm
left a comment
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.
As for motivation, this is to fix #43511
The only one case where a slice object is better than slice expression, that is to share slice expression among different objects. Otherwise they are equivalent. So motivation is to fix the issue and enable one more language feature to save users some work-around time.
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.
Done.
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 is actually something I want to get advice on. It is a vanilla SugaredValue only because ir_emitter needs it and ir_emitter can't depend on python_sugared_value. In reality, PythonSliceValue does represent a python object, thus the python prefix. Let me know what you think.
Codecov Report
@@ Coverage Diff @@
## master #44335 +/- ##
=======================================
Coverage 68.04% 68.04%
=======================================
Files 384 384
Lines 49814 49814
=======================================
Hits 33897 33897
Misses 15917 15917 Continue to review full report at Codecov.
|
facebook-github-bot
left a comment
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.
@gmagogsfm has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
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.
@gmagogsfm has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
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.
@gmagogsfm has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
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.
@gmagogsfm has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
SplitInfinity
left a comment
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.
Why did so few CI jobs run on this? Please try to get that extra signal before attempting to land this.
Because I rebased this morning to circumvent a Phabricator patch issue. You happened to open this PR when I just rebased, so CIs are just beginning. |
facebook-github-bot
left a comment
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.
@gmagogsfm has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
@gmagogsfm merged this pull request in 9909327. |
Summary: Implements support for[ Python Slice class](https://docs.python.org/3/c-api/slice.html) (not slice expression, which is already supported) Slice object can be used in any place that supports slice expression, including multi-dim tensor slicing. Fixes #43511 Fixes #43125 Pull Request resolved: #44335 Reviewed By: suo, jamesr66a Differential Revision: D23682213 Pulled By: gmagogsfm fbshipit-source-id: f74fe25370e89fbfd2b3727d95ce4e1c4ba8dec4
Implements support for Python Slice class (not slice expression, which is already supported)
Slice object can be used in any place that supports slice expression, including multi-dim tensor slicing.
Fixes #43511
Fixes #43125