Skip to content

Commit 96021f0

Browse files
authored
Merge pull request #1614 from IntelPython/reuse_dpctl_repeat
Leverage dpctl.tensor.repeat() implementation
2 parents c31557c + b81bfb9 commit 96021f0

16 files changed

+228
-242
lines changed

dpnp/backend/include/dpnp_iface_fptr.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ enum class DPNPFuncName : size_t
176176
DPNP_FN_FILL_DIAGONAL_EXT, /**< Used in numpy.fill_diagonal() impl, requires
177177
extra parameters */
178178
DPNP_FN_FLATTEN, /**< Used in numpy.flatten() impl */
179-
DPNP_FN_FLATTEN_EXT, /**< Used in numpy.flatten() impl, requires extra
180-
parameters */
181179
DPNP_FN_FLOOR, /**< Used in numpy.floor() impl */
182180
DPNP_FN_FLOOR_DIVIDE, /**< Used in numpy.floor_divide() impl */
183181
DPNP_FN_FLOOR_DIVIDE_EXT, /**< Used in numpy.floor_divide() impl, requires
@@ -259,8 +257,6 @@ enum class DPNPFuncName : size_t
259257
DPNP_FN_RECIP_EXT, /**< Used in numpy.recip() impl, requires extra
260258
parameters */
261259
DPNP_FN_REPEAT, /**< Used in numpy.repeat() impl */
262-
DPNP_FN_REPEAT_EXT, /**< Used in numpy.repeat() impl, requires extra
263-
parameters */
264260
DPNP_FN_RIGHT_SHIFT, /**< Used in numpy.right_shift() impl */
265261
DPNP_FN_RNG_BETA, /**< Used in numpy.random.beta() impl */
266262
DPNP_FN_RNG_BETA_EXT, /**< Used in numpy.random.beta() impl, requires extra

dpnp/backend/kernels/dpnp_krnl_elemwise.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -940,19 +940,6 @@ static void func_map_init_elemwise_1arg_1type(func_map_t &fmap)
940940
fmap[DPNPFuncName::DPNP_FN_FLATTEN][eft_C128][eft_C128] = {
941941
eft_C128, (void *)dpnp_copy_c_default<std::complex<double>>};
942942

943-
fmap[DPNPFuncName::DPNP_FN_FLATTEN_EXT][eft_BLN][eft_BLN] = {
944-
eft_BLN, (void *)dpnp_copy_c_ext<bool>};
945-
fmap[DPNPFuncName::DPNP_FN_FLATTEN_EXT][eft_INT][eft_INT] = {
946-
eft_INT, (void *)dpnp_copy_c_ext<int32_t>};
947-
fmap[DPNPFuncName::DPNP_FN_FLATTEN_EXT][eft_LNG][eft_LNG] = {
948-
eft_LNG, (void *)dpnp_copy_c_ext<int64_t>};
949-
fmap[DPNPFuncName::DPNP_FN_FLATTEN_EXT][eft_FLT][eft_FLT] = {
950-
eft_FLT, (void *)dpnp_copy_c_ext<float>};
951-
fmap[DPNPFuncName::DPNP_FN_FLATTEN_EXT][eft_DBL][eft_DBL] = {
952-
eft_DBL, (void *)dpnp_copy_c_ext<double>};
953-
fmap[DPNPFuncName::DPNP_FN_FLATTEN_EXT][eft_C128][eft_C128] = {
954-
eft_C128, (void *)dpnp_copy_c_ext<std::complex<double>>};
955-
956943
fmap[DPNPFuncName::DPNP_FN_NEGATIVE][eft_INT][eft_INT] = {
957944
eft_INT, (void *)dpnp_negative_c_default<int32_t>};
958945
fmap[DPNPFuncName::DPNP_FN_NEGATIVE][eft_LNG][eft_LNG] = {

dpnp/backend/kernels/dpnp_krnl_manipulation.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,6 @@ void (*dpnp_repeat_default_c)(const void *,
103103
const size_t,
104104
const size_t) = dpnp_repeat_c<_DataType>;
105105

106-
template <typename _DataType>
107-
DPCTLSyclEventRef (*dpnp_repeat_ext_c)(DPCTLSyclQueueRef,
108-
const void *,
109-
void *,
110-
const size_t,
111-
const size_t,
112-
const DPCTLEventVectorRef) =
113-
dpnp_repeat_c<_DataType>;
114-
115106
template <typename _KernelNameSpecialization>
116107
class dpnp_elemwise_transpose_c_kernel;
117108

@@ -232,15 +223,6 @@ void func_map_init_manipulation(func_map_t &fmap)
232223
fmap[DPNPFuncName::DPNP_FN_REPEAT][eft_DBL][eft_DBL] = {
233224
eft_DBL, (void *)dpnp_repeat_default_c<double>};
234225

235-
fmap[DPNPFuncName::DPNP_FN_REPEAT_EXT][eft_INT][eft_INT] = {
236-
eft_INT, (void *)dpnp_repeat_ext_c<int32_t>};
237-
fmap[DPNPFuncName::DPNP_FN_REPEAT_EXT][eft_LNG][eft_LNG] = {
238-
eft_LNG, (void *)dpnp_repeat_ext_c<int64_t>};
239-
fmap[DPNPFuncName::DPNP_FN_REPEAT_EXT][eft_FLT][eft_FLT] = {
240-
eft_FLT, (void *)dpnp_repeat_ext_c<float>};
241-
fmap[DPNPFuncName::DPNP_FN_REPEAT_EXT][eft_DBL][eft_DBL] = {
242-
eft_DBL, (void *)dpnp_repeat_ext_c<double>};
243-
244226
fmap[DPNPFuncName::DPNP_FN_TRANSPOSE][eft_INT][eft_INT] = {
245227
eft_INT, (void *)dpnp_elemwise_transpose_default_c<int32_t>};
246228
fmap[DPNPFuncName::DPNP_FN_TRANSPOSE][eft_LNG][eft_LNG] = {

dpnp/dpnp_algo/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
set(dpnp_algo_pyx_deps
33
${CMAKE_CURRENT_SOURCE_DIR}/dpnp_algo_linearalgebra.pxi
4-
${CMAKE_CURRENT_SOURCE_DIR}/dpnp_algo_manipulation.pxi
54
${CMAKE_CURRENT_SOURCE_DIR}/dpnp_algo_statistics.pxi
65
${CMAKE_CURRENT_SOURCE_DIR}/dpnp_algo_trigonometric.pxi
76
${CMAKE_CURRENT_SOURCE_DIR}/dpnp_algo_sorting.pxi

dpnp/dpnp_algo/dpnp_algo.pxd

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ cdef extern from "dpnp_iface_fptr.hpp" namespace "DPNPFuncName": # need this na
9292
DPNP_FN_FFT_RFFT_EXT
9393
DPNP_FN_FILL_DIAGONAL
9494
DPNP_FN_FILL_DIAGONAL_EXT
95-
DPNP_FN_FLATTEN
96-
DPNP_FN_FLATTEN_EXT
9795
DPNP_FN_FMOD
9896
DPNP_FN_FMOD_EXT
9997
DPNP_FN_FULL
@@ -130,8 +128,6 @@ cdef extern from "dpnp_iface_fptr.hpp" namespace "DPNPFuncName": # need this na
130128
DPNP_FN_RADIANS_EXT
131129
DPNP_FN_RECIP
132130
DPNP_FN_RECIP_EXT
133-
DPNP_FN_REPEAT
134-
DPNP_FN_REPEAT_EXT
135131
DPNP_FN_RNG_BETA
136132
DPNP_FN_RNG_BETA_EXT
137133
DPNP_FN_RNG_BINOMIAL
@@ -323,8 +319,6 @@ ctypedef c_dpctl.DPCTLSyclEventRef(*dpnp_reduction_c_t)(c_dpctl.DPCTLSyclQueueRe
323319
const long*,
324320
const c_dpctl.DPCTLEventVectorRef)
325321

326-
cpdef dpnp_descriptor dpnp_flatten(dpnp_descriptor x1)
327-
328322

329323
"""
330324
Internal functions
@@ -359,10 +353,6 @@ cpdef dpnp_descriptor dpnp_fmax(dpnp_descriptor x1_obj, dpnp_descriptor x2_obj,
359353
dpnp_descriptor out=*, object where=*)
360354
cpdef dpnp_descriptor dpnp_fmin(dpnp_descriptor x1_obj, dpnp_descriptor x2_obj, object dtype=*,
361355
dpnp_descriptor out=*, object where=*)
362-
"""
363-
Array manipulation routines
364-
"""
365-
cpdef dpnp_descriptor dpnp_repeat(dpnp_descriptor array1, repeats, axes=*)
366356

367357

368358
"""

dpnp/dpnp_algo/dpnp_algo.pyx

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ import operator
5454
import numpy
5555

5656
__all__ = [
57-
"dpnp_flatten",
5857
"dpnp_queue_initialize",
5958
]
6059

@@ -63,7 +62,6 @@ include "dpnp_algo_arraycreation.pxi"
6362
include "dpnp_algo_indexing.pxi"
6463
include "dpnp_algo_linearalgebra.pxi"
6564
include "dpnp_algo_logic.pxi"
66-
include "dpnp_algo_manipulation.pxi"
6765
include "dpnp_algo_mathematical.pxi"
6866
include "dpnp_algo_searching.pxi"
6967
include "dpnp_algo_sorting.pxi"
@@ -81,53 +79,6 @@ ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_dpnp_flatten_t)(c_dpctl.DPCTLSyclQueueR
8179
const c_dpctl.DPCTLEventVectorRef)
8280

8381

84-
cpdef utils.dpnp_descriptor dpnp_flatten(utils.dpnp_descriptor x1):
85-
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(x1.dtype)
86-
87-
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_FLATTEN_EXT, param1_type, param1_type)
88-
89-
cdef shape_type_c x1_shape = x1.shape
90-
cdef shape_type_c x1_strides = utils.strides_to_vector(x1.strides, x1_shape)
91-
92-
x1_obj = x1.get_array()
93-
94-
# create result array with type given by FPTR data
95-
cdef shape_type_c result_shape = (x1.size,)
96-
cdef utils.dpnp_descriptor result = utils.create_output_descriptor(result_shape,
97-
kernel_data.return_type,
98-
None,
99-
device=x1_obj.sycl_device,
100-
usm_type=x1_obj.usm_type,
101-
sycl_queue=x1_obj.sycl_queue)
102-
103-
result_sycl_queue = result.get_array().sycl_queue
104-
105-
cdef c_dpctl.SyclQueue q = <c_dpctl.SyclQueue> result_sycl_queue
106-
cdef c_dpctl.DPCTLSyclQueueRef q_ref = q.get_queue_ref()
107-
108-
cdef shape_type_c result_strides = utils.strides_to_vector(result.strides, result_shape)
109-
110-
cdef fptr_dpnp_flatten_t func = <fptr_dpnp_flatten_t > kernel_data.ptr
111-
cdef c_dpctl.DPCTLSyclEventRef event_ref = func(q_ref,
112-
result.get_data(),
113-
result.size,
114-
result.ndim,
115-
result_shape.data(),
116-
result_strides.data(),
117-
x1.get_data(),
118-
x1.size,
119-
x1.ndim,
120-
x1_shape.data(),
121-
x1_strides.data(),
122-
NULL,
123-
NULL) # dep_events_ref
124-
125-
with nogil: c_dpctl.DPCTLEvent_WaitAndThrow(event_ref)
126-
c_dpctl.DPCTLEvent_Delete(event_ref)
127-
128-
return result
129-
130-
13182
cpdef dpnp_queue_initialize():
13283
"""
13384
Initialize SYCL queue which will be used for any library operations.

dpnp/dpnp_algo/dpnp_algo_manipulation.pxi

Lines changed: 0 additions & 80 deletions
This file was deleted.

dpnp/dpnp_array.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,15 @@ def put(self, indices, vals, /, *, axis=None, mode="wrap"):
10501050

10511051
return dpnp.put(self, indices, vals, axis=axis, mode=mode)
10521052

1053-
# 'ravel',
1053+
def ravel(self, order="C"):
1054+
"""
1055+
Return a contiguous flattened array.
1056+
1057+
For full documentation refer to :obj:`dpnp.ravel`.
1058+
1059+
"""
1060+
1061+
return dpnp.ravel(self, order=order)
10541062

10551063
@property
10561064
def real(self):
@@ -1087,7 +1095,15 @@ def real(self, value):
10871095
"""
10881096
dpnp.copyto(self._array_obj.real, value)
10891097

1090-
# 'repeat',
1098+
def repeat(self, repeats, axis=None):
1099+
"""
1100+
Repeat elements of an array.
1101+
1102+
For full documentation refer to :obj:`dpnp.repeat`.
1103+
1104+
"""
1105+
1106+
return dpnp.repeat(self, repeats, axis=axis)
10911107

10921108
def reshape(self, *sh, **kwargs):
10931109
"""

0 commit comments

Comments
 (0)