Skip to content

Commit

Permalink
refactor[next]: remove FencilDefinition definition (#1774)
Browse files Browse the repository at this point in the history
After this commit `FencilDefinition`s are completely removed. Next step
could be to cleanup `itir` -> `gtir` everywhere.
  • Loading branch information
havogt authored Dec 6, 2024
1 parent 2c48858 commit 54f176f
Show file tree
Hide file tree
Showing 38 changed files with 91 additions and 1,926 deletions.
2 changes: 1 addition & 1 deletion docs/user/next/advanced/HackTheToolchain.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ from gt4py import eve

```python
cached_lowering_toolchain = gtx.backend.DEFAULT_TRANSFORMS.replace(
past_to_itir=gtx.ffront.past_to_itir.past_to_itir_factory(cached=False)
past_to_itir=gtx.ffront.past_to_itir.past_to_gtir_factory(cached=False)
)
```

Expand Down
18 changes: 3 additions & 15 deletions src/gt4py/next/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from gt4py.next import allocators as next_allocators
from gt4py.next.ffront import (
foast_to_gtir,
foast_to_itir,
foast_to_past,
func_to_foast,
func_to_past,
Expand All @@ -41,7 +40,7 @@

ARGS: typing.TypeAlias = arguments.JITArgs
CARG: typing.TypeAlias = arguments.CompileTimeArgs
IT_PRG: typing.TypeAlias = itir.FencilDefinition | itir.Program
IT_PRG: typing.TypeAlias = itir.Program


INPUT_DATA: typing.TypeAlias = DSL_FOP | FOP | DSL_PRG | PRG | IT_PRG
Expand Down Expand Up @@ -93,7 +92,7 @@ class Transforms(workflow.MultiWorkflow[INPUT_PAIR, stages.CompilableProgram]):
)

past_to_itir: workflow.Workflow[AOT_PRG, stages.CompilableProgram] = dataclasses.field(
default_factory=past_to_itir.past_to_itir_factory
default_factory=past_to_itir.past_to_gtir_factory
)

def step_order(self, inp: INPUT_PAIR) -> list[str]:
Expand Down Expand Up @@ -126,7 +125,7 @@ def step_order(self, inp: INPUT_PAIR) -> list[str]:
)
case PRG():
steps.extend(["past_lint", "field_view_prog_args_transform", "past_to_itir"])
case itir.FencilDefinition() | itir.Program():
case itir.Program():
pass
case _:
raise ValueError("Unexpected input.")
Expand All @@ -135,17 +134,6 @@ def step_order(self, inp: INPUT_PAIR) -> list[str]:

DEFAULT_TRANSFORMS: Transforms = Transforms()

# FIXME[#1582](havogt): remove after refactoring to GTIR
# note: this step is deliberately placed here, such that the cache is shared
_foast_to_itir_step = foast_to_itir.adapted_foast_to_itir_factory(cached=True)
LEGACY_TRANSFORMS: Transforms = Transforms(
past_to_itir=past_to_itir.past_to_itir_factory(to_gtir=False),
foast_to_itir=_foast_to_itir_step,
field_view_op_to_prog=foast_to_past.operator_to_program_factory(
foast_to_itir_step=_foast_to_itir_step
),
)


# TODO(tehrengruber): Rename class and `executor` & `transforms` attribute. Maybe:
# `Backend` -> `Toolchain`
Expand Down
5 changes: 2 additions & 3 deletions src/gt4py/next/ffront/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from gt4py.next.ffront import (
field_operator_ast as foast,
foast_to_gtir,
foast_to_itir,
past_process_args,
signature,
stages as ffront_stages,
Expand Down Expand Up @@ -186,7 +185,7 @@ def _all_closure_vars(self) -> dict[str, Any]:
return transform_utils._get_closure_vars_recursively(self.past_stage.closure_vars)

@functools.cached_property
def itir(self) -> itir.FencilDefinition:
def gtir(self) -> itir.Program:
no_args_past = toolchain.CompilableProgram(
data=ffront_stages.PastProgramDefinition(
past_node=self.past_stage.past_node,
Expand Down Expand Up @@ -561,7 +560,7 @@ def with_grid_type(self, grid_type: common.GridType) -> FieldOperator:
# a different backend than the one of the program that calls this field operator. Just use
# the hard-coded lowering until this is cleaned up.
def __gt_itir__(self) -> itir.FunctionDefinition:
return foast_to_itir.foast_to_itir(self.foast_stage)
return foast_to_gtir.foast_to_gtir(self.foast_stage)

# FIXME[#1582](tehrengruber): remove after refactoring to GTIR
def __gt_gtir__(self) -> itir.FunctionDefinition:
Expand Down
Loading

0 comments on commit 54f176f

Please sign in to comment.