Skip to content

Restyle transpose kernel #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 5, 2020
Merged
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
46 changes: 23 additions & 23 deletions dpnp/backend/custom_kernels_manipulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,29 @@ void custom_elemwise_transpose_c(void* array1_in,
}

cl::sycl::range<1> gws(size);
event = DPNP_QUEUE.submit([&](cl::sycl::handler& cgh) {
cgh.parallel_for<class custom_elemwise_transpose_c_kernel<_DataType> >(
gws,
[=](cl::sycl::id<1> global_id)
{
const size_t idx = global_id[0];

size_t output_index = 0;
size_t reminder = idx;
for (size_t axis = 0; axis < input_shape_size; ++axis)
{
/* reconstruct [x][y][z] from given linear idx */
size_t xyz_id = reminder / input_offset_shape[axis];
reminder = reminder % input_offset_shape[axis];

/* calculate destination index based on reconstructed [x][y][z] */
output_index += (xyz_id * result_offset_shape[axis]);
}

result[output_index] = array1[idx];

}); // parallel_for
}); // queue.submit
auto kernel_parallel_for_func = [=](cl::sycl::id<1> global_id) {
const size_t idx = global_id[0];

size_t output_index = 0;
size_t reminder = idx;
for (size_t axis = 0; axis < input_shape_size; ++axis)
{
/* reconstruct [x][y][z] from given linear idx */
size_t xyz_id = reminder / input_offset_shape[axis];
reminder = reminder % input_offset_shape[axis];

/* calculate destination index based on reconstructed [x][y][z] */
output_index += (xyz_id * result_offset_shape[axis]);
}

result[output_index] = array1[idx];
};

auto kernel_func = [&](cl::sycl::handler& cgh) {
cgh.parallel_for<class custom_elemwise_transpose_c_kernel<_DataType> >(gws, kernel_parallel_for_func);
};

event = DPNP_QUEUE.submit(kernel_func);

event.wait();

Expand Down