Skip to content

Commit 8bf5ec6

Browse files
authored
Restyle elemwise absolute kernel (#115)
1 parent eb307cc commit 8bf5ec6

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

dpnp/backend/custom_kernels_mathematical.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,24 @@ void custom_elemwise_absolute_c(void* array1_in, const std::vector<long>& input_
5252
size_t* result_offset_shape = reinterpret_cast<size_t*>(dpnp_memory_alloc_c(input_shape_size * sizeof(long)));
5353

5454
cl::sycl::range<1> gws(size);
55-
event = DPNP_QUEUE.submit([&](cl::sycl::handler& cgh) {
56-
cgh.parallel_for<class custom_elemwise_absolute_c_kernel<_DataType> >(
57-
gws,
58-
[=](cl::sycl::id<1> global_id)
59-
{
60-
const size_t idx = global_id[0];
55+
auto kernel_parallel_for_func = [=](cl::sycl::id<1> global_id) {
56+
const size_t idx = global_id[0];
6157

62-
if (array1[idx] >= 0)
63-
{
64-
result[idx] = array1[idx];
65-
}
66-
else
67-
{
68-
result[idx] = -1 * array1[idx];
69-
}
58+
if (array1[idx] >= 0)
59+
{
60+
result[idx] = array1[idx];
61+
}
62+
else
63+
{
64+
result[idx] = -1 * array1[idx];
65+
}
66+
};
7067

71-
}); // parallel_for
72-
}); // queue.submit
68+
auto kernel_func = [&](cl::sycl::handler& cgh) {
69+
cgh.parallel_for<class custom_elemwise_absolute_c_kernel<_DataType> >(gws, kernel_parallel_for_func);
70+
};
71+
72+
event = DPNP_QUEUE.submit(kernel_func);
7373

7474
event.wait();
7575

0 commit comments

Comments
 (0)