Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test[cartesian]: conditional xfail instead of two tests #1885

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 3 additions & 9 deletions tests/cartesian_tests/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
cp = None

import datetime

import numpy as np
import pytest

from gt4py import cartesian as gt4pyc
from gt4py.cartesian import utils as gt_utils


def _backend_name_as_param(name):
def _backend_name_as_param(name: str):
marks = []
if gt4pyc.backend.from_name(name).storage_info["device"] == "gpu":
marks.append(pytest.mark.requires_gpu)
Expand All @@ -48,14 +47,9 @@ def _get_backends_with_storage_info(storage_info_kind: str):
GPU_BACKENDS = _get_backends_with_storage_info("gpu")
ALL_BACKENDS = CPU_BACKENDS + GPU_BACKENDS

_PERFORMANCE_BACKEND_NAMES = [name for name in _ALL_BACKEND_NAMES if name not in ("numpy", "cuda")]
PERFORMANCE_BACKENDS = [_backend_name_as_param(name) for name in _PERFORMANCE_BACKEND_NAMES]

DACE_BACKENDS = [
_backend_name_as_param(name)
for name in filter(lambda name: name.startswith("dace:"), _ALL_BACKEND_NAMES)
PERFORMANCE_BACKENDS = [
_backend_name_as_param(name) for name in _ALL_BACKEND_NAMES if name not in ("numpy", "cuda")
]
NON_DACE_BACKENDS = [backend for backend in ALL_BACKENDS if backend not in DACE_BACKENDS]


@pytest.fixture()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
from cartesian_tests.definitions import (
ALL_BACKENDS,
CPU_BACKENDS,
DACE_BACKENDS,
NON_DACE_BACKENDS,
get_array_library,
)
from cartesian_tests.integration_tests.multi_feature_tests.stencil_definitions import (
Expand Down Expand Up @@ -770,20 +768,21 @@ def test(
assert (out_arr[:, :, :] == 388.0).all()


@pytest.mark.parametrize("backend", NON_DACE_BACKENDS)
def test_cast_in_index(backend):
@gtscript.stencil(backend)
def cast_in_index(
in_field: Field[np.float64], i32: np.int32, i64: np.int64, out_field: Field[np.float64]
):
"""Simple copy stencil with forced cast in index calculation."""
with computation(PARALLEL), interval(...):
out_field = in_field[0, 0, i32 - i64]
def _xfail_dace_backends(param):
if param.values[0].startswith("dace:"):
marks = param.marks + [
pytest.mark.xfail(
raises=ValueError,
reason="Missing support in DaCe backends, see https://github.com/GridTools/gt4py/issues/1881.",
)
]
# make a copy because otherwise we are operating in-place
return pytest.param(*param.values, marks=marks)
return param


@pytest.mark.parametrize("backend", DACE_BACKENDS)
@pytest.mark.xfail(raises=ValueError)
def test_dace_no_cast_in_index(backend):
@pytest.mark.parametrize("backend", map(_xfail_dace_backends, ALL_BACKENDS))
def test_cast_in_index(backend):
@gtscript.stencil(backend)
def cast_in_index(
in_field: Field[np.float64], i32: np.int32, i64: np.int64, out_field: Field[np.float64]
Expand Down