Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Tests for array API inspection utilities reflect fixes for device key…
…word
  • Loading branch information
ndgrigorian committed Jan 24, 2025
commit 9dffdc03317f8296feed3d5d0eddd87e43ba19bc
21 changes: 9 additions & 12 deletions dpctl/tests/test_tensor_array_api_inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"bool": dpt.bool,
"float32": dpt.float32,
"complex64": dpt.complex64,
"complex128": dpt.complex128,
"int8": dpt.int8,
"int16": dpt.int16,
"int32": dpt.int32,
Expand All @@ -41,12 +40,6 @@
}


class MockDevice:
def __init__(self, fp16: bool, fp64: bool):
self.has_aspect_fp16 = fp16
self.has_aspect_fp64 = fp64


def test_array_api_inspection_methods():
info = dpt.__array_namespace_info__()
assert info.capabilities()
Expand Down Expand Up @@ -125,17 +118,21 @@ def test_array_api_inspection_default_device_dtypes():
dtypes = _dtypes_no_fp16_fp64.copy()
if dev.has_aspect_fp64:
dtypes["float64"] = dpt.float64
dtypes["complex128"] = dpt.complex128

assert dtypes == dpt.__array_namespace_info__().dtypes()


@pytest.mark.parametrize("fp16", [True, False])
@pytest.mark.parametrize("fp64", [True, False])
def test_array_api_inspection_device_dtypes(fp16, fp64):
dev = MockDevice(fp16, fp64)
def test_array_api_inspection_device_dtypes():
info = dpt.__array_namespace_info__()
try:
dev = info.default_device()
except dpctl.SyclDeviceCreationError:
pytest.skip("No default device available")
dtypes = _dtypes_no_fp16_fp64.copy()
if fp64:
if dev.has_aspect_fp64:
dtypes["float64"] = dpt.float64
dtypes["complex128"] = dpt.complex128

assert dtypes == dpt.__array_namespace_info__().dtypes(device=dev)

Expand Down