-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finish domain inference for (nested) concat_where and transform to as…
…_fieldop
- Loading branch information
Showing
18 changed files
with
281 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/gt4py/next/iterator/transforms/expand_library_functions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# GT4Py - GridTools Framework | ||
# | ||
# Copyright (c) 2014-2024, ETH Zurich | ||
# All rights reserved. | ||
# | ||
# Please, refer to the LICENSE file in the root directory. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
from functools import reduce | ||
|
||
from gt4py.eve import NodeTranslator, PreserveLocationVisitor | ||
from gt4py.next.iterator import ir | ||
from gt4py.next.iterator.ir_utils import ( | ||
common_pattern_matcher as cpm, | ||
domain_utils, | ||
ir_makers as im, | ||
) | ||
|
||
|
||
class ExpandLibraryFunctions(PreserveLocationVisitor, NodeTranslator): | ||
@classmethod | ||
def apply(cls, node: ir.Node): | ||
return cls().visit(node) | ||
|
||
def visit_FunCall(self, node: ir.FunCall) -> ir.FunCall: | ||
if cpm.is_call_to(node, "in"): | ||
ret = [] | ||
pos, domain = node.args | ||
for i, (k, v) in enumerate( | ||
domain_utils.SymbolicDomain.from_expr(node.args[1]).ranges.items() | ||
): | ||
ret.append( | ||
im.and_( | ||
im.less_equal(v.start, im.tuple_get(i, pos)), | ||
im.less(im.tuple_get(i, pos), v.stop), | ||
) | ||
) # TODO: avoid pos duplication | ||
return reduce(im.and_, ret) | ||
return self.generic_visit(node) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.