47
47
"dpnp_bitwise_or" ,
48
48
"dpnp_bitwise_xor" ,
49
49
"dpnp_ceil" ,
50
+ "dpnp_conj" ,
50
51
"dpnp_cos" ,
51
52
"dpnp_divide" ,
52
53
"dpnp_equal" ,
@@ -419,20 +420,41 @@ def dpnp_ceil(x, out=None, order="K"):
419
420
"""
420
421
421
422
422
- def _call_cos (src , dst , sycl_queue , depends = None ):
423
+ _conj_docstring = """
424
+ conj(x, out=None, order='K')
425
+
426
+ Computes conjugate for each element `x_i` for input array `x`.
427
+
428
+ Args:
429
+ x (dpnp.ndarray):
430
+ Input array, expected to have numeric data type.
431
+ out ({None, dpnp.ndarray}, optional):
432
+ Output array to populate. Array must have the correct
433
+ shape and the expected data type.
434
+ order ("C","F","A","K", optional): memory layout of the new
435
+ output array, if parameter `out` is `None`.
436
+ Default: "K".
437
+ Return:
438
+ dpnp.ndarray:
439
+ An array containing the element-wise conjugate.
440
+ The returned array has the same data type as `x`.
441
+ """
442
+
443
+
444
+ def _call_conj (src , dst , sycl_queue , depends = None ):
423
445
"""A callback to register in UnaryElementwiseFunc class of dpctl.tensor"""
424
446
425
447
if depends is None :
426
448
depends = []
427
449
428
- if vmi ._mkl_cos_to_call (sycl_queue , src , dst ):
429
- # call pybind11 extension for cos () function from OneMKL VM
430
- return vmi ._cos (sycl_queue , src , dst , depends )
431
- return ti ._cos (src , dst , sycl_queue , depends )
450
+ if vmi ._mkl_conj_to_call (sycl_queue , src , dst ):
451
+ # call pybind11 extension for conj () function from OneMKL VM
452
+ return vmi ._conj (sycl_queue , src , dst , depends )
453
+ return ti ._conj (src , dst , sycl_queue , depends )
432
454
433
455
434
- cos_func = UnaryElementwiseFunc (
435
- "cos " , ti ._cos_result_type , _call_cos , _cos_docstring
456
+ conj_func = UnaryElementwiseFunc (
457
+ "conj " , ti ._conj_result_type , _call_conj , _conj_docstring
436
458
)
437
459
438
460
@@ -441,13 +463,42 @@ def dpnp_cos(x, out=None, order="K"):
441
463
Invokes cos() function from pybind11 extension of OneMKL VM if possible.
442
464
443
465
Otherwise fully relies on dpctl.tensor implementation for cos() function.
466
+
467
+ """
468
+
469
+ def _call_cos (src , dst , sycl_queue , depends = None ):
470
+ """A callback to register in UnaryElementwiseFunc class of dpctl.tensor"""
471
+
472
+ if depends is None :
473
+ depends = []
474
+
475
+ if vmi ._mkl_cos_to_call (sycl_queue , src , dst ):
476
+ # call pybind11 extension for cos() function from OneMKL VM
477
+ return vmi ._cos (sycl_queue , src , dst , depends )
478
+ return ti ._cos (src , dst , sycl_queue , depends )
479
+
480
+ # dpctl.tensor only works with usm_ndarray
481
+ x1_usm = dpnp .get_usm_ndarray (x )
482
+ out_usm = None if out is None else dpnp .get_usm_ndarray (out )
483
+
484
+ func = UnaryElementwiseFunc (
485
+ "cos" , ti ._cos_result_type , _call_cos , _cos_docstring
486
+ )
487
+ res_usm = func (x1_usm , out = out_usm , order = order )
488
+ return dpnp_array ._create_from_usm_ndarray (res_usm )
489
+
490
+
491
+ def dpnp_conj (x , out = None , order = "K" ):
444
492
"""
493
+ Invokes conj() function from pybind11 extension of OneMKL VM if possible.
445
494
495
+ Otherwise fully relies on dpctl.tensor implementation for conj() function.
496
+ """
446
497
# dpctl.tensor only works with usm_ndarray
447
498
x1_usm = dpnp .get_usm_ndarray (x )
448
499
out_usm = None if out is None else dpnp .get_usm_ndarray (out )
449
500
450
- res_usm = cos_func (x1_usm , out = out_usm , order = order )
501
+ res_usm = conj_func (x1_usm , out = out_usm , order = order )
451
502
return dpnp_array ._create_from_usm_ndarray (res_usm )
452
503
453
504
0 commit comments