-
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
feat[next]: Refactor CSE pass to support ITIR.Program (GTIR branch) #1579
Conversation
@@ -264,25 +264,23 @@ def visit_FunCall(self, node: gtfn_ir.FunCall, **kwargs: Any) -> gtfn_ir_common. | |||
self.imp_list_ir.append(InitStmt(lhs=gtfn_ir_common.Sym(id=f"{lam_idx}"), rhs=node)) | |||
return gtfn_ir_common.SymRef(id=f"{lam_idx}") | |||
if isinstance(node.fun, gtfn_ir.Lambda): |
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.
The scoping here was completely broken leading to multiple SymbolName's with the same id being declared in InitStmt
. The fix is ok, but not great.
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.
It looks good. I have mostly questions and optional suggestions.
@@ -365,10 +371,10 @@ class CommonSubexpressionElimination(PreserveLocationVisitor, NodeTranslator): | |||
Perform common subexpression elimination. | |||
|
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.
Could you briefly outline here the algorithm and the used tools (e.g. other visitors, functions, ...)
@@ -116,15 +116,17 @@ def _(lhs: ts.ScalarType, rhs: ts.ScalarType) -> ts.ScalarType | ts.TupleType: | |||
|
|||
|
|||
@_register_builtin_type_synthesizer | |||
def deref(it: it_ts.IteratorType) -> ts.DataType: | |||
def deref(it: it_ts.IteratorType) -> ts.DataType | ts.DeferredType: |
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.
Just a question: is the type annotation for it
correct? Shouldn't it be a union with DeferredType
? If that is the case, why is not type checker complaining here?
def deref(it: it_ts.IteratorType) -> ts.DataType | ts.DeferredType: | |
def deref(it: it_ts.IteratorType| ts.DeferredType) -> ts.DataType | ts.DeferredType: |
src/gt4py/next/program_processors/codegens/gtfn/gtfn_ir_to_gtfn_im_ir.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.
LGTM
Extends the common subexpression elimination to support the new
itir.Program
node and pushes the intermediateFencil
->Program
conversion upwards the pass manager. The CSE pass now uses the type inference such that only field expressions or composites thereof are collected in field-view context (i.e. outside ofas_fieldop
).