Skip to content

Commit

Permalink
fix[next]: Fix Program.itir (GridTools#1523)
Browse files Browse the repository at this point in the history
## Description

Fix diverging behavior of `Program.itir` for embedded vs backend. Temporary regression test included until `next.decorator` can be type checked, which should render it obsolete.

Co-authored-by: Till Ehrengruber <[email protected]>
  • Loading branch information
DropD and tehrengruber authored Apr 8, 2024
1 parent f857184 commit 609a5c9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/gt4py/next/ffront/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def itir(self) -> itir.FencilDefinition:
kwargs={},
)
if self.backend is not None and self.backend.transformer is not None:
return self.backend.transformer.past_to_itir(no_args_past)
return self.backend.transformer.past_to_itir(no_args_past).program
return past_to_itir.PastToItirFactory()(no_args_past).program

def __call__(self, *args, offset_provider: dict[str, Dimension], **kwargs: Any) -> None:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# GT4Py - GridTools Framework
#
# Copyright (c) 2014-2023, ETH Zurich
# All rights reserved.
#
# This file is part of the GT4Py project and the GridTools framework.
# GT4Py is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or any later
# version. See the LICENSE.txt file at the top-level directory of this
# distribution for a copy of the license or check <https://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: GPL-3.0-or-later
# TODO(dropd): Remove as soon as `gt4py.next.ffront.decorator` is type checked.
from gt4py import next as gtx
from gt4py.next.iterator import ir as itir

from next_tests.integration_tests import cases
from next_tests.integration_tests.cases import cartesian_case
from next_tests.integration_tests.feature_tests.ffront_tests.ffront_test_utils import (
exec_alloc_descriptor,
)


def test_program_itir_regression(cartesian_case):
@gtx.field_operator(backend=None)
def testee_op(a: cases.IField) -> cases.IField:
return a

@gtx.program(backend=None)
def testee(a: cases.IField, out: cases.IField):
testee_op(a, out=out)

assert isinstance(testee.itir, itir.FencilDefinition)
assert isinstance(testee.with_backend(cartesian_case.executor).itir, itir.FencilDefinition)

0 comments on commit 609a5c9

Please sign in to comment.