Skip to content

Commit ab92db7

Browse files
authored
style19JUN2021 (#732)
1 parent de3ba00 commit ab92db7

19 files changed

+106
-112
lines changed

dpnp/backend/include/dpnp_iface.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,9 @@ INP_DLLEXPORT void dpnp_argsort_c(void* array, void* result, size_t size);
467467
* @param [in] arr_size Number of elements in input arrays.
468468
* @param [in] v_size Number of elements in input values arrays.
469469
*/
470-
template<typename _DataType, typename _IndexingType>
471-
INP_DLLEXPORT void dpnp_searchsorted_c(void* result, const void* array, const void* v, bool side, const size_t arr_size, const size_t v_size);
470+
template <typename _DataType, typename _IndexingType>
471+
INP_DLLEXPORT void dpnp_searchsorted_c(
472+
void* result, const void* array, const void* v, bool side, const size_t arr_size, const size_t v_size);
472473

473474
/**
474475
* @ingroup BACKEND_API
@@ -713,10 +714,7 @@ INP_DLLEXPORT void dpnp_argmin_c(void* array, void* result, size_t size);
713714
* @param [in] decimals Number of decimal places to round. Support only with default value 0.
714715
*/
715716
template <typename _DataType>
716-
INP_DLLEXPORT void dpnp_around_c(const void* input_in,
717-
void* result_out,
718-
const size_t input_size,
719-
const int decimals);
717+
INP_DLLEXPORT void dpnp_around_c(const void* input_in, void* result_out, const size_t input_size, const int decimals);
720718

721719
/**
722720
* @ingroup BACKEND_API

dpnp/backend/kernels/dpnp_krnl_mathematical.cpp

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ template <typename _KernelNameSpecialization>
3737
class dpnp_around_c_kernel;
3838

3939
template <typename _DataType>
40-
void dpnp_around_c(const void* input_in,
41-
void* result_out,
42-
const size_t input_size,
43-
const int decimals)
40+
void dpnp_around_c(const void* input_in, void* result_out, const size_t input_size, const int decimals)
4441
{
4542
(void)decimals;
4643

@@ -53,7 +50,7 @@ void dpnp_around_c(const void* input_in,
5350
_DataType* input = reinterpret_cast<_DataType*>(const_cast<void*>(input_in));
5451
_DataType* result = reinterpret_cast<_DataType*>(result_out);
5552

56-
if constexpr(std::is_same<_DataType, double>::value || std::is_same<_DataType, float>::value)
53+
if constexpr (std::is_same<_DataType, double>::value || std::is_same<_DataType, float>::value)
5754
{
5855
event = oneapi::mkl::vm::rint(DPNP_QUEUE, input_size, input, result);
5956
}
@@ -68,8 +65,7 @@ void dpnp_around_c(const void* input_in,
6865
};
6966

7067
auto kernel_func = [&](cl::sycl::handler& cgh) {
71-
cgh.parallel_for<class dpnp_around_c_kernel<_DataType>>(
72-
gws, kernel_parallel_for_func);
68+
cgh.parallel_for<class dpnp_around_c_kernel<_DataType>>(gws, kernel_parallel_for_func);
7369
};
7470

7571
event = DPNP_QUEUE.submit(kernel_func);
@@ -238,8 +234,8 @@ void dpnp_floor_divide_c(void* result_out,
238234
_DataType_input2* input2_data = reinterpret_cast<_DataType_input2*>(const_cast<void*>(input2_in));
239235
_DataType_output* result = reinterpret_cast<_DataType_output*>(result_out);
240236

241-
std::vector<size_t> result_shape = get_result_shape(input1_shape, input1_shape_ndim,
242-
input2_shape, input2_shape_ndim);
237+
std::vector<size_t> result_shape =
238+
get_result_shape(input1_shape, input1_shape_ndim, input2_shape, input2_shape_ndim);
243239

244240
DPNPC_id<_DataType_input1>* input1_it;
245241
const size_t input1_it_size_in_bytes = sizeof(DPNPC_id<_DataType_input1>);
@@ -254,11 +250,10 @@ void dpnp_floor_divide_c(void* result_out,
254250
new (input2_it) DPNPC_id<_DataType_input2>(input2_data, input2_shape, input2_shape_ndim);
255251

256252
input2_it->broadcast_to_shape(result_shape);
257-
258-
const size_t result_size = input1_it->get_output_size();
259253

254+
const size_t result_size = input1_it->get_output_size();
260255

261-
cl::sycl::range<1> gws(result_size);
256+
cl::sycl::range<1> gws(result_size);
262257
auto kernel_parallel_for_func = [=](cl::sycl::id<1> global_id) {
263258
const size_t i = global_id[0]; /* for (size_t i = 0; i < result_size; ++i) */
264259
const _DataType_output input1_elem = (*input1_it)[i];
@@ -276,9 +271,8 @@ void dpnp_floor_divide_c(void* result_out,
276271

277272
if (input1_size == input2_size)
278273
{
279-
if constexpr ((std::is_same<_DataType_input1, double>::value ||
280-
std::is_same<_DataType_input1, float>::value) &&
281-
std::is_same<_DataType_input2, _DataType_input1>::value)
274+
if constexpr ((std::is_same<_DataType_input1, double>::value || std::is_same<_DataType_input1, float>::value) &&
275+
std::is_same<_DataType_input2, _DataType_input1>::value)
282276
{
283277
event = oneapi::mkl::vm::div(DPNP_QUEUE, input1_size, input1_data, input2_data, result);
284278
event.wait();
@@ -298,7 +292,6 @@ void dpnp_floor_divide_c(void* result_out,
298292

299293
input1_it->~DPNPC_id();
300294
input2_it->~DPNPC_id();
301-
302295
}
303296

304297
template <typename _KernelNameSpecialization1, typename _KernelNameSpecialization2>

dpnp/backend/kernels/dpnp_krnl_random.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,10 @@ void dpnp_rng_noncentral_chisquare_c(void* result, const _DataType df, const _Da
632632
auto event_gaussian_distr = mkl_rng::generate(gaussian_distribution, DPNP_RNG_ENGINE, size, nvec);
633633

634634
/* squaring could result in an overflow */
635-
auto event_sqr_out = mkl_vm::sqr(DPNP_QUEUE, size, nvec, nvec, {event_gamma_distr, event_gaussian_distr}, mkl_vm::mode::ha);
636-
auto event_add_out = mkl_vm::add(DPNP_QUEUE, size, result1, nvec, result1, {event_sqr_out}, mkl_vm::mode::ha);
635+
auto event_sqr_out =
636+
mkl_vm::sqr(DPNP_QUEUE, size, nvec, nvec, {event_gamma_distr, event_gaussian_distr}, mkl_vm::mode::ha);
637+
auto event_add_out =
638+
mkl_vm::add(DPNP_QUEUE, size, result1, nvec, result1, {event_sqr_out}, mkl_vm::mode::ha);
637639
dpnp_memory_free_c(nvec);
638640
event_add_out.wait();
639641
}

dpnp/backend/kernels/dpnp_krnl_sorting.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,12 @@ void dpnp_partition_c(
175175
dpnp_memory_free_c(shape);
176176
}
177177

178-
template<typename _DataType, typename _IndexingType>
178+
template <typename _DataType, typename _IndexingType>
179179
class dpnp_searchsorted_c_kernel;
180180

181-
template<typename _DataType, typename _IndexingType>
182-
void dpnp_searchsorted_c(void* result1, const void* array1_in, const void* v1_in, bool side, const size_t arr_size, const size_t v_size)
181+
template <typename _DataType, typename _IndexingType>
182+
void dpnp_searchsorted_c(
183+
void* result1, const void* array1_in, const void* v1_in, bool side, const size_t arr_size, const size_t v_size)
183184
{
184185
const _DataType* arr = reinterpret_cast<const _DataType*>(array1_in);
185186
const _DataType* v = reinterpret_cast<const _DataType*>(v1_in);
@@ -209,7 +210,7 @@ void dpnp_searchsorted_c(void* result1, const void* array1_in, const void* v1_in
209210
{
210211
if (side)
211212
{
212-
if (j == arr_size-1)
213+
if (j == arr_size - 1)
213214
{
214215
if (v[i] == arr[j])
215216
{
@@ -225,7 +226,7 @@ void dpnp_searchsorted_c(void* result1, const void* array1_in, const void* v1_in
225226
}
226227
else
227228
{
228-
if ((arr[j-1] < v[i]) && (v[i] <= arr[j]))
229+
if ((arr[j - 1] < v[i]) && (v[i] <= arr[j]))
229230
{
230231
result[i] = j;
231232
}
@@ -235,7 +236,7 @@ void dpnp_searchsorted_c(void* result1, const void* array1_in, const void* v1_in
235236
{
236237
if (j == arr_size - 1)
237238
{
238-
if ((arr[j-1] <= v[i]) && (v[i] < arr[j]))
239+
if ((arr[j - 1] <= v[i]) && (v[i] < arr[j]))
239240
{
240241
result[i] = arr_size - 1;
241242
}
@@ -256,7 +257,7 @@ void dpnp_searchsorted_c(void* result1, const void* array1_in, const void* v1_in
256257
}
257258
else
258259
{
259-
if ((arr[j-1] <= v[i]) && (v[i] < arr[j]))
260+
if ((arr[j - 1] <= v[i]) && (v[i] < arr[j]))
260261
{
261262
result[i] = j;
262263
}

dpnp/backend/src/dpnp_iterator.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,8 @@ class DPNPC_id final
481481
{
482482
if (std::find(axes.begin(), axes.end(), iit) == axes.end())
483483
{
484-
const size_type output_xyz_id = get_xyz_id_by_id_inkernel(output_global_id, output_shape_strides,
485-
output_shape_size, oit);
484+
const size_type output_xyz_id =
485+
get_xyz_id_by_id_inkernel(output_global_id, output_shape_strides, output_shape_size, oit);
486486
input_global_id += (output_xyz_id * input_shape_strides[iit]);
487487
++oit;
488488
}
@@ -498,8 +498,8 @@ class DPNPC_id final
498498
size_type* broadcast_axes_end = broadcast_axes + broadcast_axes_size;
499499
if (std::find(broadcast_axes, broadcast_axes_end, orit) == broadcast_axes_end)
500500
{
501-
const size_type output_xyz_id = get_xyz_id_by_id_inkernel(output_global_id, output_shape_strides,
502-
output_shape_size, orit);
501+
const size_type output_xyz_id =
502+
get_xyz_id_by_id_inkernel(output_global_id, output_shape_strides, output_shape_size, orit);
503503
input_global_id += (output_xyz_id * input_shape_strides[irit]);
504504
}
505505
}

dpnp/backend/src/dpnp_utils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#ifndef BACKEND_UTILS_H // Cython compatibility
2828
#define BACKEND_UTILS_H
2929

30-
#include <cassert>
3130
#include <algorithm>
31+
#include <cassert>
3232
#include <iostream>
3333
#include <iterator>
3434

dpnp/dpnp_algo/dpnp_algo.pxd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ cdef extern from "dpnp_iface.hpp":
222222

223223
# C function pointer to the C library template functions
224224
ctypedef void(*fptr_1out_t)(void *, size_t)
225-
ctypedef void(*fptr_1in_1out_t)(void *, void *, size_t)
226-
ctypedef void(*fptr_2in_1out_t)(void *, const void *, const size_t, const long *, const size_t,
227-
const void *, const size_t, const long *, const size_t, const long *)
225+
ctypedef void(*fptr_1in_1out_t)(void * , void * , size_t)
226+
ctypedef void(*fptr_2in_1out_t)(void *, const void * , const size_t, const long * , const size_t,
227+
const void * , const size_t, const long * , const size_t, const long * )
228228
ctypedef void(*fptr_blas_gemm_2in_1out_t)(void * , void * , void * , size_t, size_t, size_t)
229229
ctypedef void(*dpnp_reduction_c_t)(void * , const void * , const size_t*, const size_t, const long*, const size_t, const void * , const long*)
230230

dpnp/dpnp_algo/dpnp_algo.pyx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ include "dpnp_algo_statistics.pyx"
6969
include "dpnp_algo_trigonometric.pyx"
7070

7171

72-
ctypedef void(*fptr_dpnp_arange_t)(size_t, size_t, void *, size_t)
73-
ctypedef void(*fptr_dpnp_astype_t)(const void *, void * , const size_t)
74-
ctypedef void(*fptr_dpnp_flatten_t)(const void *, void * , const size_t)
75-
ctypedef void(*fptr_dpnp_initval_t)(void *, void * , size_t)
72+
ctypedef void(*fptr_dpnp_arange_t)(size_t, size_t, void * , size_t)
73+
ctypedef void(*fptr_dpnp_astype_t)(const void * , void * , const size_t)
74+
ctypedef void(*fptr_dpnp_flatten_t)(const void * , void * , const size_t)
75+
ctypedef void(*fptr_dpnp_initval_t)(void * , void * , size_t)
7676

7777

7878
cpdef dparray dpnp_arange(start, stop, step, dtype):
@@ -87,7 +87,7 @@ cpdef dparray dpnp_arange(start, stop, step, dtype):
8787
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
8888
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_ARANGE, param1_type, param1_type)
8989

90-
result_type = dpnp_DPNPFuncType_to_dtype( < size_t > kernel_data.return_type)
90+
result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
9191
cdef dparray result = dparray(obj_len, dtype=result_type)
9292

9393
# for i in range(result.size):
@@ -133,7 +133,7 @@ cpdef dparray dpnp_astype(dparray array1, dtype_target):
133133

134134
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_ASTYPE, param1_type, param2_type)
135135

136-
result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
136+
result_type = dpnp_DPNPFuncType_to_dtype( < size_t > kernel_data.return_type)
137137
cdef dparray result = dparray(array1.shape, dtype=result_type)
138138

139139
cdef fptr_dpnp_astype_t func = <fptr_dpnp_astype_t > kernel_data.ptr
@@ -147,7 +147,7 @@ cpdef dparray dpnp_flatten(dparray array_):
147147

148148
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_FLATTEN, param1_type, param1_type)
149149

150-
result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
150+
result_type = dpnp_DPNPFuncType_to_dtype( < size_t > kernel_data.return_type)
151151
cdef dparray result = dparray(array_.size, dtype=result_type)
152152

153153
cdef fptr_dpnp_flatten_t func = <fptr_dpnp_flatten_t > kernel_data.ptr
@@ -161,7 +161,7 @@ cpdef dparray dpnp_init_val(shape, dtype, value):
161161

162162
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_INITVAL, param1_type, param1_type)
163163

164-
result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
164+
result_type = dpnp_DPNPFuncType_to_dtype( < size_t > kernel_data.return_type)
165165
cdef dparray result = dparray(shape, dtype=dtype)
166166

167167
# TODO: find better way to pass single value with type conversion
@@ -234,7 +234,7 @@ cpdef dparray dpnp_matmul(dparray in_array1, dparray in_array2):
234234
# get the FPTR data structure
235235
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_MATMUL, param1_type, param2_type)
236236

237-
result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
237+
result_type = dpnp_DPNPFuncType_to_dtype( < size_t > kernel_data.return_type)
238238
# ceate result array with type given by FPTR data
239239
cdef dparray result = dparray(shape_result, dtype=result_type)
240240
if result.size == 0:
@@ -322,7 +322,7 @@ cdef dparray call_fptr_1out(DPNPFuncName fptr_name, result_shape, result_dtype):
322322
# get the FPTR data structure
323323
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(fptr_name, dtype_in, dtype_in)
324324

325-
result_type = dpnp_DPNPFuncType_to_dtype( < size_t > kernel_data.return_type)
325+
result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
326326

327327
# Create result array with type given by FPTR data
328328
cdef dparray result = dparray(result_shape, dtype=result_type)
@@ -342,7 +342,7 @@ cdef dparray call_fptr_1in_1out(DPNPFuncName fptr_name, dparray x1, dparray_shap
342342
""" get the FPTR data structure """
343343
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(fptr_name, param1_type, param1_type)
344344

345-
result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
345+
result_type = dpnp_DPNPFuncType_to_dtype( < size_t > kernel_data.return_type)
346346
""" Create result array with type given by FPTR data """
347347
cdef dparray result = dparray(result_shape, dtype=result_type)
348348

@@ -395,6 +395,6 @@ cdef dparray call_fptr_2in_1out(DPNPFuncName fptr_name, object x1_obj, object x2
395395
""" Call FPTR function """
396396
cdef fptr_2in_1out_t func = <fptr_2in_1out_t > kernel_data.ptr
397397
func(result.get_data(), x1_dparray.get_data(), x1_dparray.size, x1_shape.data(), x1_shape.size(),
398-
x2_dparray.get_data(), x2_dparray.size, x2_shape.data(), x2_shape.size(), NULL)
398+
x2_dparray.get_data(), x2_dparray.size, x2_shape.data(), x2_shape.size(), NULL)
399399

400400
return result

dpnp/dpnp_algo/dpnp_algo_arraycreation.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ __all__ += [
6363

6464

6565
ctypedef void(*custom_1in_1out_func_ptr_t)(void *, void * , const int , size_t * , size_t * , const size_t, const size_t)
66-
ctypedef void(*ftpr_custom_vander_1in_1out_t)(void *, void *, size_t, size_t, int)
66+
ctypedef void(*ftpr_custom_vander_1in_1out_t)(void * , void * , size_t, size_t, int)
6767
ctypedef void(*custom_indexing_1out_func_ptr_t)(void * , const size_t , const size_t , const int)
6868
ctypedef void(*fptr_dpnp_trace_t)(const void *, void * , const size_t * , const size_t)
6969

dpnp/dpnp_algo/dpnp_algo_linearalgebra.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ __all__ += [
4545

4646

4747
# C function pointer to the C library template functions
48-
ctypedef void(*fptr_2in_1out_shapes_t)(void * , void * , void * , size_t * , size_t * , size_t * , size_t)
48+
ctypedef void(*fptr_2in_1out_shapes_t)(void *, void * , void * , size_t * , size_t * , size_t * , size_t)
4949

5050

5151
cpdef dparray dpnp_dot(dparray in_array1, dparray in_array2):
@@ -85,14 +85,14 @@ cpdef dparray dpnp_dot(dparray in_array1, dparray in_array2):
8585
# get the FPTR data structure
8686
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_DOT, param1_type, param2_type)
8787

88-
result_type = dpnp_DPNPFuncType_to_dtype( < size_t > kernel_data.return_type)
88+
result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
8989
# ceate result array with type given by FPTR data
9090
cdef dparray result = dparray((1,), dtype=result_type)
9191

9292
cdef fptr_2in_1out_t func = <fptr_2in_1out_t > kernel_data.ptr
9393
# call FPTR function
9494
func(result.get_data(), in_array1.get_data(), in_array1.size, shape1.data(), shape1.size(),
95-
in_array2.get_data(), in_array2.size, shape2.data(), shape2.size(), NULL)
95+
in_array2.get_data(), in_array2.size, shape2.data(), shape2.size(), NULL)
9696

9797
return result
9898

@@ -185,7 +185,7 @@ cpdef dparray dpnp_kron(dparray in_array1, dparray in_array2):
185185
# get the FPTR data structure
186186
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_KRON, param1_type, param2_type)
187187

188-
result_type = dpnp_DPNPFuncType_to_dtype( < size_t > kernel_data.return_type)
188+
result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
189189
# ceate result array with type given by FPTR data
190190
cdef dparray result = dparray(result_shape, dtype=result_type)
191191

0 commit comments

Comments
 (0)