-
Notifications
You must be signed in to change notification settings - Fork 55
feat[cartesian]: All data dimensions field RHS access needs to be fully defined #2555
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
Merged
FlorianDeconinck
merged 9 commits into
GridTools:main
from
FlorianDeconinck:feature/ddims_force_full_indexation
Apr 1, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
34e0f1b
Add a `DataDimensionsChecker` _before_ the `UnrollVectorAssignement`
FlorianDeconinck 44afe7d
Move Unroller first to do only RHS checks
FlorianDeconinck b1a6fd9
Better error
FlorianDeconinck 812a871
Merge remote-tracking branch 'GridTools/main' into feature/ddims_forc…
FlorianDeconinck cfa8b01
Move last step of DefinitionIR building to it's own file
FlorianDeconinck af33c12
Fix typo
FlorianDeconinck ca48ec6
Fix lint, circumventing the `StencilDefinition` overloaded "attribclass"
FlorianDeconinck 18fbb41
Restore default constructor + type ignore out
FlorianDeconinck 9ac267c
Pass `sources` to the `StencilDefinition`
FlorianDeconinck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,70 @@ | ||
| # 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 typing import Any | ||
|
|
||
| from gt4py.cartesian.frontend.defir_to_gtir import DataDimensionsChecker, UnrollVectorAssignments | ||
| from gt4py.cartesian.frontend.nodes import ( | ||
| ArgumentInfo, | ||
| ComputationBlock, | ||
| Domain, | ||
| FieldDecl, | ||
| Location, | ||
| StencilDefinition, | ||
| VarDecl, | ||
| ) | ||
|
|
||
|
|
||
| class DefIRBuilder: | ||
| """Assemble DefinitionIR from DefIR nodes build from the Python AST parsing""" | ||
|
|
||
| def __init__(self, stencil_name: str) -> None: | ||
| self.stencil_name = stencil_name | ||
|
|
||
| def build( | ||
| self, | ||
| domain: Domain, | ||
| api_signature: list[ArgumentInfo], | ||
| fields_decls: dict[str, FieldDecl], | ||
| parameter_decls: dict[str, VarDecl], | ||
| computations: list[ComputationBlock], | ||
| externals: dict[str, Any] | None = None, | ||
| sources: dict[str, str] | None = None, | ||
| docstring: str = "", | ||
| loc: Location | None = None, | ||
| ) -> StencilDefinition: | ||
| """Assemble signature, fields and computations nodes into a StencilDefinition""" | ||
| api_fields = [ | ||
| fields_decls[item.name] for item in api_signature if item.name in fields_decls | ||
| ] | ||
| parameters = [ | ||
| parameter_decls[item.name] for item in api_signature if item.name in parameter_decls | ||
| ] | ||
|
|
||
| stencil_definition = StencilDefinition( | ||
| name=self.stencil_name, # type: ignore[call-arg] | ||
| domain=domain, | ||
| api_signature=api_signature, | ||
| api_fields=api_fields, | ||
| parameters=parameters, | ||
| computations=computations, | ||
| externals=externals, | ||
| sources=sources, | ||
| docstring=docstring, | ||
| loc=loc, | ||
| ) | ||
|
|
||
| stencil_definition = UnrollVectorAssignments.apply( | ||
| stencil_definition, | ||
| fields_decls=fields_decls, | ||
| ) | ||
|
|
||
| # We check fields with data dimensions are all fully indexed | ||
| DataDimensionsChecker.apply(stencil_definition, fields_decls) | ||
|
|
||
| return stencil_definition | ||
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.