@@ -98,7 +98,7 @@ cpdef utils.dpnp_descriptor dpnp_diag(utils.dpnp_descriptor v, int k):
98
98
99
99
100
100
cpdef utils.dpnp_descriptor dpnp_full(result_shape, value_in, result_dtype):
101
- # Convert string type names (dparray .dtype) to C enum DPNPFuncType
101
+ # Convert string type names (array .dtype) to C enum DPNPFuncType
102
102
cdef DPNPFuncType dtype_in = dpnp_dtype_to_DPNPFuncType(result_dtype)
103
103
104
104
# get the FPTR data structure
@@ -121,7 +121,7 @@ cpdef utils.dpnp_descriptor dpnp_full(result_shape, value_in, result_dtype):
121
121
122
122
123
123
cpdef utils.dpnp_descriptor dpnp_full_like(result_shape, value_in, result_dtype):
124
- # Convert string type names (dparray .dtype) to C enum DPNPFuncType
124
+ # Convert string type names (array .dtype) to C enum DPNPFuncType
125
125
cdef DPNPFuncType dtype_in = dpnp_dtype_to_DPNPFuncType(result_dtype)
126
126
127
127
# get the FPTR data structure
@@ -143,8 +143,9 @@ cpdef utils.dpnp_descriptor dpnp_full_like(result_shape, value_in, result_dtype)
143
143
return result
144
144
145
145
146
- cpdef dparray dpnp_geomspace(start, stop, num, endpoint, dtype, axis):
147
- cdef dparray result = dparray(num, dtype = dtype)
146
+ cpdef utils.dpnp_descriptor dpnp_geomspace(start, stop, num, endpoint, dtype, axis):
147
+ cdef shape_type_c obj_shape = utils._object_to_tuple(num)
148
+ cdef utils.dpnp_descriptor result = utils_py.create_output_descriptor_py(obj_shape, dtype, None )
148
149
149
150
if endpoint:
150
151
steps_count = num - 1
@@ -156,28 +157,27 @@ cpdef dparray dpnp_geomspace(start, stop, num, endpoint, dtype, axis):
156
157
step = dpnp.power(dpnp.float64(stop) / start, 1.0 / steps_count)
157
158
mult = step
158
159
for i in range (1 , result.size):
159
- result[i] = start * mult
160
+ result.get_pyobj() [i] = start * mult
160
161
mult = mult * step
161
162
else :
162
163
step = dpnp.nan
163
164
164
165
# if result is not empty, then fiil first and last elements
165
166
if num > 0 :
166
- result[0 ] = start
167
+ result.get_pyobj() [0 ] = start
167
168
if endpoint and result.size > 1 :
168
- result[result.size - 1 ] = stop
169
+ result.get_pyobj() [result.size - 1 ] = stop
169
170
170
171
return result
171
172
172
173
173
- cpdef dparray dpnp_identity(n, result_dtype):
174
+ cpdef utils.dpnp_descriptor dpnp_identity(n, result_dtype):
174
175
cdef DPNPFuncType dtype_in = dpnp_dtype_to_DPNPFuncType(result_dtype)
175
176
176
177
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_IDENTITY, dtype_in, DPNP_FT_NONE)
177
178
178
- result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
179
-
180
- cdef dparray result = dparray((n, n), dtype = result_type)
179
+ cdef shape_type_c shape_in = (n, n)
180
+ cdef utils.dpnp_descriptor result = utils.create_output_descriptor(shape_in, kernel_data.return_type, None )
181
181
182
182
cdef fptr_1out_t func = < fptr_1out_t > kernel_data.ptr
183
183
func(result.get_data(), n)
@@ -187,7 +187,8 @@ cpdef dparray dpnp_identity(n, result_dtype):
187
187
188
188
# TODO this function should work through dpnp_arange_c
189
189
cpdef tuple dpnp_linspace(start, stop, num, endpoint, retstep, dtype, axis):
190
- cdef dparray result = dparray(num, dtype = dtype)
190
+ cdef shape_type_c obj_shape = utils._object_to_tuple(num)
191
+ cdef utils.dpnp_descriptor result = utils_py.create_output_descriptor_py(obj_shape, dtype, None )
191
192
192
193
if endpoint:
193
194
steps_count = num - 1
@@ -198,20 +199,20 @@ cpdef tuple dpnp_linspace(start, stop, num, endpoint, retstep, dtype, axis):
198
199
if steps_count > 0 :
199
200
step = (dpnp.float64(stop) - start) / steps_count
200
201
for i in range (1 , result.size):
201
- result[i] = start + step * i
202
+ result.get_pyobj() [i] = start + step * i
202
203
else :
203
204
step = dpnp.nan
204
205
205
206
# if result is not empty, then fiil first and last elements
206
207
if num > 0 :
207
- result[0 ] = start
208
+ result.get_pyobj() [0 ] = start
208
209
if endpoint and result.size > 1 :
209
- result[result.size - 1 ] = stop
210
+ result.get_pyobj() [result.size - 1 ] = stop
210
211
211
- return (result, step)
212
+ return (result.get_pyobj() , step)
212
213
213
214
214
- cpdef dparray dpnp_logspace(start, stop, num, endpoint, base, dtype, axis):
215
+ cpdef object dpnp_logspace(start, stop, num, endpoint, base, dtype, axis):
215
216
temp = dpnp.linspace(start, stop, num = num, endpoint = endpoint)
216
217
return dpnp.power(base, temp).astype(dtype)
217
218
@@ -278,7 +279,7 @@ cpdef utils.dpnp_descriptor dpnp_trace(utils.dpnp_descriptor arr, offset=0, axis
278
279
else :
279
280
dtype_ = dtype
280
281
281
- cdef dparray diagonal_arr = dpnp.diagonal (arr, offset, axis1, axis2 )
282
+ cdef utils.dpnp_descriptor diagonal_arr = dpnp_diagonal (arr, offset)
282
283
cdef size_t diagonal_ndim = diagonal_arr.ndim
283
284
cdef shape_type_c diagonal_shape = diagonal_arr.shape
284
285
@@ -298,22 +299,19 @@ cpdef utils.dpnp_descriptor dpnp_trace(utils.dpnp_descriptor arr, offset=0, axis
298
299
return result
299
300
300
301
301
- cpdef dparray dpnp_tri(N, M = None , k = 0 , dtype = numpy.float):
302
+ cpdef utils.dpnp_descriptor dpnp_tri(N, M = None , k = 0 , dtype = numpy.float):
302
303
if M is None :
303
304
M = N
304
305
305
306
if dtype == numpy.float:
306
307
dtype = numpy.float64
307
308
308
- cdef dparray result
309
-
310
309
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
311
310
312
311
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_TRI, param1_type, param1_type)
313
312
314
- result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
315
-
316
- result = dparray(shape = (N, M), dtype = result_type)
313
+ cdef shape_type_c shape_in = (N, M)
314
+ cdef utils.dpnp_descriptor result = utils.create_output_descriptor(shape_in, kernel_data.return_type, None )
317
315
318
316
cdef custom_indexing_1out_func_ptr_t func = < custom_indexing_1out_func_ptr_t > kernel_data.ptr
319
317
0 commit comments