benchmark
f66bdcd0 - New `UserDefinedEnumVariable` and Support __contains__ method for Enum and constants (#173223)

Commit
178 days ago
New `UserDefinedEnumVariable` and Support __contains__ method for Enum and constants (#173223) Summary: Fixes L130 in the Asks sheet. Extract Enum class-specific logic from UserDefinedClassVariable into a new UserDefinedEnumClassVariable class, following the pattern of UserDefinedListVariable. Changes: - Add enum_type_methods set to torch/_dynamo/utils.py - Create UserDefinedEnumClassVariable in torch/_dynamo/variables/user_defined.py with _maybe_get_baseclass_method pattern for handling Enum metaclass methods - Update torch/_dynamo/variables/builder.py to use UserDefinedEnumClassVariable for Enum classes - Move all enum tests from test/dynamo/test_misc.py to new test/dynamo/test_enum.py - Add test for custom metaclass __contains__ override Currently unsupported Enum metaclass methods (marked as expectedFailure): - __iter__ (iteration over enum members) - __reversed__ - Flag enum membership checks ``` python -m pytest test/dynamo/test_enum.py -v ``` X-link: https://github.com/pytorch/pytorch/pull/173223 Approved by: https://github.com/williamwen42 Reviewed By: wdvr Differential Revision: D91627970 fbshipit-source-id: 750b70d2f234a69be69a5e4ef304a54d06efa593
Author
Committer
Parents
Loading