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
3 changes: 0 additions & 3 deletions dpnp/dpnp_algo/dpnp_algo.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,6 @@ ctypedef void(*dpnp_reduction_c_t)(void * , const void * , const size_t*, const

cdef dparray call_fptr_1out(DPNPFuncName fptr_name, result_shape, result_dtype)
cdef dparray call_fptr_1in_1out(DPNPFuncName fptr_name, dparray x1, dparray_shape_type result_shape)
cdef dparray call_fptr_2in_1out(DPNPFuncName fptr_name, object x1_obj, object x2_obj,
object dtype=*, dparray out=*, object where=*)


cpdef dparray dpnp_astype(dparray array1, dtype_target)
cpdef dparray dpnp_flatten(dparray array1)
Expand Down
49 changes: 1 addition & 48 deletions dpnp/dpnp_algo/dpnp_algo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -279,55 +279,8 @@ cdef dparray call_fptr_1in_1out(DPNPFuncName fptr_name, dparray x1, dparray_shap
return result


cdef dparray call_fptr_2in_1out(DPNPFuncName fptr_name, object x1_obj, object x2_obj,
cdef dparray call_fptr_2in_1out(DPNPFuncName fptr_name, utils.dpnp_descriptor x1_obj, utils.dpnp_descriptor x2_obj,
object dtype=None, dparray out=None, object where=True):
cdef dparray_shape_type x1_shape, x2_shape, result_shape

cdef bint x1_obj_is_dparray = isinstance(x1_obj, dparray)
cdef bint x2_obj_is_dparray = isinstance(x2_obj, dparray)

cdef dparray x1_dparray, x2_dparray

common_type = utils.find_common_type(x1_obj, x2_obj)

if x1_obj_is_dparray:
x1_dparray = x1_obj
else:
x1_dparray = dparray((1,), dtype=common_type)
utils.copy_values_to_dparray(x1_dparray, (x1_obj,))

if x2_obj_is_dparray:
x2_dparray = x2_obj
else:
x2_dparray = dparray((1,), dtype=common_type)
utils.copy_values_to_dparray(x2_dparray, (x2_obj,))

x1_shape = x1_dparray.shape
x2_shape = x2_dparray.shape
result_shape = utils.get_common_shape(x1_shape, x2_shape)

# Convert string type names (dparray.dtype) to C enum DPNPFuncType
cdef DPNPFuncType x1_c_type = dpnp_dtype_to_DPNPFuncType(x1_dparray.dtype)
cdef DPNPFuncType x2_c_type = dpnp_dtype_to_DPNPFuncType(x2_dparray.dtype)

# get the FPTR data structure
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(fptr_name, x1_c_type, x2_c_type)

# TODO: apply parameters out and dtype after reafactoring fmap (required 4th level nesting)

# Create result array
cdef dparray result = utils.create_output_array(result_shape, kernel_data.return_type, out)

""" Call FPTR function """
cdef fptr_2in_1out_t func = <fptr_2in_1out_t > kernel_data.ptr
func(result.get_data(), x1_dparray.get_data(), x1_dparray.size, x1_shape.data(), x1_shape.size(),
x2_dparray.get_data(), x2_dparray.size, x2_shape.data(), x2_shape.size(), NULL)

return result

# this is replacement for "call_fptr_2in_1out". original function must be deleted after transotion.
cdef dparray call_fptr_2in_1out_new(DPNPFuncName fptr_name, utils.dpnp_descriptor x1_obj, utils.dpnp_descriptor x2_obj,
object dtype=None, dparray out=None, object where=True):
# Convert string type names (dparray.dtype) to C enum DPNPFuncType
cdef DPNPFuncType x1_c_type = dpnp_dtype_to_DPNPFuncType(x1_obj.dtype)
cdef DPNPFuncType x2_c_type = dpnp_dtype_to_DPNPFuncType(x2_obj.dtype)
Expand Down
10 changes: 5 additions & 5 deletions dpnp/dpnp_algo/dpnp_algo_bitwise.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,23 @@ __all__ += [


cpdef dparray dpnp_bitwise_and(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_BITWISE_AND, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_BITWISE_AND, x1_obj, x2_obj, dtype=dtype, out=out, where=where)


cpdef dparray dpnp_bitwise_or(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_BITWISE_OR, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_BITWISE_OR, x1_obj, x2_obj, dtype=dtype, out=out, where=where)


cpdef dparray dpnp_bitwise_xor(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_BITWISE_XOR, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_BITWISE_XOR, x1_obj, x2_obj, dtype=dtype, out=out, where=where)


cpdef dparray dpnp_invert(dparray arr):
return call_fptr_1in_1out(DPNP_FN_INVERT, arr, arr.shape)


cpdef dparray dpnp_left_shift(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_LEFT_SHIFT, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_LEFT_SHIFT, x1_obj, x2_obj, dtype=dtype, out=out, where=where)

cpdef dparray dpnp_right_shift(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_RIGHT_SHIFT, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_RIGHT_SHIFT, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
28 changes: 14 additions & 14 deletions dpnp/dpnp_algo/dpnp_algo_mathematical.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ cpdef dparray dpnp_absolute(dparray input):


cpdef dparray dpnp_add(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_ADD, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_ADD, x1_obj, x2_obj, dtype=dtype, out=out, where=where)


cpdef dparray dpnp_arctan2(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_ARCTAN2, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_ARCTAN2, x1_obj, x2_obj, dtype=dtype, out=out, where=where)


cpdef dpnp_around(dparray x1, int decimals):
Expand Down Expand Up @@ -135,11 +135,11 @@ cpdef dparray dpnp_conjugate(dparray x1):


cpdef dparray dpnp_copysign(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_COPYSIGN, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_COPYSIGN, x1_obj, x2_obj, dtype=dtype, out=out, where=where)


cpdef dparray dpnp_cross(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_CROSS, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_CROSS, x1_obj, x2_obj, dtype=dtype, out=out, where=where)


cpdef dparray dpnp_cumprod(dparray x1):
Expand Down Expand Up @@ -194,7 +194,7 @@ cpdef dparray dpnp_diff(dparray input, int n):


cpdef dparray dpnp_divide(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_DIVIDE, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_DIVIDE, x1_obj, x2_obj, dtype=dtype, out=out, where=where)


cpdef dparray dpnp_ediff1d(dparray x1):
Expand All @@ -214,11 +214,11 @@ cpdef dparray dpnp_floor(dparray x1):


cpdef dparray dpnp_floor_divide(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_FLOOR_DIVIDE, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_FLOOR_DIVIDE, x1_obj, x2_obj, dtype=dtype, out=out, where=where)


cpdef dparray dpnp_fmod(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_FMOD, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_FMOD, x1_obj, x2_obj, dtype=dtype, out=out, where=where)


cpdef dparray dpnp_gradient(dparray y1, int dx=1):
Expand All @@ -243,15 +243,15 @@ cpdef dparray dpnp_gradient(dparray y1, int dx=1):


cpdef dparray dpnp_hypot(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_HYPOT, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_HYPOT, x1_obj, x2_obj, dtype=dtype, out=out, where=where)


cpdef dparray dpnp_maximum(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_MAXIMUM, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_MAXIMUM, x1_obj, x2_obj, dtype=dtype, out=out, where=where)


cpdef dparray dpnp_minimum(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_MINIMUM, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_MINIMUM, x1_obj, x2_obj, dtype=dtype, out=out, where=where)


cpdef tuple dpnp_modf(utils.dpnp_descriptor x1):
Expand All @@ -274,7 +274,7 @@ cpdef tuple dpnp_modf(utils.dpnp_descriptor x1):


cpdef dparray dpnp_multiply(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_MULTIPLY, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_MULTIPLY, x1_obj, x2_obj, dtype=dtype, out=out, where=where)


cpdef dparray dpnp_nancumprod(dparray x1):
Expand Down Expand Up @@ -335,7 +335,7 @@ cpdef dparray dpnp_negative(dparray array1):


cpdef dparray dpnp_power(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_POWER, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_POWER, x1_obj, x2_obj, dtype=dtype, out=out, where=where)


cpdef dparray dpnp_prod(dparray input, object axis=None, object dtype=None, dparray out=None, cpp_bool keepdims=False, object initial=None, object where=True):
Expand Down Expand Up @@ -371,15 +371,15 @@ cpdef dparray dpnp_prod(dparray input, object axis=None, object dtype=None, dpar


cpdef dparray dpnp_remainder(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_REMAINDER, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_REMAINDER, x1_obj, x2_obj, dtype=dtype, out=out, where=where)


cpdef dparray dpnp_sign(dparray x1):
return call_fptr_1in_1out(DPNP_FN_SIGN, x1, x1.shape)


cpdef dparray dpnp_subtract(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
return call_fptr_2in_1out_new(DPNP_FN_SUBTRACT, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
return call_fptr_2in_1out(DPNP_FN_SUBTRACT, x1_obj, x2_obj, dtype=dtype, out=out, where=where)


cpdef dparray dpnp_sum(dparray input, object axis=None, object dtype=None, dparray out=None, cpp_bool keepdims=False, object initial=None, object where=True):
Expand Down