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

bug[next]: Fix codegen in gtfn for unused vertical offset provider #1746

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ def _collect_offset_definitions(
"Mapping an offset to a horizontal dimension in unstructured is not allowed."
)
# create alias from vertical offset to vertical dimension
offset_definitions[dim.value] = TagDefinition(
name=Sym(id=dim.value), alias=_vertical_dimension
)
offset_definitions[offset_name] = TagDefinition(
name=Sym(id=offset_name), alias=SymRef(id=dim.value)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def simple_mesh() -> MeshDescriptor:
C2E.value: gtx.NeighborTableOffsetProvider(
c2e_arr, Cell, Edge, 4, has_skip_values=False
),
Koff.value: KDim,
Copy link
Contributor

@havogt havogt Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change here? I don't understand how this is related. Is it required to make the test below fail before the fix?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an easy way to trigger the error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But not the best I guess. An isolated test would be one that has an Cartesian offset for a dimension that is not in any field?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any updates on this? I would need it for C2SM/icon4py#564

},
)

Expand Down Expand Up @@ -305,6 +306,7 @@ def skip_value_mesh() -> MeshDescriptor:
C2E.value: gtx.NeighborTableOffsetProvider(
c2e_arr, Cell, Edge, 3, has_skip_values=False
),
Koff.value: KDim,
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def testee(a: cases.IJKField) -> cases.IJKField:


@pytest.mark.uses_unstructured_shift
def test_unstructured_shift(unstructured_case):
def test_unstructured_shift_indexed(unstructured_case):
@gtx.field_operator
def testee(a: cases.VField) -> cases.EField:
return a(E2V[0])
Expand All @@ -93,6 +93,19 @@ def testee(a: cases.VField) -> cases.EField:
)


@pytest.mark.uses_unstructured_shift
def test_unstructured_shift(unstructured_case):
@gtx.field_operator
def testee(a: cases.VField) -> cases.EField:
return neighbor_sum(a(E2V), axis=E2VDim)

cases.verify_with_default_data(
unstructured_case,
testee,
ref=lambda a: np.sum(a[unstructured_case.offset_provider["E2V"].table], axis=1),
)


@pytest.mark.uses_unstructured_shift
def test_composed_unstructured_shift(unstructured_case):
@gtx.field_operator
Expand Down
Loading