Skip to content

Commit eb307cc

Browse files
authored
Restyle transpose kernel (#114)
1 parent daec5c2 commit eb307cc

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

dpnp/backend/custom_kernels_manipulation.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -73,29 +73,29 @@ void custom_elemwise_transpose_c(void* array1_in,
7373
}
7474

7575
cl::sycl::range<1> gws(size);
76-
event = DPNP_QUEUE.submit([&](cl::sycl::handler& cgh) {
77-
cgh.parallel_for<class custom_elemwise_transpose_c_kernel<_DataType> >(
78-
gws,
79-
[=](cl::sycl::id<1> global_id)
80-
{
81-
const size_t idx = global_id[0];
82-
83-
size_t output_index = 0;
84-
size_t reminder = idx;
85-
for (size_t axis = 0; axis < input_shape_size; ++axis)
86-
{
87-
/* reconstruct [x][y][z] from given linear idx */
88-
size_t xyz_id = reminder / input_offset_shape[axis];
89-
reminder = reminder % input_offset_shape[axis];
90-
91-
/* calculate destination index based on reconstructed [x][y][z] */
92-
output_index += (xyz_id * result_offset_shape[axis]);
93-
}
94-
95-
result[output_index] = array1[idx];
96-
97-
}); // parallel_for
98-
}); // queue.submit
76+
auto kernel_parallel_for_func = [=](cl::sycl::id<1> global_id) {
77+
const size_t idx = global_id[0];
78+
79+
size_t output_index = 0;
80+
size_t reminder = idx;
81+
for (size_t axis = 0; axis < input_shape_size; ++axis)
82+
{
83+
/* reconstruct [x][y][z] from given linear idx */
84+
size_t xyz_id = reminder / input_offset_shape[axis];
85+
reminder = reminder % input_offset_shape[axis];
86+
87+
/* calculate destination index based on reconstructed [x][y][z] */
88+
output_index += (xyz_id * result_offset_shape[axis]);
89+
}
90+
91+
result[output_index] = array1[idx];
92+
};
93+
94+
auto kernel_func = [&](cl::sycl::handler& cgh) {
95+
cgh.parallel_for<class custom_elemwise_transpose_c_kernel<_DataType> >(gws, kernel_parallel_for_func);
96+
};
97+
98+
event = DPNP_QUEUE.submit(kernel_func);
9999

100100
event.wait();
101101

0 commit comments

Comments
 (0)