refactor[next-dace]: change dispatching of visitors for builtin functions#2690
refactor[next-dace]: change dispatching of visitors for builtin functions#2690edopao wants to merge 5 commits into
Conversation
6f99a07 to
057605c
Compare
057605c to
90d9ce6
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the DaCe lowering pipeline for gt4py.next by renaming key lowering entry points and restructuring how builtin-function visitors are dispatched in both the fieldview and iterator lowering paths.
Changes:
- Renames/reshapes lowering entry points (e.g.,
build_sdfg_from_gtir→lower_program_to_sdfg) and adjusts imports/types accordingly. - Refactors builtin dispatch in
GTIRToSDFG(fieldview) andLambdaToDataflow(iterator) via centralized handler maps. - Updates scan/primitives/type helpers to use the split fieldview/iterator lowering modules.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_types.py | Updates local-view helpers to return iterator-based IteratorExpr/MemletExpr types. |
| src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_scan.py | Switches scan lowering to the new fieldview/iterator module split and updated dataflow types. |
| src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_primitives.py | Retypes primitives to the split builders and iterator dataflow edges; small typing-related adjustments. |
| src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_iterator.py | Refactors builtin dispatch in lambda-to-dataflow and retargets builder typing to fieldview interfaces. |
| src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_fieldview.py | Refactors builtin dispatch in program lowering; introduces _visit_* helpers; renames program lowering entry point. |
| src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_concat_where.py | Updates concat_where lowering to use the fieldview lowering module split. |
| src/gt4py/next/program_processors/runners/dace/lowering/init.py | Updates lowering package exports to point at the refactored lowering entry points. |
Comments suppressed due to low confidence (3)
src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_iterator.py:58
gtir_to_sdfg_iterator.pyimportsgtir_to_sdfg_fieldviewusing thesrc.gt4py...package path, which will fail at runtime outside the repository checkout layout. Also, since this module usesfrom __future__ import annotations, this import is only needed for type checking and can be placed underTYPE_CHECKINGto avoid creating an import cycle (fieldview -> primitives -> iterator -> fieldview).
src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_iterator.py:18- The new
TYPE_CHECKING-guarded import forgtir_to_sdfg_fieldview(recommended below) requiresTYPE_CHECKINGto be imported fromtypingin this module.
src/gt4py/next/program_processors/runners/dace/lowering/init.py:23 lowering/__init__.pyre-exportsbuild_sdfg_from_gtirfromgtir_to_sdfg_fieldview, but that function was renamed tolower_program_to_sdfg(andbuild_sdfg_from_gtirno longer exists). This currently breaks imports likegtx_dace_lowering.build_sdfg_from_gtir(...)used elsewhere in the codebase.
from gt4py.next.program_processors.runners.dace.lowering.gtir_to_sdfg_fieldview import (
build_sdfg_from_gtir,
)
from gt4py.next.program_processors.runners.dace.lowering.gtir_to_sdfg_utils import (
flatten_tuple_fields,
get_map_variable,
)
__all__ = [
"build_sdfg_from_gtir",
"flatten_tuple_fields",
"get_map_variable",
]
90d9ce6 to
4d8ca3b
Compare
4d8ca3b to
e92eade
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_fieldview.py:1231
- This comment line has a stray "to." at the end (likely meant to be "symbols."), which makes the sentence ungrammatical.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_iterator.py:52
gtir_to_sdfg_fieldviewis imported here only to satisfy type annotations, but this creates an avoidable import edge (and contributes to circular imports: fieldview -> primitives -> iterator -> fieldview). Since this module usesfrom __future__ import annotations, you can move the import behindtyping.TYPE_CHECKING(or otherwise defer it) to keep runtime imports acyclic.
The refactoring includes the following changes:
gtir_to_sdfgtogtir_to_sdfg_fieldviewgtir_dataflowtogtir_to_sdfg_iteratorbuild_sdfg_from_gtirtolower_program_to_sdfggtir_to_sdfg_fieldviewandgtir_to_sdfg_iterator