Skip to content
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

feature[next]: Validate no dynamic offsets #1504

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/gt4py/next/iterator/transforms/global_tmps.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,15 @@ def convert_type(dtype):
)


def validate_no_dynamic_offsets(node: ir.Node):
"""Vaidate we have no dynamic offsets, e.g. `shift(Ioff, deref(...))(...)`"""
for call_node in node.walk_values().if_isinstance(ir.FunCall):
assert isinstance(call_node, ir.FunCall)
if call_node.fun == im.ref("shift"):
if any(not isinstance(arg, ir.OffsetLiteral) for arg in call_node.args):
raise NotImplementedError("Dynamic offsets not supported in temporary pass.")


# TODO(tehrengruber): Add support for dynamic shifts (e.g. the distance is a symbol). This can be
# tricky: For every lift statement that is dynamically shifted we can not compute bounds anymore
# and hence also not extract as a temporary.
Expand All @@ -661,6 +670,8 @@ def visit_FencilDefinition(
] = None,
symbolic_sizes: Optional[dict[str, str]],
) -> FencilWithTemporaries:
# Vaidate we have no dynamic offsets, e.g. `shift(Ioff, deref(...))(...)`
validate_no_dynamic_offsets(node)
# Split closures on lifted function calls and introduce temporaries
res = split_closures(
node, offset_provider=offset_provider, extraction_heuristics=extraction_heuristics
Expand Down
Loading