Skip to content

Commit c8b3f0f

Browse files
committed
skip complex32 tests on ml_dtypes < 0.6
conda-forge has no ml_dtypes 0.6 for Python 3.10, and 0.5.x lacks complex32 and bcomplex32.
1 parent 0c609d6 commit c8b3f0f

4 files changed

Lines changed: 19 additions & 11 deletions

File tree

‎dpctl/tests/test_kernel_arg_dtypes.py‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def test_numpy_scalar_arg(ctype, dtype):
128128

129129
def _complex_half_scalar(kind, value):
130130
if kind == "complex32":
131-
ml_dtypes = pytest.importorskip("ml_dtypes")
131+
ml_dtypes = pytest.importorskip("ml_dtypes", minversion="0.6")
132132
return ml_dtypes.complex32(value)
133133
return np.array((value.real, value.imag), dtype=complex_half)[()]
134134

@@ -182,7 +182,7 @@ def test_complex_scalar_arg(ctype, kind):
182182

183183

184184
def test_bcomplex32_scalar_arg():
185-
ml_dtypes = pytest.importorskip("ml_dtypes")
185+
ml_dtypes = pytest.importorskip("ml_dtypes", minversion="0.6")
186186
q = _opencl_queue_or_skip()
187187
src = (
188188
"kernel void widen(global float *out, ushort2 d) {"
@@ -398,7 +398,11 @@ def test_local_accessor_dtypes(dtype):
398398

399399
def test_local_accessor_bfloat16():
400400
ml_dtypes = pytest.importorskip("ml_dtypes")
401-
for dtype in (ml_dtypes.bfloat16, "bfloat16", ml_dtypes.complex32):
401+
dtypes = [ml_dtypes.bfloat16, "bfloat16"]
402+
# complex32 needs ml_dtypes 0.6
403+
if hasattr(ml_dtypes, "complex32"):
404+
dtypes.append(ml_dtypes.complex32)
405+
for dtype in dtypes:
402406
la = dpctl.LocalAccessor(dtype, (8,))
403407
assert isinstance(la, dpctl.LocalAccessor)
404408

‎dpctl/tests/test_sycl_compiler.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ def test_spec_const_complex_half():
430430

431431

432432
def test_spec_const_complex32():
433-
ml_dtypes = pytest.importorskip("ml_dtypes")
433+
ml_dtypes = pytest.importorskip("ml_dtypes", minversion="0.6")
434434
sp = dpc.SpecializationConstant(0, ml_dtypes.complex32(1 - 2j))
435435
assert sp.size == 4
436436
assert sp == dpc.SpecializationConstant(0, "complex32", 1 - 2j)

‎dpctl/tests/test_sycl_queue_copy.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,11 @@ def test_copy_with_ml_dtypes():
348348
pytest.skip("Default constructor for SyclQueue failed")
349349

350350
src = np.arange(8, dtype=np.uint16)
351-
for dtype in (ml_dtypes.bfloat16, "bfloat16", ml_dtypes.complex32):
351+
dtypes = [ml_dtypes.bfloat16, "bfloat16"]
352+
# complex32 needs ml_dtypes 0.6
353+
if hasattr(ml_dtypes, "complex32"):
354+
dtypes.append(ml_dtypes.complex32)
355+
for dtype in dtypes:
352356
dst = np.zeros_like(src)
353357
n = src.nbytes // np.dtype(dtype).itemsize
354358
q.copy(dst, src, n, dtype=dtype)

‎dpctl/tests/test_sycl_queue_fill.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -382,12 +382,12 @@ def test_fill_with_ml_dtypes():
382382
pytest.skip("Default constructor for SyclQueue failed")
383383

384384
num_elements = 8
385-
for dtype, value in (
386-
(ml_dtypes.bfloat16, 1.5),
387-
("bfloat16", 1.5),
388-
(ml_dtypes.complex32, 1 - 2j),
389-
(ml_dtypes.bcomplex32, 1 - 2j),
390-
):
385+
cases = [(ml_dtypes.bfloat16, 1.5), ("bfloat16", 1.5)]
386+
# complex32 and bcomplex32 need ml_dtypes 0.6
387+
for name in ("complex32", "bcomplex32"):
388+
if hasattr(ml_dtypes, name):
389+
cases.append((getattr(ml_dtypes, name), 1 - 2j))
390+
for dtype, value in cases:
391391
np_dt = np.dtype(dtype)
392392
nbytes = num_elements * np_dt.itemsize
393393
mem = dpctl.memory.MemoryUSMShared(nbytes, queue=q)

0 commit comments

Comments
 (0)