Skip to content

Restyle elemwise absolute kernel #115

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
32 changes: 16 additions & 16 deletions dpnp/backend/custom_kernels_mathematical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,24 @@ void custom_elemwise_absolute_c(void* array1_in, const std::vector<long>& input_
size_t* result_offset_shape = reinterpret_cast<size_t*>(dpnp_memory_alloc_c(input_shape_size * sizeof(long)));

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

if (array1[idx] >= 0)
{
result[idx] = array1[idx];
}
else
{
result[idx] = -1 * array1[idx];
}
if (array1[idx] >= 0)
{
result[idx] = array1[idx];
}
else
{
result[idx] = -1 * array1[idx];
}
};

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

event = DPNP_QUEUE.submit(kernel_func);

event.wait();

Expand Down