Skip to content

Commit c81f816

Browse files
AlexanderKalistratovkhaled
authored andcommitted
Applying review comments
1 parent 294b15b commit c81f816

File tree

3 files changed

+11
-32
lines changed

3 files changed

+11
-32
lines changed

numba_dpex/core/typeconv/array_conversion.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def to_usm_ndarray(suai_attrs, addrspace=address_space.GLOBAL):
3737
ndim=suai_attrs.dimensions,
3838
layout=layout,
3939
usm_type=suai_attrs.usm_type,
40-
device=suai_attrs.device,
4140
queue=suai_attrs.queue,
4241
readonly=not suai_attrs.is_writable,
4342
name=None,

numba_dpex/core/types/usm_ndarray_type.py

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ def __init__(
3131
aligned=True,
3232
addrspace=address_space.GLOBAL,
3333
):
34-
# Creating SyclDevice from filter_string is expensive. So, USMNdArray should be able to
35-
# accept and SyclDevice from usm_ndarray as device parameter
36-
if not isinstance(device, (str, dpctl.SyclDevice)):
34+
if not isinstance(device, str):
3735
raise TypeError(
3836
"The device keyword arg should be a str object specifying "
3937
"a SYCL filter selector"
@@ -47,35 +45,21 @@ def __init__(
4745
self.usm_type = usm_type
4846
self.addrspace = addrspace
4947

50-
def to_device(dev):
51-
if isinstance(dev, dpctl.SyclDevice):
52-
return dev
48+
if device == "unknown":
49+
device = None
5350

54-
return dpctl.SyclDevice(dev)
55-
56-
def device_as_string(dev):
57-
if isinstance(dev, dpctl.SyclDevice):
58-
return dev.filter_string
59-
60-
return dev
51+
if queue is not None and device is not None:
52+
raise TypeError(
53+
"'queue' and 'device' keywords can not be both specified"
54+
)
6155

6256
if queue is not None:
63-
if device != "unknown":
64-
if queue.sycl_device != to_device(device):
65-
raise TypeError(
66-
"The queue keyword arg and the device keyword arg specify "
67-
"different SYCL devices"
68-
)
69-
7057
self.queue = queue
7158
else:
72-
if device == "unknown":
73-
device = None
59+
if device is None:
60+
device = dpctl.SyclDevice()
7461

75-
device_str = device_as_string(device)
76-
self.queue = dpctl.tensor._device.normalize_queue_device(
77-
device=device_str
78-
)
62+
self.queue = dpctl.get_device_cached_queue(device)
7963

8064
self.device = self.queue.sycl_device.filter_string
8165

numba_dpex/core/typing/typeof.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,14 @@ def _typeof_helper(val, array_class_type):
4242
"The usm_type for the usm_ndarray could not be inferred"
4343
)
4444

45-
try:
46-
device = val.sycl_device
47-
except AttributeError:
48-
raise ValueError("The device for the usm_ndarray could not be inferred")
45+
assert val.sycl_queue is not None
4946

5047
return array_class_type(
5148
dtype=dtype,
5249
ndim=val.ndim,
5350
layout=layout,
5451
readonly=readonly,
5552
usm_type=usm_type,
56-
device=device,
5753
queue=val.sycl_queue,
5854
addrspace=address_space.GLOBAL,
5955
)

0 commit comments

Comments
 (0)