Support iterating through an Enum class#42661
Support iterating through an Enum class#42661gmagogsfm wants to merge 1 commit intopytorch:masterfrom gmagogsfm:enum_iterate
Conversation
💊 CI failures summary and remediationsAs of commit d37c553 (more details on the Dr. CI page):
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
facebook-github-bot
left a comment
There was a problem hiding this comment.
@gmagogsfm has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
There was a problem hiding this comment.
Wasn't this in your other PR too?
There was a problem hiding this comment.
It is, I didn't want the PRs to depend on each other. Will resolve this conflict when one lands first.
There was a problem hiding this comment.
How come you didn't use ghstack to stack them?
There was a problem hiding this comment.
No real reason, just not used to using it. Maybe I should try it some day.
There was a problem hiding this comment.
I wonder if it would be better to create this list upfront as a constant like we do with the enum values themselves and retrieve it here. If it ends up not being used, it'll be optimized out?
Do you know if there is already an optimization that recognizes that this list construction involves only graph constants and does not perform it at runtime?
There was a problem hiding this comment.
I think unused and constant enum values will be optimized out if unused. However, I am not entirely sure what benefit we get from creating them upfront. Could you help clarify?
There was a problem hiding this comment.
My worry is that this creates a prim::ListConstruct node that creates the list at runtime through a corresponding LIST_CONSTRUCT interpreter op. But we know at compile time how long this list is and what its contents are, so we can avoid constructing the list at run time.
There was a problem hiding this comment.
I am probably missing something. I thought that would get constant folded and become a list constant?
There was a problem hiding this comment.
If that's the case, that's fine too. I think you can probably print the graph attribute in your test to find out for sure?
There was a problem hiding this comment.
Great catch! runCleanUpPasses actually doesn't run constant folding on mutable types (list). Just changed implementation make sure a list constant is generated.
facebook-github-bot
left a comment
There was a problem hiding this comment.
@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 9597af0. |
Summary: [5/N] Implement Enum JIT support Implement Enum class iteration Add aten.ne for EnumType Supported: Enum-typed function arguments using Enum type and comparing them Support getting name/value attrs of enums Using Enum value as constant Support Enum-typed return values Support iterating through Enum class (enum value list) TODO: Support serialization and deserialization Pull Request resolved: pytorch#42661 Reviewed By: SplitInfinity Differential Revision: D22977364 Pulled By: gmagogsfm fbshipit-source-id: 1a0216f91d296119e34cc292791f9aef1095b5a8
[5/N] Implement Enum JIT support
Implement Enum class iteration
Add aten.ne for EnumType
Supported:
Enum-typed function arguments
using Enum type and comparing them
Support getting name/value attrs of enums
Using Enum value as constant
Support Enum-typed return values
Support iterating through Enum class (enum value list)
TODO:
Support serialization and deserialization