-
Notifications
You must be signed in to change notification settings - Fork 49
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
refact[next][dace]: split handling of let-statement lambdas from stencil body #1781
Conversation
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.
There are some aspects that needs some changes but it looks not bad.
src/gt4py/next/program_processors/runners/dace_fieldview/gtir_builtin_translators.py
Show resolved
Hide resolved
src/gt4py/next/program_processors/runners/dace_fieldview/gtir_builtin_translators.py
Show resolved
Hide resolved
src/gt4py/next/program_processors/runners/dace_fieldview/gtir_dataflow.py
Outdated
Show resolved
Hide resolved
src/gt4py/next/program_processors/runners/dace_fieldview/gtir_dataflow.py
Outdated
Show resolved
Hide resolved
@@ -1309,3 +1320,38 @@ def visit_SymRef(self, node: gtir.SymRef) -> IteratorExpr | MemletExpr | SymbolE | |||
# if not in the lambda symbol map, this must be a symref to a builtin function | |||
assert param in gtir_python_codegen.MATH_BUILTINS_MAPPING | |||
return SymbolExpr(param, dace.string) | |||
|
|||
def apply( |
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 remember that there is a call to apply()
.
As far as I can tell apply
is only called in this function, so it is a recursive function.
However, it does some highly non trivial pre and post processing.
So I think that:
- This function needs a better name,
apply
is just too generic. - This function needs a doc string.
- This function needs comment that explain why the pre and post processing is needed and how it is 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.
I would like to keep the name apply
for the entry point of this visitor class, since it is consistent with other visitor classes in GT4Py. However, I agree on the rest so I will write some documentation.
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 still think that apply()
is the wrong name. If it is for compatibility, then why was it there before?
_vistit_let()
should be the much better name.
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 have now made a code change in this direction.
src/gt4py/next/program_processors/runners/dace_fieldview/gtir_dataflow.py
Outdated
Show resolved
Hide resolved
src/gt4py/next/program_processors/runners/dace_fieldview/gtir_dataflow.py
Outdated
Show resolved
Hide resolved
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.
There are some small points, but there is nothing serious.
@@ -1309,3 +1320,38 @@ def visit_SymRef(self, node: gtir.SymRef) -> IteratorExpr | MemletExpr | SymbolE | |||
# if not in the lambda symbol map, this must be a symref to a builtin function | |||
assert param in gtir_python_codegen.MATH_BUILTINS_MAPPING | |||
return SymbolExpr(param, dace.string) | |||
|
|||
def apply( |
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 still think that apply()
is the wrong name. If it is for compatibility, then why was it there before?
_vistit_let()
should be the much better name.
prev_symbol_map = self.symbol_map | ||
self.symbol_map = self.symbol_map.copy() |
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.
prev_symbol_map = self.symbol_map | |
self.symbol_map = self.symbol_map.copy() | |
prev_symbol_map = self.symbol_map.copy() |
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 to save the self.symbol_map
object as prev_symbol_map
, just to be on the safe side.
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.
In my view this is indicating that you have some big problems.
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 see what you mean, side effects. Luckily I do not have such problems: I can do the change you propose.
However, in my opinion, I still prefer the original version where I added/removed items from always the same dictionary object, without copying it.
src/gt4py/next/program_processors/runners/dace_fieldview/gtir_dataflow.py
Outdated
Show resolved
Hide resolved
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 still think that apply()
is not needed.
It is not an entry point because it was not needed before (as visit()
was used).
That is true. I will make another change in this direction. |
This is a refactoring of the code to lower lambda nodes: it splits the lowering of let-statements from the lowering of stencil expressions.