@@ -42,20 +42,10 @@ __all__ += [
42
42
" dpnp_expand_dims" ,
43
43
" dpnp_repeat" ,
44
44
" dpnp_reshape" ,
45
- " dpnp_transpose" ,
46
45
]
47
46
48
47
49
48
# C function pointer to the C library template functions
50
- ctypedef c_dpctl.DPCTLSyclEventRef(* fptr_custom_elemwise_transpose_1in_1out_t)(c_dpctl.DPCTLSyclQueueRef,
51
- void * ,
52
- shape_elem_type * ,
53
- shape_elem_type * ,
54
- shape_elem_type * ,
55
- size_t,
56
- void * ,
57
- size_t,
58
- const c_dpctl.DPCTLEventVectorRef)
59
49
ctypedef c_dpctl.DPCTLSyclEventRef(* fptr_dpnp_repeat_t)(c_dpctl.DPCTLSyclQueueRef,
60
50
const void * , void * , const size_t , const size_t,
61
51
const c_dpctl.DPCTLEventVectorRef)
@@ -229,67 +219,3 @@ cpdef utils.dpnp_descriptor dpnp_reshape(utils.dpnp_descriptor array1, newshape,
229
219
usm_type = array1_obj.usm_type,
230
220
sycl_queue = array1_obj.sycl_queue),
231
221
copy_when_nondefault_queue = False )
232
-
233
-
234
- cpdef utils.dpnp_descriptor dpnp_transpose(utils.dpnp_descriptor array1, axes = None ):
235
- cdef shape_type_c input_shape = array1.shape
236
- cdef size_t input_shape_size = array1.ndim
237
- cdef shape_type_c result_shape = shape_type_c(input_shape_size, 1 )
238
-
239
- cdef shape_type_c permute_axes
240
- if axes is None :
241
- """
242
- template to do transpose a tensor
243
- input_shape=[2, 3, 4]
244
- permute_axes=[2, 1, 0]
245
- after application `permute_axes` to `input_shape` result:
246
- result_shape=[4, 3, 2]
247
-
248
- 'do nothing' axes variable is `permute_axes=[0, 1, 2]`
249
-
250
- test: pytest tests/third_party/cupy/manipulation_tests/test_transpose.py::TestTranspose::test_external_transpose_all
251
- """
252
- permute_axes = list (reversed ([i for i in range (input_shape_size)]))
253
- else :
254
- permute_axes = utils.normalize_axis(axes, input_shape_size)
255
-
256
- for i in range (input_shape_size):
257
- """ construct output shape """
258
- result_shape[i] = input_shape[permute_axes[i]]
259
-
260
- # convert string type names (array.dtype) to C enum DPNPFuncType
261
- cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(array1.dtype)
262
-
263
- # get the FPTR data structure
264
- cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_TRANSPOSE_EXT, param1_type, param1_type)
265
-
266
- array1_obj = array1.get_array()
267
-
268
- # ceate result array with type given by FPTR data
269
- cdef utils.dpnp_descriptor result = utils.create_output_descriptor(result_shape,
270
- kernel_data.return_type,
271
- None ,
272
- device = array1_obj.sycl_device,
273
- usm_type = array1_obj.usm_type,
274
- sycl_queue = array1_obj.sycl_queue)
275
- result_sycl_queue = result.get_array().sycl_queue
276
-
277
- cdef c_dpctl.SyclQueue q = < c_dpctl.SyclQueue> result_sycl_queue
278
- cdef c_dpctl.DPCTLSyclQueueRef q_ref = q.get_queue_ref()
279
-
280
- cdef fptr_custom_elemwise_transpose_1in_1out_t func = < fptr_custom_elemwise_transpose_1in_1out_t > kernel_data.ptr
281
- # call FPTR function
282
- cdef c_dpctl.DPCTLSyclEventRef event_ref = func(q_ref,
283
- array1.get_data(),
284
- input_shape.data(),
285
- result_shape.data(),
286
- permute_axes.data(),
287
- input_shape_size,
288
- result.get_data(),
289
- array1.size,
290
- NULL ) # dep_events_ref
291
-
292
- with nogil: c_dpctl.DPCTLEvent_WaitAndThrow(event_ref)
293
- c_dpctl.DPCTLEvent_Delete(event_ref)
294
-
295
- return result
0 commit comments