-
Notifications
You must be signed in to change notification settings - Fork 54
feat[cartesian]: IntEnum support #2323
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
base: main
Are you sure you want to change the base?
feat[cartesian]: IntEnum support #2323
Conversation
- Value replaced in frontend - Normalize at `call` time of the stencil
src/gt4py/cartesian/gtscript.py
Outdated
|
|
||
| def enum(class_: type[IntEnum]): | ||
| class_name = class_.__name__ | ||
| if class_name in _ENUM_REGISTER: |
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 think this works and makes for some centralization!
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 like that ENUM_REGISTER is on gtscript, I will probably move it into it's own little space
romanc
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.
I think this looks good as proof of concept. Some suggested wording changes inline.
|
Test fails on 3.10, fine on 3.11. Looks like the |
|
Test will be happy when #2326 is in |
| def get_integer_default_type(): | ||
| """Return the integer numpy type corresponding to the LITERAL_INT_PRECISION set.""" |
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.
That won't work with the per-stencil overrides of literal_integer_precision that we allow. In the GTScriptParser, you have access to the BuildOptions in self.options which contains literal_integer_precision. Likewise, in annotate_definition() of the StencilObject you get the BuildOptions as function argument, so you can get the precision from there.
Description
We introduced the (strict) support for
IntEnumin code and arguments of stencils. The strategy is to replace them with proper integer as soon as possible.Guardrails exists for name clash and
IntEnumderivation.Valid code looks like this
TO CLEAN
gtscriptRequirements