@@ -36,7 +36,6 @@ and the rest of the library
36
36
# NO IMPORTs here. All imports must be placed into main "dpnp_algo.pyx" file
37
37
38
38
__all__ += [
39
- " dpnp_inner" ,
40
39
" dpnp_kron" ,
41
40
]
42
41
@@ -48,80 +47,6 @@ ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_2in_1out_shapes_t)(c_dpctl.DPCTLSyclQue
48
47
const c_dpctl.DPCTLEventVectorRef)
49
48
50
49
51
- cpdef utils.dpnp_descriptor dpnp_inner(dpnp_descriptor array1, dpnp_descriptor array2):
52
- result_type = numpy.promote_types(array1.dtype, array1.dtype)
53
-
54
- assert (len (array1.shape) == len (array2.shape))
55
-
56
- cdef shape_type_c array1_no_last_axes = array1.shape[:- 1 ]
57
- cdef shape_type_c array2_no_last_axes = array2.shape[:- 1 ]
58
-
59
- cdef shape_type_c result_shape = array1_no_last_axes
60
- result_shape.insert(result_shape.end(), array2_no_last_axes.begin(), array2_no_last_axes.end())
61
-
62
- result_sycl_device, result_usm_type, result_sycl_queue = utils.get_common_usm_allocation(array1, array2)
63
-
64
- # create result array with type given by FPTR data
65
- cdef utils.dpnp_descriptor result = utils_py.create_output_descriptor_py(result_shape,
66
- result_type,
67
- None ,
68
- device = result_sycl_device,
69
- usm_type = result_usm_type,
70
- sycl_queue = result_sycl_queue)
71
-
72
- # calculate input arrays offsets
73
- cdef shape_type_c array1_offsets = [1 ] * len (array1.shape)
74
- cdef shape_type_c array2_offsets = [1 ] * len (array2.shape)
75
- cdef size_t acc1 = 1
76
- cdef size_t acc2 = 1
77
- for axis in range (len (array1.shape) - 1 , - 1 , - 1 ):
78
- array1_offsets[axis] = acc1
79
- array2_offsets[axis] = acc2
80
- acc1 *= array1.shape[axis]
81
- acc2 *= array2.shape[axis]
82
-
83
- cdef shape_type_c result_shape_offsets = [1 ] * len (result.shape)
84
- acc = 1
85
- for i in range (len (result.shape) - 1 , - 1 , - 1 ):
86
- result_shape_offsets[i] = acc
87
- acc *= result.shape[i]
88
-
89
- cdef shape_type_c xyz
90
- cdef size_t array1_lin_index_base
91
- cdef size_t array2_lin_index_base
92
- cdef size_t axis2
93
- cdef long remainder
94
- cdef long quotient
95
-
96
- result_flatiter = result.get_pyobj().flat
97
- array1_flatiter = array1.get_pyobj().flat
98
- array2_flatiter = array2.get_pyobj().flat
99
-
100
- for idx1 in range (result.size):
101
- # reconstruct x,y,z from linear index
102
- xyz.clear()
103
- remainder = idx1
104
- for i in result_shape_offsets:
105
- quotient, remainder = divmod (remainder, i)
106
- xyz.push_back(quotient)
107
-
108
- # calculate linear base input index
109
- array1_lin_index_base = 0
110
- array2_lin_index_base = 0
111
- for axis in range (len (array1_offsets) - 1 ):
112
- axis2 = axis + (len (xyz) / 2 )
113
- array1_lin_index_base += array1_offsets[axis] * xyz[axis]
114
- array2_lin_index_base += array2_offsets[axis] * xyz[axis2]
115
-
116
- # do inner product
117
- result_flatiter[idx1] = 0
118
- for idx2 in range (array1.shape[- 1 ]):
119
- result_flatiter[idx1] += array1_flatiter[array1_lin_index_base + idx2] * \
120
- array2_flatiter[array2_lin_index_base + idx2]
121
-
122
- return result
123
-
124
-
125
50
cpdef utils.dpnp_descriptor dpnp_kron(dpnp_descriptor in_array1, dpnp_descriptor in_array2):
126
51
cdef size_t ndim = max (in_array1.ndim, in_array2.ndim)
127
52
0 commit comments