Skip to content

Commit

Permalink
Warn if GT4Py can't find DaCe
Browse files Browse the repository at this point in the history
DaCe adds optional backends to GT4Py. Currently, we silently drop
support for DaCe backends. This PR adds a warning message allowing
developers to easily figure out DaCe backends aren't available.
  • Loading branch information
Roman Cattaneo committed Oct 17, 2024
1 parent ed9d82d commit db2759b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/gt4py/cartesian/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# Please, refer to the LICENSE file in the root directory.
# SPDX-License-Identifier: BSD-3-Clause

from warnings import warn

from .base import (
REGISTRY,
Backend,
Expand All @@ -16,13 +18,6 @@
from_name,
register,
)


try:
from .dace_backend import DaceCPUBackend, DaceGPUBackend
except ImportError:
pass

from .cuda_backend import CudaBackend
from .gtcpp_backend import GTCpuIfirstBackend, GTCpuKfirstBackend, GTGpuBackend
from .module_generator import BaseModuleGenerator
Expand All @@ -47,5 +42,12 @@
]


if "DaceCPUBackend" in globals():
try:
from .dace_backend import DaceCPUBackend, DaceGPUBackend

__all__ += ["DaceCPUBackend", "DaceGPUBackend"]
except ImportError:
warn(
"GT4Py was unable to load DaCe. DaCe backends (`dace:cpu` and `dace:gpu`) will not be available.",
stacklevel=2,
)

0 comments on commit db2759b

Please sign in to comment.