Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions ndsl/dsl/dace/orchestration.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from dace.transformation.passes.simplify import SimplifyPass
from gt4py import storage

import ndsl.dsl.dace.replacements # noqa # We load in the DaCe replacements
from ndsl.comm.mpi import MPI
from ndsl.dsl.dace.build import get_sdfg_path, write_build_info
from ndsl.dsl.dace.dace_config import (
Expand Down
32 changes: 32 additions & 0 deletions ndsl/dsl/dace/replacements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""This module uses DaCe's op_repository feature to override symbols/AST object
during parsing and replace them with an SDFG compatible representation. This
allow custom NDSL system to be natively orchestratable."""
Comment thread
FlorianDeconinck marked this conversation as resolved.
Outdated

from dace import SDFG, SDFGState, dtypes
from dace.frontend.common import op_repository as oprepo
from dace.frontend.python.newast import ProgramVisitor
from dace.frontend.python.replacements import UfuncInput, _datatype_converter

from ndsl.dsl.typing import Float, Int


@oprepo.replaces("Float")
def _convert_Float(_pv: ProgramVisitor, sdfg: SDFG, state: SDFGState, arg: UfuncInput):
"""Replace `Float(x)` with a typecast of `x` to the proper floating precision type"""
return _datatype_converter(
sdfg,
state,
arg,
dtype=dtypes.dtype_to_typeclass(Float),
)


@oprepo.replaces("Int")
def _convert_Int(_pv: ProgramVisitor, sdfg: SDFG, state: SDFGState, arg: UfuncInput):
"""Replace `Int(x)` with a typecast of `x` to the proper integer precision type"""
return _datatype_converter(
sdfg,
state,
arg,
dtype=dtypes.dtype_to_typeclass(Int),
)
Loading