-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit tests for USMNdArray creation. Remove test_usm_ndarray_type_exce…
…ptions
- Loading branch information
Diptorup Deb
committed
Apr 26, 2023
1 parent
e21f04a
commit 5655ab7
Showing
2 changed files
with
79 additions
and
31 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
numba_dpex/tests/core/types/USMNdAArray/test_usm_ndarray_creation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import dpctl | ||
import pytest | ||
|
||
from numba_dpex.core.types import USMNdArray | ||
|
||
"""Negative tests for expected exceptions raised during USMNdArray creation. | ||
""" | ||
|
||
|
||
def test_default_type_construction(): | ||
"""Tests call USMNdArray constructor with no device or queue args.""" | ||
usma = USMNdArray(1, queue=None) | ||
|
||
assert usma.ndim == 1 | ||
assert usma.layout == "C" | ||
assert usma.addrspace == 1 | ||
assert usma.usm_type == "device" | ||
|
||
default_device = dpctl.SyclDevice() | ||
cached_queue = dpctl.get_device_cached_queue(default_device) | ||
|
||
assert usma.device == default_device.filter_string | ||
assert usma.queue == cached_queue | ||
|
||
|
||
def test_type_creation_with_device(): | ||
"""Tests creating a USMNdArray with a device arg and no queue""" | ||
|
||
default_device_str = dpctl.SyclDevice().filter_string | ||
|
||
usma = USMNdArray(1, device=default_device_str, queue=None) | ||
|
||
assert usma.ndim == 1 | ||
assert usma.layout == "C" | ||
assert usma.addrspace == 1 | ||
assert usma.usm_type == "device" | ||
|
||
assert usma.device == default_device_str | ||
|
||
cached_queue = dpctl.get_device_cached_queue(default_device_str) | ||
|
||
assert usma.queue == cached_queue | ||
|
||
|
||
def test_type_creation_with_queue(): | ||
"""Tests creating a USMNdArray with a queue arg and no device""" | ||
queue = dpctl.SyclQueue() | ||
usma = USMNdArray(1, queue=queue) | ||
|
||
assert usma.ndim == 1 | ||
assert usma.layout == "C" | ||
assert usma.addrspace == 1 | ||
assert usma.usm_type == "device" | ||
|
||
assert usma.device == queue.sycl_device.filter_string | ||
assert usma.queue == queue | ||
|
||
|
||
def test_exception_when_both_device_and_queue_arg_specified(): | ||
"""Tests if TypeError is raised when both queue and device specified""" | ||
|
||
queue = dpctl.SyclQueue() | ||
with pytest.raises(TypeError): | ||
USMNdArray(1, device="cpu", queue=queue) | ||
|
||
|
||
def test_improper_queue_type(): | ||
"""Tests if TypeError is raised if queue argument is of invalid type""" | ||
|
||
with pytest.raises(TypeError): | ||
USMNdArray(1, queue="cpu") | ||
|
||
|
||
def test_improper_device_type(): | ||
"""Tests if TypeError is raised if device argument is of invalid type""" | ||
|
||
with pytest.raises(TypeError): | ||
USMNdArray(1, device=0) |
31 changes: 0 additions & 31 deletions
31
numba_dpex/tests/core/types/USMNdAArray/test_usm_ndarray_type_exceptions.py
This file was deleted.
Oops, something went wrong.