Skip to content

Commit 4da3061

Browse files
authored
Remove unused algo utils functions from the backend (#1788)
1 parent 415e6df commit 4da3061

File tree

2 files changed

+0
-121
lines changed

2 files changed

+0
-121
lines changed

dpnp/dpnp_utils/dpnp_algo_utils.pxd

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ from dpnp.dpnp_algo cimport shape_type_c
3131
from dpnp.dpnp_algo.dpnp_algo cimport DPNPFuncData, DPNPFuncName, DPNPFuncType
3232

3333

34-
cpdef checker_throw_runtime_error(function_name, message)
35-
""" Throw exception RuntimeError with 'message'
36-
37-
"""
38-
3934
cpdef checker_throw_value_error(function_name, param_name, param, expected)
4035
""" Throw exception ValueError if 'param' is not 'expected'
4136
@@ -81,25 +76,11 @@ cpdef shape_type_c normalize_axis(object axis, size_t shape_size)
8176
Conversion of the transformation shape axis [-1, 0, 1] into [2, 0, 1] where numbers are `id`s of array shape axis
8277
"""
8378

84-
cdef tuple get_shape_dtype(object input_obj)
85-
"""
86-
input_obj: Complex object with lists, scalars and numpy-like arrays
87-
88-
Returns a tuple of:
89-
1. concatenated shape, empty `shape_type_c` if unsuccessful.
90-
2. dtype
91-
"""
92-
9379
cpdef long _get_linear_index(key, tuple shape, int ndim)
9480
"""
9581
Compute linear index of an element in memory from array indices
9682
"""
9783

98-
cpdef tuple get_axis_indeces(idx, shape)
99-
"""
100-
Compute axis indices of an element in array from array linear index
101-
"""
102-
10384
cpdef tuple get_axis_offsets(shape)
10485
"""
10586
Compute axis offsets in the linear array memory
@@ -124,19 +105,6 @@ cdef shape_type_c get_common_shape(shape_type_c input1_shape, shape_type_c input
124105
Calculate common shape from input shapes
125106
"""
126107

127-
cdef shape_type_c get_reduction_output_shape(shape_type_c input_shape, object axis, cpp_bool keepdims)
128-
"""
129-
Calculate output array shape in reduction functions
130-
"""
131-
132-
cdef DPNPFuncType get_output_c_type(DPNPFuncName funcID,
133-
DPNPFuncType input_array_c_type,
134-
object requested_out,
135-
object requested_dtype)
136-
"""
137-
Calculate output array type by 'out' and 'dtype' cast parameters
138-
"""
139-
140108
cdef dpnp_descriptor create_output_descriptor(shape_type_c output_shape,
141109
DPNPFuncType c_type,
142110
dpnp_descriptor requested_out,

dpnp/dpnp_utils/dpnp_algo_utils.pyx

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,11 @@ __all__ = [
6262
"call_origin",
6363
"checker_throw_axis_error",
6464
"checker_throw_index_error",
65-
"checker_throw_runtime_error",
6665
"checker_throw_type_error",
6766
"checker_throw_value_error",
6867
"create_output_descriptor_py",
6968
"convert_item",
7069
"dpnp_descriptor",
71-
"get_axis_indeces",
7270
"get_axis_offsets",
7371
"get_usm_allocations",
7472
"_get_linear_index",
@@ -322,10 +320,6 @@ cpdef checker_throw_index_error(function_name, index, size):
322320
f"{ERROR_PREFIX} in function {function_name}() index {index} is out of bounds. dimension size `{size}`")
323321

324322

325-
cpdef checker_throw_runtime_error(function_name, message):
326-
raise RuntimeError(f"{ERROR_PREFIX} in function {function_name}(): '{message}'")
327-
328-
329323
cpdef checker_throw_type_error(function_name, given_type):
330324
raise TypeError(f"{ERROR_PREFIX} in function {function_name}() type '{given_type}' is not supported")
331325

@@ -356,21 +350,6 @@ cpdef dpnp_descriptor create_output_descriptor_py(shape_type_c output_shape,
356350
sycl_queue=sycl_queue)
357351

358352

359-
cpdef tuple get_axis_indeces(idx, shape):
360-
"""
361-
Compute axis indices of an element in array from array linear index
362-
"""
363-
364-
ids = []
365-
remainder = idx
366-
offsets = get_axis_offsets(shape)
367-
for i in offsets:
368-
quotient, remainder = divmod(remainder, i)
369-
ids.append(quotient)
370-
371-
return _object_to_tuple(ids)
372-
373-
374353
cpdef tuple get_axis_offsets(shape):
375354
"""
376355
Compute axis offsets in the linear array memory
@@ -402,36 +381,6 @@ cpdef long _get_linear_index(key, tuple shape, int ndim):
402381
return li
403382

404383

405-
cdef tuple get_shape_dtype(object input_obj):
406-
cdef shape_type_c return_shape # empty shape means scalar
407-
return_dtype = None
408-
409-
# TODO replace with checking "shape" and "dtype" attributes
410-
if hasattr(input_obj, "shape") and hasattr(input_obj, "dtype"):
411-
return (input_obj.shape, input_obj.dtype)
412-
413-
cdef shape_type_c elem_shape
414-
cdef shape_type_c list_shape
415-
if isinstance(input_obj, (list, tuple)):
416-
for elem in input_obj:
417-
elem_shape, elem_dtype = get_shape_dtype(elem)
418-
419-
if return_shape.empty():
420-
return_shape = elem_shape
421-
return_dtype = elem_dtype
422-
423-
# shape and dtype does not match with siblings.
424-
if ((return_shape != elem_shape) or (return_dtype != elem_dtype)):
425-
return (elem_shape, dpnp.dtype(numpy.object_))
426-
427-
list_shape.push_back(len(input_obj))
428-
list_shape.insert(list_shape.end(), return_shape.begin(), return_shape.end())
429-
return (list_shape, return_dtype)
430-
431-
# assume scalar or object
432-
return (return_shape, dpnp.dtype(type(input_obj)))
433-
434-
435384
cdef shape_type_c get_common_shape(shape_type_c input1_shape, shape_type_c input2_shape) except *:
436385
cdef shape_type_c input1_shape_orig = input1_shape
437386
cdef shape_type_c input2_shape_orig = input2_shape
@@ -458,44 +407,6 @@ cdef shape_type_c get_common_shape(shape_type_c input1_shape, shape_type_c input
458407
return result_shape
459408

460409

461-
cdef shape_type_c get_reduction_output_shape(shape_type_c input_shape, object axis, cpp_bool keepdims):
462-
cdef shape_type_c result_shape
463-
cdef tuple axis_tuple = _object_to_tuple(axis)
464-
465-
if axis is not None:
466-
for it in range(input_shape.size()):
467-
if it not in axis_tuple:
468-
result_shape.push_back(input_shape[it])
469-
elif keepdims is True:
470-
result_shape.push_back(1)
471-
elif keepdims is True:
472-
for it in range(input_shape.size()):
473-
result_shape.push_back(1)
474-
475-
return result_shape
476-
477-
478-
cdef DPNPFuncType get_output_c_type(DPNPFuncName funcID,
479-
DPNPFuncType input_array_c_type,
480-
object requested_out,
481-
object requested_dtype):
482-
483-
if requested_out is None:
484-
if requested_dtype is None:
485-
""" get recommended result type by function ID """
486-
kernel_data = get_dpnp_function_ptr(funcID, input_array_c_type, input_array_c_type)
487-
return kernel_data.return_type
488-
else:
489-
""" return type by request """
490-
return dpnp_dtype_to_DPNPFuncType(requested_dtype)
491-
else:
492-
if requested_dtype is None:
493-
""" determined by 'out' parameter """
494-
return dpnp_dtype_to_DPNPFuncType(requested_out.dtype)
495-
496-
checker_throw_value_error("get_output_c_type", "dtype and out", requested_dtype, requested_out)
497-
498-
499410
cdef dpnp_descriptor create_output_descriptor(shape_type_c output_shape,
500411
DPNPFuncType c_type,
501412
dpnp_descriptor requested_out,

0 commit comments

Comments
 (0)