Skip to content

Commit c8c6bd4

Browse files
authored
Merge 0c64722 into 434590c
2 parents 434590c + 0c64722 commit c8c6bd4

26 files changed

+758
-46
lines changed

dpnp/dpnp_iface.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"get_normalized_queue_device",
7070
"get_result_array",
7171
"get_usm_ndarray",
72+
"is_cuda_backend",
7273
"get_usm_ndarray_or_scalar",
7374
"is_supported_array_or_scalar",
7475
"is_supported_array_type",
@@ -757,6 +758,40 @@ def get_usm_ndarray_or_scalar(a):
757758
return a if dpnp.isscalar(a) else get_usm_ndarray(a)
758759

759760

761+
def is_cuda_backend(obj=None):
762+
"""
763+
Checks that object has a CUDA backend.
764+
765+
Parameters
766+
----------
767+
obj : {Device, SyclDevice, SyclQueue, dpnp.ndarray, usm_ndarray, None},
768+
optional
769+
An input object with sycl_device property to check device backend.
770+
If `obj` is ``None``, device backend will be checked for the default
771+
queue.
772+
Default: ``None``.
773+
774+
Returns
775+
-------
776+
out : bool
777+
Return ``True`` if object has a cuda backend, otherwise``False``.
778+
779+
"""
780+
781+
if obj is None:
782+
sycl_device = dpctl.SyclQueue().sycl_device
783+
elif isinstance(obj, dpctl.SyclDevice):
784+
sycl_device = obj
785+
else:
786+
sycl_device = getattr(obj, "sycl_device", None)
787+
if (
788+
sycl_device is not None
789+
and sycl_device.backend == dpctl.backend_type.cuda
790+
):
791+
return True
792+
return False
793+
794+
760795
def is_supported_array_or_scalar(a):
761796
"""
762797
Return ``True`` if `a` is a scalar or an array of either

dpnp/dpnp_iface_indexing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ def choose(x1, choices, out=None, mode="raise"):
173173
:obj:`dpnp.take_along_axis` : Preferable if choices is an array.
174174
175175
"""
176+
176177
x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False)
177178

178179
choices_list = []
@@ -192,6 +193,8 @@ def choose(x1, choices, out=None, mode="raise"):
192193
pass
193194
elif not choices_list:
194195
pass
196+
elif dpnp.is_cuda_backend(x1):
197+
pass
195198
else:
196199
size = x1_desc.size
197200
choices_size = choices_list[0].size

dpnp/dpnp_iface_libmath.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def erf(in_array1):
8181
x1_desc = dpnp.get_dpnp_descriptor(
8282
in_array1, copy_when_strides=False, copy_when_nondefault_queue=False
8383
)
84-
if x1_desc:
84+
if x1_desc and not dpnp.is_cuda_backend(in_array1):
8585
return dpnp_erf(x1_desc).get_pyobj()
8686

8787
result = create_output_descriptor_py(

dpnp/dpnp_iface_mathematical.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,8 +2479,13 @@ def modf(x1, **kwargs):
24792479
"""
24802480

24812481
x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False)
2482-
if x1_desc and not kwargs:
2483-
return dpnp_modf(x1_desc)
2482+
if x1_desc:
2483+
if not kwargs:
2484+
pass
2485+
elif dpnp.is_cuda_backend(x1):
2486+
pass
2487+
else:
2488+
return dpnp_modf(x1_desc)
24842489

24852490
return call_origin(numpy.modf, x1, **kwargs)
24862491

dpnp/dpnp_iface_sorting.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ def partition(x1, kth, axis=-1, kind="introselect", order=None):
188188
pass
189189
elif order is not None:
190190
pass
191+
elif dpnp.is_cuda_backend(x1):
192+
pass
191193
else:
192194
return dpnp_partition(x1_desc, kth, axis, kind, order).get_pyobj()
193195

dpnp/dpnp_iface_statistics.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ def correlate(x1, x2, mode="valid"):
380380
pass
381381
elif mode != "valid":
382382
pass
383+
elif dpnp.is_cuda_backend(x1) or dpnp.is_cuda_backend(x2):
384+
pass
383385
else:
384386
return dpnp_correlate(x1_desc, x2_desc).get_pyobj()
385387

@@ -665,6 +667,8 @@ def median(x1, axis=None, out=None, overwrite_input=False, keepdims=False):
665667
pass
666668
elif keepdims:
667669
pass
670+
elif dpnp.is_cuda_backend(x1):
671+
pass
668672
else:
669673
result_obj = dpnp_median(x1_desc).get_pyobj()
670674
result = dpnp.convert_single_elem_array_to_scalar(result_obj)

0 commit comments

Comments
 (0)