Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions dpnp/backend/include/dpnp_iface_fptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ enum class DPNPFuncName : size_t
DPNP_FN_DIAG_INDICES_EXT, /**< Used in numpy.diag_indices() impl, requires
extra parameters */
DPNP_FN_DIAGONAL, /**< Used in numpy.diagonal() impl */
DPNP_FN_DIAGONAL_EXT, /**< Used in numpy.diagonal() impl, requires extra
parameters */
DPNP_FN_DIVIDE, /**< Used in numpy.divide() impl */
DPNP_FN_DOT, /**< Used in numpy.dot() impl */
DPNP_FN_DOT_EXT, /**< Used in numpy.dot() impl, requires extra parameters */
Expand Down Expand Up @@ -343,8 +341,6 @@ enum class DPNPFuncName : size_t
DPNP_FN_TANH, /**< Used in numpy.tanh() impl */
DPNP_FN_TRANSPOSE, /**< Used in numpy.transpose() impl */
DPNP_FN_TRACE, /**< Used in numpy.trace() impl */
DPNP_FN_TRACE_EXT, /**< Used in numpy.trace() impl, requires extra
parameters */
DPNP_FN_TRAPZ, /**< Used in numpy.trapz() impl */
DPNP_FN_TRAPZ_EXT, /**< Used in numpy.trapz() impl, requires extra
parameters */
Expand Down
42 changes: 0 additions & 42 deletions dpnp/backend/kernels/dpnp_krnl_arraycreation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,15 +723,6 @@ void (*dpnp_trace_default_c)(const void *,
const size_t) =
dpnp_trace_c<_DataType, _ResultType>;

template <typename _DataType, typename _ResultType>
DPCTLSyclEventRef (*dpnp_trace_ext_c)(DPCTLSyclQueueRef,
const void *,
void *,
const shape_elem_type *,
const size_t,
const DPCTLEventVectorRef) =
dpnp_trace_c<_DataType, _ResultType>;

template <typename _DataType>
class dpnp_tri_c_kernel;

Expand Down Expand Up @@ -1288,39 +1279,6 @@ void func_map_init_arraycreation(func_map_t &fmap)
fmap[DPNPFuncName::DPNP_FN_TRACE][eft_DBL][eft_DBL] = {
eft_DBL, (void *)dpnp_trace_default_c<double, double>};

fmap[DPNPFuncName::DPNP_FN_TRACE_EXT][eft_INT][eft_INT] = {
eft_INT, (void *)dpnp_trace_ext_c<int32_t, int32_t>};
fmap[DPNPFuncName::DPNP_FN_TRACE_EXT][eft_LNG][eft_INT] = {
eft_INT, (void *)dpnp_trace_ext_c<int64_t, int32_t>};
fmap[DPNPFuncName::DPNP_FN_TRACE_EXT][eft_FLT][eft_INT] = {
eft_INT, (void *)dpnp_trace_ext_c<float, int32_t>};
fmap[DPNPFuncName::DPNP_FN_TRACE_EXT][eft_DBL][eft_INT] = {
eft_INT, (void *)dpnp_trace_ext_c<double, int32_t>};
fmap[DPNPFuncName::DPNP_FN_TRACE_EXT][eft_INT][eft_LNG] = {
eft_LNG, (void *)dpnp_trace_ext_c<int32_t, int64_t>};
fmap[DPNPFuncName::DPNP_FN_TRACE_EXT][eft_LNG][eft_LNG] = {
eft_LNG, (void *)dpnp_trace_ext_c<int64_t, int64_t>};
fmap[DPNPFuncName::DPNP_FN_TRACE_EXT][eft_FLT][eft_LNG] = {
eft_LNG, (void *)dpnp_trace_ext_c<float, int64_t>};
fmap[DPNPFuncName::DPNP_FN_TRACE_EXT][eft_DBL][eft_LNG] = {
eft_LNG, (void *)dpnp_trace_ext_c<double, int64_t>};
fmap[DPNPFuncName::DPNP_FN_TRACE_EXT][eft_INT][eft_FLT] = {
eft_FLT, (void *)dpnp_trace_ext_c<int32_t, float>};
fmap[DPNPFuncName::DPNP_FN_TRACE_EXT][eft_LNG][eft_FLT] = {
eft_FLT, (void *)dpnp_trace_ext_c<int64_t, float>};
fmap[DPNPFuncName::DPNP_FN_TRACE_EXT][eft_FLT][eft_FLT] = {
eft_FLT, (void *)dpnp_trace_ext_c<float, float>};
fmap[DPNPFuncName::DPNP_FN_TRACE_EXT][eft_DBL][eft_FLT] = {
eft_FLT, (void *)dpnp_trace_ext_c<double, float>};
fmap[DPNPFuncName::DPNP_FN_TRACE_EXT][eft_INT][eft_DBL] = {
eft_DBL, (void *)dpnp_trace_ext_c<int32_t, double>};
fmap[DPNPFuncName::DPNP_FN_TRACE_EXT][eft_LNG][eft_DBL] = {
eft_DBL, (void *)dpnp_trace_ext_c<int64_t, double>};
fmap[DPNPFuncName::DPNP_FN_TRACE_EXT][eft_FLT][eft_DBL] = {
eft_DBL, (void *)dpnp_trace_ext_c<float, double>};
fmap[DPNPFuncName::DPNP_FN_TRACE_EXT][eft_DBL][eft_DBL] = {
eft_DBL, (void *)dpnp_trace_ext_c<double, double>};

fmap[DPNPFuncName::DPNP_FN_TRI][eft_INT][eft_INT] = {
eft_INT, (void *)dpnp_tri_default_c<int32_t>};
fmap[DPNPFuncName::DPNP_FN_TRI][eft_LNG][eft_LNG] = {
Expand Down
25 changes: 0 additions & 25 deletions dpnp/backend/kernels/dpnp_krnl_indexing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,18 +293,6 @@ void (*dpnp_diagonal_default_c)(void *,
shape_elem_type *,
const size_t) = dpnp_diagonal_c<_DataType>;

template <typename _DataType>
DPCTLSyclEventRef (*dpnp_diagonal_ext_c)(DPCTLSyclQueueRef,
void *,
const size_t,
void *,
const size_t,
shape_elem_type *,
shape_elem_type *,
const size_t,
const DPCTLEventVectorRef) =
dpnp_diagonal_c<_DataType>;

template <typename _DataType>
DPCTLSyclEventRef
dpnp_fill_diagonal_c(DPCTLSyclQueueRef q_ref,
Expand Down Expand Up @@ -927,19 +915,6 @@ void func_map_init_indexing_func(func_map_t &fmap)
fmap[DPNPFuncName::DPNP_FN_DIAGONAL][eft_DBL][eft_DBL] = {
eft_DBL, (void *)dpnp_diagonal_default_c<double>};

fmap[DPNPFuncName::DPNP_FN_DIAGONAL_EXT][eft_INT][eft_INT] = {
eft_INT, (void *)dpnp_diagonal_ext_c<int32_t>};
fmap[DPNPFuncName::DPNP_FN_DIAGONAL_EXT][eft_LNG][eft_LNG] = {
eft_LNG, (void *)dpnp_diagonal_ext_c<int64_t>};
fmap[DPNPFuncName::DPNP_FN_DIAGONAL_EXT][eft_FLT][eft_FLT] = {
eft_FLT, (void *)dpnp_diagonal_ext_c<float>};
fmap[DPNPFuncName::DPNP_FN_DIAGONAL_EXT][eft_DBL][eft_DBL] = {
eft_DBL, (void *)dpnp_diagonal_ext_c<double>};
fmap[DPNPFuncName::DPNP_FN_DIAGONAL_EXT][eft_C64][eft_C64] = {
eft_C64, (void *)dpnp_diagonal_ext_c<std::complex<float>>};
fmap[DPNPFuncName::DPNP_FN_DIAGONAL_EXT][eft_C128][eft_C128] = {
eft_C128, (void *)dpnp_diagonal_ext_c<std::complex<double>>};

fmap[DPNPFuncName::DPNP_FN_FILL_DIAGONAL][eft_INT][eft_INT] = {
eft_INT, (void *)dpnp_fill_diagonal_default_c<int32_t>};
fmap[DPNPFuncName::DPNP_FN_FILL_DIAGONAL][eft_LNG][eft_LNG] = {
Expand Down
2 changes: 0 additions & 2 deletions dpnp/dpnp_algo/dpnp_algo.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ cdef extern from "dpnp_iface_fptr.hpp" namespace "DPNPFuncName": # need this na
DPNP_FN_CORRELATE_EXT
DPNP_FN_DEGREES_EXT
DPNP_FN_DIAG_INDICES_EXT
DPNP_FN_DIAGONAL_EXT
DPNP_FN_EDIFF1D_EXT
DPNP_FN_ERF_EXT
DPNP_FN_FABS_EXT
Expand Down Expand Up @@ -90,7 +89,6 @@ cdef extern from "dpnp_iface_fptr.hpp" namespace "DPNPFuncName": # need this na
DPNP_FN_RNG_WALD_EXT
DPNP_FN_RNG_WEIBULL_EXT
DPNP_FN_RNG_ZIPF_EXT
DPNP_FN_TRACE_EXT
DPNP_FN_TRAPZ_EXT

cdef extern from "dpnp_iface_fptr.hpp" namespace "DPNPFuncType": # need this namespace for Enum import
Expand Down
53 changes: 0 additions & 53 deletions dpnp/dpnp_algo/dpnp_algo_arraycreation.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ and the rest of the library

__all__ += [
"dpnp_copy",
"dpnp_trace",
]


Expand Down Expand Up @@ -73,59 +72,7 @@ ctypedef c_dpctl.DPCTLSyclEventRef(*custom_indexing_1out_func_ptr_t)(c_dpctl.DPC
const size_t ,
const int,
const c_dpctl.DPCTLEventVectorRef) except +
ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_dpnp_trace_t)(c_dpctl.DPCTLSyclQueueRef,
const void *,
void * ,
const shape_elem_type * ,
const size_t,
const c_dpctl.DPCTLEventVectorRef) except +


cpdef utils.dpnp_descriptor dpnp_copy(utils.dpnp_descriptor x1):
return call_fptr_1in_1out_strides(DPNP_FN_COPY_EXT, x1)


cpdef utils.dpnp_descriptor dpnp_trace(utils.dpnp_descriptor arr, offset=0, axis1=0, axis2=1, dtype=None, out=None):
if dtype is None:
dtype_ = arr.dtype
else:
dtype_ = dtype

cdef utils.dpnp_descriptor diagonal_arr = dpnp_diagonal(arr, offset)
cdef size_t diagonal_ndim = diagonal_arr.ndim
cdef shape_type_c diagonal_shape = diagonal_arr.shape

cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(arr.dtype)
cdef DPNPFuncType param2_type = dpnp_dtype_to_DPNPFuncType(dtype_)

cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_TRACE_EXT, param1_type, param2_type)

arr_obj = arr.get_array()

# create result array with type given by FPTR data
cdef shape_type_c result_shape = diagonal_shape[:-1]
cdef utils.dpnp_descriptor result = utils.create_output_descriptor(result_shape,
kernel_data.return_type,
None,
device=arr_obj.sycl_device,
usm_type=arr_obj.usm_type,
sycl_queue=arr_obj.sycl_queue)

result_sycl_queue = result.get_array().sycl_queue

cdef c_dpctl.SyclQueue q = <c_dpctl.SyclQueue> result_sycl_queue
cdef c_dpctl.DPCTLSyclQueueRef q_ref = q.get_queue_ref()

cdef fptr_dpnp_trace_t func = <fptr_dpnp_trace_t > kernel_data.ptr

cdef c_dpctl.DPCTLSyclEventRef event_ref = func(q_ref,
diagonal_arr.get_data(),
result.get_data(),
diagonal_shape.data(),
diagonal_ndim,
NULL) # dep_events_ref

with nogil: c_dpctl.DPCTLEvent_WaitAndThrow(event_ref)
c_dpctl.DPCTLEvent_Delete(event_ref)

return result
65 changes: 0 additions & 65 deletions dpnp/dpnp_algo/dpnp_algo_indexing.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_dpnp_choose_t)(c_dpctl.DPCTLSyclQueueRe
ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_dpnp_diag_indices)(c_dpctl.DPCTLSyclQueueRef,
void * , size_t,
const c_dpctl.DPCTLEventVectorRef)
ctypedef c_dpctl.DPCTLSyclEventRef(*custom_indexing_2in_1out_func_ptr_t_)(c_dpctl.DPCTLSyclQueueRef,
void * ,
const size_t,
void * ,
const size_t,
shape_elem_type * ,
shape_elem_type *,
const size_t,
const c_dpctl.DPCTLEventVectorRef)
ctypedef c_dpctl.DPCTLSyclEventRef(*custom_indexing_2in_func_ptr_t)(c_dpctl.DPCTLSyclQueueRef,
void *, void * , shape_elem_type * , const size_t,
const c_dpctl.DPCTLEventVectorRef)
Expand Down Expand Up @@ -146,62 +137,6 @@ cpdef tuple dpnp_diag_indices(n, ndim):
return tuple(res_list)


cpdef utils.dpnp_descriptor dpnp_diagonal(dpnp_descriptor x1, offset=0):
cdef shape_type_c x1_shape = x1.shape

n = min(x1.shape[0], x1.shape[1])
res_shape = [None] * (x1.ndim - 1)

if x1.ndim > 2:
for i in range(x1.ndim - 2):
res_shape[i] = x1.shape[i + 2]

if (n + offset) > x1.shape[1]:
res_shape[-1] = x1.shape[1] - offset
elif (n + offset) > x1.shape[0]:
res_shape[-1] = x1.shape[0]
else:
res_shape[-1] = n + offset

cdef shape_type_c result_shape = res_shape
res_ndim = len(res_shape)

cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(x1.dtype)

cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_DIAGONAL_EXT, param1_type, param1_type)

x1_obj = x1.get_array()

cdef utils.dpnp_descriptor result = utils.create_output_descriptor(result_shape,
kernel_data.return_type,
None,
device=x1_obj.sycl_device,
usm_type=x1_obj.usm_type,
sycl_queue=x1_obj.sycl_queue)

result_sycl_queue = result.get_array().sycl_queue

cdef c_dpctl.SyclQueue q = <c_dpctl.SyclQueue> result_sycl_queue
cdef c_dpctl.DPCTLSyclQueueRef q_ref = q.get_queue_ref()

cdef custom_indexing_2in_1out_func_ptr_t_ func = <custom_indexing_2in_1out_func_ptr_t_ > kernel_data.ptr

cdef c_dpctl.DPCTLSyclEventRef event_ref = func(q_ref,
x1.get_data(),
x1.size,
result.get_data(),
offset,
x1_shape.data(),
result_shape.data(),
res_ndim,
NULL) # dep_events_ref

with nogil: c_dpctl.DPCTLEvent_WaitAndThrow(event_ref)
c_dpctl.DPCTLEvent_Delete(event_ref)

return result


cpdef dpnp_fill_diagonal(dpnp_descriptor x1, val):
x1_obj = x1.get_array()

Expand Down
13 changes: 12 additions & 1 deletion dpnp/dpnp_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,18 @@ def take(self, indices, /, *, axis=None, out=None, mode="wrap"):
# 'tofile',
# 'tolist',
# 'tostring',
# 'trace',

def trace(self, offset=0, axis1=0, axis2=1, dtype=None, out=None):
"""
Return the sum along diagonals of the array.

Refer to :obj:`dpnp.trace` for full documentation.

"""

return dpnp.trace(
self, offset=offset, axis1=axis1, axis2=axis2, dtype=dtype, out=out
)

def transpose(self, *axes):
"""
Expand Down
Loading