Skip to content

Commit e527817

Browse files
authored
Merge 4d2606a into 3f737be
2 parents 3f737be + 4d2606a commit e527817

29 files changed

+1212
-60
lines changed

dpnp/dpnp_iface.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"get_result_array",
7070
"get_usm_ndarray",
7171
"get_usm_ndarray_or_scalar",
72+
"is_cuda_backend",
7273
"is_supported_array_or_scalar",
7374
"is_supported_array_type",
7475
"synchronize_array_data",
@@ -736,6 +737,41 @@ def get_usm_ndarray_or_scalar(a):
736737
return a if dpnp.isscalar(a) else get_usm_ndarray(a)
737738

738739

740+
def is_cuda_backend(obj=None):
741+
"""
742+
Checks that object has a CUDA backend.
743+
744+
Parameters
745+
----------
746+
obj : {Device, SyclDevice, SyclQueue, dpnp.ndarray, usm_ndarray, None},
747+
optional
748+
An input object with sycl_device property to check device backend.
749+
If `obj` is ``None``, device backend will be checked for the default
750+
queue.
751+
Default: ``None``.
752+
753+
Returns
754+
-------
755+
out : bool
756+
Return ``True`` if data of the input object resides on a CUDA backend,
757+
otherwise ``False``.
758+
759+
"""
760+
761+
if obj is None:
762+
sycl_device = dpctl.select_default_device()
763+
elif isinstance(obj, dpctl.SyclDevice):
764+
sycl_device = obj
765+
else:
766+
sycl_device = getattr(obj, "sycl_device", None)
767+
if (
768+
sycl_device is not None
769+
and sycl_device.backend == dpctl.backend_type.cuda
770+
):
771+
return True
772+
return False
773+
774+
739775
def is_supported_array_or_scalar(a):
740776
"""
741777
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: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2949,8 +2949,14 @@ 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 not kwargs:
2959+
return dpnp_modf(x1_desc)
29542960

29552961
return call_origin(numpy.modf, x1, **kwargs)
29562962

dpnp/dpnp_iface_sorting.py

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

188188
x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False)
189189
if x1_desc:
190+
if dpnp.is_cuda_backend(x1_desc.get_array()):
191+
raise NotImplementedError(
192+
"Running on CUDA is currently not supported"
193+
)
194+
190195
if not isinstance(kth, int):
191196
pass
192197
elif x1_desc.ndim == 0:

dpnp/dpnp_iface_statistics.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,13 @@ def correlate(x1, x2, mode="valid"):
484484
x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False)
485485
x2_desc = dpnp.get_dpnp_descriptor(x2, copy_when_nondefault_queue=False)
486486
if x1_desc and x2_desc:
487+
if dpnp.is_cuda_backend(x1_desc.get_array()) or dpnp.is_cuda_backend(
488+
x2_desc.get_array()
489+
):
490+
raise NotImplementedError(
491+
"Running on CUDA is currently not supported"
492+
)
493+
487494
if x1_desc.size != x2_desc.size or x1_desc.size == 0:
488495
pass
489496
elif x1_desc.shape != x2_desc.shape:

0 commit comments

Comments
 (0)