Skip to content

Commit 6aa1985

Browse files
authored
Merge a0219b3 into 765dc04
2 parents 765dc04 + a0219b3 commit 6aa1985

29 files changed

+1211
-60
lines changed

dpnp/dpnp_iface.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"get_normalized_queue_device",
6969
"get_result_array",
7070
"get_usm_ndarray",
71+
"is_cuda_backend",
7172
"get_usm_ndarray_or_scalar",
7273
"is_supported_array_or_scalar",
7374
"is_supported_array_type",
@@ -736,6 +737,40 @@ 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 object has a CUDA backend, otherwise ``False``.
757+
758+
"""
759+
760+
if obj is None:
761+
sycl_device = dpctl.select_default_device()
762+
elif isinstance(obj, dpctl.SyclDevice):
763+
sycl_device = obj
764+
else:
765+
sycl_device = getattr(obj, "sycl_device", None)
766+
if (
767+
sycl_device is not None
768+
and sycl_device.backend == dpctl.backend_type.cuda
769+
):
770+
return True
771+
return False
772+
773+
739774
def is_supported_array_or_scalar(a):
740775
"""
741776
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
@@ -127,6 +127,7 @@ def choose(x1, choices, out=None, mode="raise"):
127127
:obj:`dpnp.take_along_axis` : Preferable if choices is an array.
128128
129129
"""
130+
130131
x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False)
131132

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

138139
if x1_desc:
140+
if dpnp.is_cuda_backend(x1_desc.get_array()):
141+
raise NotImplementedError(
142+
"Running on CUDA is currently not supported"
143+
)
144+
139145
if any(not desc for desc in choices_list):
140146
pass
141147
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)