Skip to content

identity and tri with device keywords #1577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 6, 2023
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
27 changes: 12 additions & 15 deletions dpnp/backend/include/dpnp_iface_fptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ enum class DPNPFuncName : size_t
extra parameters */
DPNP_FN_HYPOT, /**< Used in numpy.hypot() impl */
DPNP_FN_IDENTITY, /**< Used in numpy.identity() impl */
DPNP_FN_IDENTITY_EXT, /**< Used in numpy.identity() impl, requires extra
parameters */
DPNP_FN_INITVAL, /**< Used in numpy ones, ones_like, zeros, zeros_like impls
*/
DPNP_FN_INITVAL_EXT, /**< Used in numpy ones, ones_like, zeros, zeros_like
Expand Down Expand Up @@ -438,19 +436,18 @@ enum class DPNPFuncName : size_t
DPNP_FN_TAKE, /**< Used in numpy.take() impl */
DPNP_FN_TAN, /**< Used in numpy.tan() impl */
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 */
DPNP_FN_TRI, /**< Used in numpy.tri() impl */
DPNP_FN_TRI_EXT, /**< Used in numpy.tri() impl, requires extra parameters */
DPNP_FN_TRIL, /**< Used in numpy.tril() impl */
DPNP_FN_TRIU, /**< Used in numpy.triu() impl */
DPNP_FN_TRUNC, /**< Used in numpy.trunc() impl */
DPNP_FN_VANDER, /**< Used in numpy.vander() 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 */
DPNP_FN_TRI, /**< Used in numpy.tri() impl */
DPNP_FN_TRIL, /**< Used in numpy.tril() impl */
DPNP_FN_TRIU, /**< Used in numpy.triu() impl */
DPNP_FN_TRUNC, /**< Used in numpy.trunc() impl */
DPNP_FN_VANDER, /**< Used in numpy.vander() impl */
DPNP_FN_VANDER_EXT, /**< Used in numpy.vander() impl, requires extra
parameters */
DPNP_FN_VAR, /**< Used in numpy.var() impl */
Expand Down
40 changes: 0 additions & 40 deletions dpnp/backend/kernels/dpnp_krnl_arraycreation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,6 @@ template <typename _DataType>
void (*dpnp_identity_default_c)(void *,
const size_t) = dpnp_identity_c<_DataType>;

template <typename _DataType>
DPCTLSyclEventRef (*dpnp_identity_ext_c)(DPCTLSyclQueueRef,
void *,
const size_t,
const DPCTLEventVectorRef) =
dpnp_identity_c<_DataType>;

template <typename _DataType>
class dpnp_ones_c_kernel;

Expand Down Expand Up @@ -851,15 +844,6 @@ template <typename _DataType>
void (*dpnp_tri_default_c)(void *, const size_t, const size_t, const int) =
dpnp_tri_c<_DataType>;

template <typename _DataType>
DPCTLSyclEventRef (*dpnp_tri_ext_c)(DPCTLSyclQueueRef,
void *,
const size_t,
const size_t,
const int,
const DPCTLEventVectorRef) =
dpnp_tri_c<_DataType>;

template <typename _DataType>
DPCTLSyclEventRef dpnp_tril_c(DPCTLSyclQueueRef q_ref,
void *array_in,
Expand Down Expand Up @@ -1265,21 +1249,6 @@ void func_map_init_arraycreation(func_map_t &fmap)
fmap[DPNPFuncName::DPNP_FN_IDENTITY][eft_C128][eft_C128] = {
eft_C128, (void *)dpnp_identity_default_c<std::complex<double>>};

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

fmap[DPNPFuncName::DPNP_FN_ONES][eft_INT][eft_INT] = {
eft_INT, (void *)dpnp_ones_default_c<int32_t>};
fmap[DPNPFuncName::DPNP_FN_ONES][eft_LNG][eft_LNG] = {
Expand Down Expand Up @@ -1431,15 +1400,6 @@ void func_map_init_arraycreation(func_map_t &fmap)
fmap[DPNPFuncName::DPNP_FN_TRI][eft_DBL][eft_DBL] = {
eft_DBL, (void *)dpnp_tri_default_c<double>};

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

fmap[DPNPFuncName::DPNP_FN_TRIL][eft_INT][eft_INT] = {
eft_INT, (void *)dpnp_tril_default_c<int32_t>};
fmap[DPNPFuncName::DPNP_FN_TRIL][eft_LNG][eft_LNG] = {
Expand Down
4 changes: 0 additions & 4 deletions dpnp/dpnp_algo/dpnp_algo.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ cdef extern from "dpnp_iface_fptr.hpp" namespace "DPNPFuncName": # need this na
DPNP_FN_FMOD_EXT
DPNP_FN_FULL
DPNP_FN_FULL_LIKE
DPNP_FN_IDENTITY
DPNP_FN_IDENTITY_EXT
DPNP_FN_INV
DPNP_FN_INV_EXT
DPNP_FN_KRON
Expand Down Expand Up @@ -242,8 +240,6 @@ cdef extern from "dpnp_iface_fptr.hpp" namespace "DPNPFuncName": # need this na
DPNP_FN_TRANSPOSE
DPNP_FN_TRAPZ
DPNP_FN_TRAPZ_EXT
DPNP_FN_TRI
DPNP_FN_TRI_EXT
DPNP_FN_TRIL
DPNP_FN_TRIL_EXT
DPNP_FN_TRIU
Expand Down
50 changes: 0 additions & 50 deletions dpnp/dpnp_algo/dpnp_algo_arraycreation.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ __all__ += [
"dpnp_copy",
"dpnp_diag",
"dpnp_geomspace",
"dpnp_identity",
"dpnp_linspace",
"dpnp_logspace",
"dpnp_ptp",
"dpnp_trace",
"dpnp_tri",
"dpnp_vander",
]

Expand Down Expand Up @@ -168,28 +166,6 @@ cpdef utils.dpnp_descriptor dpnp_geomspace(start, stop, num, endpoint, dtype, ax
return result


cpdef utils.dpnp_descriptor dpnp_identity(n, result_dtype):
cdef DPNPFuncType dtype_in = dpnp_dtype_to_DPNPFuncType(result_dtype)

cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_IDENTITY_EXT, dtype_in, DPNP_FT_NONE)

cdef shape_type_c shape_in = (n, n)
cdef utils.dpnp_descriptor result = utils.create_output_descriptor(shape_in, kernel_data.return_type, None)

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_1out_t func = <fptr_1out_t > kernel_data.ptr
cdef c_dpctl.DPCTLSyclEventRef event_ref = func(q_ref, result.get_data(), n, NULL)

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

return result


def dpnp_linspace(start, stop, num, dtype=None, device=None, usm_type=None, sycl_queue=None, endpoint=True, retstep=False, axis=0):
usm_type_alloc, sycl_queue_alloc = utils_py.get_usm_allocations([start, stop])

Expand Down Expand Up @@ -401,32 +377,6 @@ cpdef utils.dpnp_descriptor dpnp_trace(utils.dpnp_descriptor arr, offset=0, axis
return result


cpdef utils.dpnp_descriptor dpnp_tri(N, M=None, k=0, dtype=dpnp.float):
if M is None:
M = N

cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dtype)

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

cdef shape_type_c shape_in = (N, M)
cdef utils.dpnp_descriptor result = utils.create_output_descriptor(shape_in, kernel_data.return_type, None)

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_1out_func_ptr_t func = <custom_indexing_1out_func_ptr_t > kernel_data.ptr

cdef c_dpctl.DPCTLSyclEventRef event_ref = func(q_ref, result.get_data(), N, M, k, NULL)

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

return result


cpdef utils.dpnp_descriptor dpnp_vander(utils.dpnp_descriptor x1, int N, int increasing):
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(x1.dtype)
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_VANDER_EXT, param1_type, DPNP_FT_NONE)
Expand Down
Loading