4747 "dpnp_bitwise_or" ,
4848 "dpnp_bitwise_xor" ,
4949 "dpnp_ceil" ,
50+ "dpnp_conj" ,
5051 "dpnp_cos" ,
5152 "dpnp_divide" ,
5253 "dpnp_equal" ,
@@ -419,20 +420,41 @@ def dpnp_ceil(x, out=None, order="K"):
419420"""
420421
421422
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 ):
423445 """A callback to register in UnaryElementwiseFunc class of dpctl.tensor"""
424446
425447 if depends is None :
426448 depends = []
427449
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 )
432454
433455
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
436458)
437459
438460
@@ -441,13 +463,42 @@ def dpnp_cos(x, out=None, order="K"):
441463 Invokes cos() function from pybind11 extension of OneMKL VM if possible.
442464
443465 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" ):
444492 """
493+ Invokes conj() function from pybind11 extension of OneMKL VM if possible.
445494
495+ Otherwise fully relies on dpctl.tensor implementation for conj() function.
496+ """
446497 # dpctl.tensor only works with usm_ndarray
447498 x1_usm = dpnp .get_usm_ndarray (x )
448499 out_usm = None if out is None else dpnp .get_usm_ndarray (out )
449500
450- res_usm = cos_func (x1_usm , out = out_usm , order = order )
501+ res_usm = conj_func (x1_usm , out = out_usm , order = order )
451502 return dpnp_array ._create_from_usm_ndarray (res_usm )
452503
453504
0 commit comments