Skip to content

Commit 2c43f47

Browse files
authored
utils function refactoring. move to cdef (#792)
1 parent 16b15c9 commit 2c43f47

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

dpnp/dpnp_algo/dpnp_algo.pxd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ cpdef dparray dpnp_flatten(dparray array1)
238238
"""
239239
Internal functions
240240
"""
241-
cpdef DPNPFuncType dpnp_dtype_to_DPNPFuncType(dtype)
242-
cpdef dpnp_DPNPFuncType_to_dtype(size_t type)
241+
cdef DPNPFuncType dpnp_dtype_to_DPNPFuncType(dtype)
242+
cdef dpnp_DPNPFuncType_to_dtype(size_t type)
243243

244244

245245
"""

dpnp/dpnp_algo/dpnp_algo.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ cpdef dpnp_queue_is_cpu():
198198
"""
199199
Internal functions
200200
"""
201-
cpdef DPNPFuncType dpnp_dtype_to_DPNPFuncType(dtype):
201+
cdef DPNPFuncType dpnp_dtype_to_DPNPFuncType(dtype):
202202

203203
if dtype in [numpy.float64, 'float64']:
204204
return DPNP_FT_DOUBLE
@@ -215,7 +215,7 @@ cpdef DPNPFuncType dpnp_dtype_to_DPNPFuncType(dtype):
215215
else:
216216
utils.checker_throw_type_error("dpnp_dtype_to_DPNPFuncType", dtype)
217217

218-
cpdef dpnp_DPNPFuncType_to_dtype(size_t type):
218+
cdef dpnp_DPNPFuncType_to_dtype(size_t type):
219219
"""
220220
Type 'size_t' used instead 'DPNPFuncType' because Cython has lack of Enum support (0.29)
221221
TODO needs to use DPNPFuncType here

dpnp/dpnp_utils/dpnp_algo_utils.pyx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ __all__ = [
5353
"checker_throw_runtime_error",
5454
"checker_throw_type_error",
5555
"checker_throw_value_error",
56+
"create_output_descriptor_py",
5657
"dp2nd_array",
5758
"dpnp_descriptor",
5859
"get_axis_indeces",
@@ -135,6 +136,12 @@ cpdef checker_throw_value_error(function_name, param_name, param, expected):
135136
raise ValueError(err_msg)
136137

137138

139+
cpdef dpnp_descriptor create_output_descriptor_py(dparray_shape_type output_shape, object d_type, object requested_out):
140+
cdef DPNPFuncType c_type = dpnp_dtype_to_DPNPFuncType(d_type)
141+
142+
return create_output_descriptor(output_shape, c_type, requested_out)
143+
144+
138145
cpdef dp2nd_array(arr):
139146
"""Convert dparray to ndarray"""
140147
return dpnp.asnumpy(arr) if isinstance(arr, dparray) else arr

0 commit comments

Comments
 (0)