Skip to content

Commit 0322aea

Browse files
authored
Merge e87174e into c4997cc
2 parents c4997cc + e87174e commit 0322aea

27 files changed

+1223
-42
lines changed

dpnp/dpnp_iface.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"get_result_array",
6969
"get_usm_ndarray",
7070
"get_usm_ndarray_or_scalar",
71+
"is_cuda_backend",
7172
"is_supported_array_or_scalar",
7273
"is_supported_array_type",
7374
"synchronize_array_data",
@@ -681,6 +682,41 @@ def get_usm_ndarray_or_scalar(a):
681682
return a if dpnp.isscalar(a) else get_usm_ndarray(a)
682683

683684

685+
def is_cuda_backend(obj=None):
686+
"""
687+
Checks that object has a CUDA backend.
688+
689+
Parameters
690+
----------
691+
obj : {Device, SyclDevice, SyclQueue, dpnp.ndarray, usm_ndarray, None},
692+
optional
693+
An input object with sycl_device property to check device backend.
694+
If `obj` is ``None``, device backend will be checked for the default
695+
queue.
696+
Default: ``None``.
697+
698+
Returns
699+
-------
700+
out : bool
701+
Return ``True`` if data of the input object resides on a CUDA backend,
702+
otherwise ``False``.
703+
704+
"""
705+
706+
if obj is None:
707+
sycl_device = dpctl.select_default_device()
708+
elif isinstance(obj, dpctl.SyclDevice):
709+
sycl_device = obj
710+
else:
711+
sycl_device = getattr(obj, "sycl_device", None)
712+
if (
713+
sycl_device is not None
714+
and sycl_device.backend == dpctl.backend_type.cuda
715+
):
716+
return True
717+
return False
718+
719+
684720
def is_supported_array_or_scalar(a):
685721
"""
686722
Return ``True`` if `a` is a scalar or an array of either

dpnp/dpnp_iface_indexing.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def choose(x1, choices, out=None, mode="raise"):
128128
:obj:`dpnp.take_along_axis` : Preferable if choices is an array.
129129
130130
"""
131+
131132
x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False)
132133

133134
choices_list = []
@@ -137,6 +138,11 @@ def choose(x1, choices, out=None, mode="raise"):
137138
)
138139

139140
if x1_desc:
141+
if dpnp.is_cuda_backend(x1_desc.get_array()):
142+
raise NotImplementedError(
143+
"Running on CUDA is currently not supported"
144+
)
145+
140146
if any(not desc for desc in choices_list):
141147
pass
142148
elif out is not None:

dpnp/dpnp_iface_libmath.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ def erf(in_array1):
8282
in_array1, copy_when_strides=False, copy_when_nondefault_queue=False
8383
)
8484
if x1_desc:
85+
if dpnp.is_cuda_backend(x1_desc.get_array()):
86+
raise NotImplementedError(
87+
"Running on CUDA is currently not supported"
88+
)
8589
return dpnp_erf(x1_desc).get_pyobj()
8690

8791
result = create_output_descriptor_py(

dpnp/dpnp_iface_mathematical.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2949,8 +2949,16 @@ def modf(x1, **kwargs):
29492949
"""
29502950

29512951
x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False)
2952-
if x1_desc and not kwargs:
2953-
return dpnp_modf(x1_desc)
2952+
if x1_desc:
2953+
if dpnp.is_cuda_backend(x1_desc.get_array()):
2954+
raise NotImplementedError(
2955+
"Running on CUDA is currently not supported"
2956+
)
2957+
2958+
if kwargs:
2959+
pass
2960+
else:
2961+
return dpnp_modf(x1_desc)
29542962

29552963
return call_origin(numpy.modf, x1, **kwargs)
29562964

dpnp/dpnp_iface_sorting.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ def partition(x1, kth, axis=-1, kind="introselect", order=None):
192192

193193
x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False)
194194
if x1_desc:
195+
if dpnp.is_cuda_backend(x1_desc.get_array()):
196+
raise NotImplementedError(
197+
"Running on CUDA is currently not supported"
198+
)
199+
195200
if not isinstance(kth, int):
196201
pass
197202
elif x1_desc.ndim == 0:

0 commit comments

Comments
 (0)