-
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]: Index builtin #1699
Changes from 9 commits
e1e30b2
181b912
60d2100
19998af
a8c99b8
8031bf9
655e260
b53897a
1540e8d
a61ef9a
f558e35
0c50850
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,9 +31,9 @@ | |
INT_LITERAL: SIGNED_INT | ||
FLOAT_LITERAL: SIGNED_FLOAT | ||
OFFSET_LITERAL: ( INT_LITERAL | CNAME ) "ₒ" | ||
_literal: INT_LITERAL | FLOAT_LITERAL | OFFSET_LITERAL | ||
AXIS_LITERAL: CNAME ("ᵥ" | "ₕ") | ||
_literal: INT_LITERAL | FLOAT_LITERAL | OFFSET_LITERAL | AXIS_LITERAL | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Otherwise There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
ID_NAME: CNAME | ||
AXIS_NAME: CNAME ("ᵥ" | "ₕ") | ||
|
||
?prec0: prec1 | ||
| "λ(" ( SYM "," )* SYM? ")" "→" prec0 -> lam | ||
|
@@ -84,7 +84,7 @@ | |
else_branch_seperator: "else" | ||
if_stmt: "if" "(" prec0 ")" "{" ( stmt )* "}" else_branch_seperator "{" ( stmt )* "}" | ||
|
||
named_range: AXIS_NAME ":" "[" prec0 "," prec0 ")" | ||
named_range: AXIS_LITERAL ":" "[" prec0 "," prec0 ")" | ||
function_definition: ID_NAME "=" "λ(" ( SYM "," )* SYM? ")" "→" prec0 ";" | ||
declaration: ID_NAME "=" "temporary(" "domain=" prec0 "," "dtype=" TYPE_LITERAL ")" ";" | ||
stencil_closure: prec0 "←" "(" prec0 ")" "(" ( SYM_REF ", " )* SYM_REF ")" "@" prec0 ";" | ||
|
@@ -128,7 +128,7 @@ def OFFSET_LITERAL(self, value: lark_lexer.Token) -> ir.OffsetLiteral: | |
def ID_NAME(self, value: lark_lexer.Token) -> str: | ||
return value.value | ||
|
||
def AXIS_NAME(self, value: lark_lexer.Token) -> ir.AxisLiteral: | ||
def AXIS_LITERAL(self, value: lark_lexer.Token) -> ir.AxisLiteral: | ||
name = value.value[:-1] | ||
kind = ir.DimensionKind.HORIZONTAL if value.value[-1] == "ₕ" else ir.DimensionKind.VERTICAL | ||
return ir.AxisLiteral(value=name, kind=kind) | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -260,6 +260,17 @@ def visit_Program(self, node: gtfn_ir.Program, **kwargs: Any) -> Union[str, Coll | |||||||||||||||||||||||
#include <gridtools/fn/${grid_type_str}.hpp> | ||||||||||||||||||||||||
#include <gridtools/fn/sid_neighbor_table.hpp> | ||||||||||||||||||||||||
#include <gridtools/stencil/global_parameter.hpp> | ||||||||||||||||||||||||
#include <gridtools/stencil/positional.hpp> | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
// TODO(havogt): move to gtfn? | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd propose to wait until GridTools/gridtools#1806 is merged next week. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once #1720 is in, we can remove this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I removed that code. |
||||||||||||||||||||||||
namespace gridtools{ | ||||||||||||||||||||||||
namespace fn{ | ||||||||||||||||||||||||
template <class T> | ||||||||||||||||||||||||
auto index(T){ | ||||||||||||||||||||||||
return stencil::positional<std::decay_t<T>>();} | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
namespace generated{ | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -611,7 +611,6 @@ def convert_el_to_sid(el_expr: Expr, el_type: ts.ScalarType | ts.FieldType) -> E | |
tuple_constructor=lambda *elements: SidComposite(values=list(elements)), | ||
) | ||
|
||
assert isinstance(lowered_input_as_sid, (SidComposite, SidFromScalar, SymRef)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check was superfluous from the beginning since the format is checked anyway when the |
||
lowered_inputs.append(lowered_input_as_sid) | ||
|
||
backend = Backend(domain=self.visit(domain, stencil=stencil, **kwargs)) | ||
|
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.
Renamed for consistency.