Skip to content

Commit 56a0af4

Browse files
Apply clang-format
1 parent d835f96 commit 56a0af4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+445
-815
lines changed

dpnp/backend/include/dpnp4pybind11.hpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -195,22 +195,10 @@ class dpctl_capi
195195
return api;
196196
}
197197

198-
py::object default_sycl_queue_pyobj()
199-
{
200-
return *default_sycl_queue_;
201-
}
202-
py::object default_usm_memory_pyobj()
203-
{
204-
return *default_usm_memory_;
205-
}
206-
py::object default_usm_ndarray_pyobj()
207-
{
208-
return *default_usm_ndarray_;
209-
}
210-
py::object as_usm_memory_pyobj()
211-
{
212-
return *as_usm_memory_;
213-
}
198+
py::object default_sycl_queue_pyobj() { return *default_sycl_queue_; }
199+
py::object default_usm_memory_pyobj() { return *default_usm_memory_; }
200+
py::object default_usm_ndarray_pyobj() { return *default_usm_ndarray_; }
201+
py::object as_usm_memory_pyobj() { return *as_usm_memory_; }
214202

215203
private:
216204
struct Deleter

dpnp/tensor/libtensor/include/kernels/accumulators.hpp

Lines changed: 32 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@ struct NoOpTransformer
8585
{
8686
constexpr NoOpTransformer() {}
8787

88-
T operator()(const T &val) const
89-
{
90-
return val;
91-
}
88+
T operator()(const T &val) const { return val; }
9289
};
9390

9491
template <typename srcTy, typename dstTy>
@@ -134,22 +131,13 @@ class stack_t
134131
: src_(src), size_(sz), local_scans_(local_scans)
135132
{
136133
}
137-
~stack_t(){};
134+
~stack_t() {};
138135

139-
T *get_src_ptr() const
140-
{
141-
return src_;
142-
}
136+
T *get_src_ptr() const { return src_; }
143137

144-
std::size_t get_size() const
145-
{
146-
return size_;
147-
}
138+
std::size_t get_size() const { return size_; }
148139

149-
T *get_local_scans_ptr() const
150-
{
151-
return local_scans_;
152-
}
140+
T *get_local_scans_ptr() const { return local_scans_; }
153141
};
154142

155143
template <typename T>
@@ -170,27 +158,15 @@ class stack_strided_t
170158
local_stride_(local_stride)
171159
{
172160
}
173-
~stack_strided_t(){};
161+
~stack_strided_t() {};
174162

175-
T *get_src_ptr() const
176-
{
177-
return src_;
178-
}
163+
T *get_src_ptr() const { return src_; }
179164

180-
std::size_t get_size() const
181-
{
182-
return size_;
183-
}
165+
std::size_t get_size() const { return size_; }
184166

185-
T *get_local_scans_ptr() const
186-
{
187-
return local_scans_;
188-
}
167+
T *get_local_scans_ptr() const { return local_scans_; }
189168

190-
std::size_t get_local_stride() const
191-
{
192-
return local_stride_;
193-
}
169+
std::size_t get_local_stride() const { return local_stride_; }
194170
};
195171

196172
} // end of namespace detail
@@ -515,32 +491,35 @@ sycl::event inclusive_scan_base_step_striped(
515491
it.barrier(sycl::access::fence_space::local_space);
516492

517493
// convert back to blocked layout
518-
{{const std::uint32_t local_offset0 = lid * n_wi;
494+
{
495+
{
496+
const std::uint32_t local_offset0 = lid * n_wi;
519497
#pragma unroll
520-
for (nwiT m_wi = 0; m_wi < n_wi; ++m_wi) {
521-
slm_iscan_tmp[local_offset0 + m_wi] = local_iscan[m_wi];
522-
}
498+
for (nwiT m_wi = 0; m_wi < n_wi; ++m_wi) {
499+
slm_iscan_tmp[local_offset0 + m_wi] = local_iscan[m_wi];
500+
}
523501

524-
it.barrier(sycl::access::fence_space::local_space);
502+
it.barrier(sycl::access::fence_space::local_space);
525503
}
526504
}
527505

528506
{
529-
const std::uint32_t block_offset = sgroup_id * sgSize * n_wi + lane_id;
507+
const std::uint32_t block_offset =
508+
sgroup_id * sgSize * n_wi + lane_id;
530509
#pragma unroll
531-
for (nwiT m_wi = 0; m_wi < n_wi; ++m_wi) {
532-
const std::uint32_t m_wi_scaled = m_wi * sgSize;
533-
const std::size_t out_id = inp_id0 + m_wi_scaled;
534-
if (out_id < acc_nelems) {
535-
output[out_iter_offset + out_indexer(out_id)] =
536-
slm_iscan_tmp[block_offset + m_wi_scaled];
537-
}
538-
}
510+
for (nwiT m_wi = 0; m_wi < n_wi; ++m_wi) {
511+
const std::uint32_t m_wi_scaled = m_wi * sgSize;
512+
const std::size_t out_id = inp_id0 + m_wi_scaled;
513+
if (out_id < acc_nelems) {
514+
output[out_iter_offset + out_indexer(out_id)] =
515+
slm_iscan_tmp[block_offset + m_wi_scaled];
516+
}
517+
}
539518
}
540-
});
541-
});
519+
});
520+
});
542521

543-
return inc_scan_phase1_ev;
522+
return inc_scan_phase1_ev;
544523
}
545524

546525
template <typename inputT,
@@ -746,8 +725,7 @@ sycl::event inclusive_scan_iter_1d(sycl::queue &exec_q,
746725
}
747726

748727
for (std::size_t reverse_stack_id = 0; reverse_stack_id < stack.size();
749-
++reverse_stack_id)
750-
{
728+
++reverse_stack_id) {
751729
const std::size_t stack_id = stack.size() - 1 - reverse_stack_id;
752730

753731
const auto &stack_elem = stack[stack_id];
@@ -1082,8 +1060,7 @@ sycl::event inclusive_scan_iter(sycl::queue &exec_q,
10821060
}
10831061

10841062
for (std::size_t reverse_stack_id = 0;
1085-
reverse_stack_id < stack.size() - 1; ++reverse_stack_id)
1086-
{
1063+
reverse_stack_id < stack.size() - 1; ++reverse_stack_id) {
10871064
const std::size_t stack_id = stack.size() - 1 - reverse_stack_id;
10881065

10891066
const auto &stack_elem = stack[stack_id];

dpnp/tensor/libtensor/include/kernels/clip.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ sycl::event clip_contig_impl(sycl::queue &q,
219219
if (is_aligned<required_alignment>(x_cp) &&
220220
is_aligned<required_alignment>(min_cp) &&
221221
is_aligned<required_alignment>(max_cp) &&
222-
is_aligned<required_alignment>(dst_cp))
223-
{
222+
is_aligned<required_alignment>(dst_cp)) {
224223
static constexpr bool enable_sg_loadstore = true;
225224
using KernelName = clip_contig_kernel<T, vec_sz, n_vecs>;
226225
using Impl =

dpnp/tensor/libtensor/include/kernels/copy_and_cast.hpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,7 @@ sycl::event copy_and_cast_contig_impl(sycl::queue &q,
352352
const auto lws_range = sycl::range<1>(lws);
353353

354354
if (is_aligned<required_alignment>(src_cp) &&
355-
is_aligned<required_alignment>(dst_cp))
356-
{
355+
is_aligned<required_alignment>(dst_cp)) {
357356
static constexpr bool enable_sg_loadstore = true;
358357
using KernelName =
359358
copy_cast_contig_kernel<srcTy, dstTy, vec_sz, n_vecs>;
@@ -920,10 +919,7 @@ struct CompositionIndexer
920919
{
921920
CompositionIndexer(IndexerT f, TransformerT t) : f_(f), t_(t) {}
922921

923-
auto operator()(std::size_t gid) const
924-
{
925-
return f_(t_(gid));
926-
}
922+
auto operator()(std::size_t gid) const { return f_(t_(gid)); }
927923

928924
private:
929925
IndexerT f_;
@@ -944,10 +940,7 @@ struct RolledNDIndexer
944940
{
945941
}
946942

947-
ssize_t operator()(std::size_t gid) const
948-
{
949-
return compute_offset(gid);
950-
}
943+
ssize_t operator()(std::size_t gid) const { return compute_offset(gid); }
951944

952945
private:
953946
int nd_ = -1;

dpnp/tensor/libtensor/include/kernels/copy_as_contiguous.hpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,7 @@ typedef sycl::event (*as_c_contiguous_array_impl_fn_ptr_t)(
261261
template <typename fnT, typename T>
262262
struct AsCContigFactory
263263
{
264-
fnT get()
265-
{
266-
return as_c_contiguous_array_generic_impl<T>;
267-
}
264+
fnT get() { return as_c_contiguous_array_generic_impl<T>; }
268265
};
269266

270267
template <typename T,
@@ -496,8 +493,7 @@ sycl::event as_c_contiguous_batch_of_square_matrices_impl(
496493
else {
497494
// map local_linear_id into (local_dim0, local_dim1)
498495
for (std::uint16_t el_id = lid_lin;
499-
el_id < local_dim0 * local_dim1; el_id += lws0 * lws1)
500-
{
496+
el_id < local_dim0 * local_dim1; el_id += lws0 * lws1) {
501497

502498
// 0 <= local_i0 < local_dim0
503499
const std::uint16_t loc_i0 = el_id / local_dim1;
@@ -577,10 +573,7 @@ typedef sycl::event (
577573
template <typename fnT, typename T>
578574
struct AsCContig1DBatchOfSquareMatricesFactory
579575
{
580-
fnT get()
581-
{
582-
return as_c_contiguous_1d_batch_of_square_matrices_impl<T>;
583-
}
576+
fnT get() { return as_c_contiguous_1d_batch_of_square_matrices_impl<T>; }
584577
};
585578

586579
template <typename T>
@@ -638,9 +631,6 @@ typedef sycl::event (
638631
template <typename fnT, typename T>
639632
struct AsCContigNDBatchOfSquareMatricesFactory
640633
{
641-
fnT get()
642-
{
643-
return as_c_contiguous_nd_batch_of_square_matrices_impl<T>;
644-
}
634+
fnT get() { return as_c_contiguous_nd_batch_of_square_matrices_impl<T>; }
645635
};
646636
} // namespace dpctl::tensor::kernels::copy_as_contig

dpnp/tensor/libtensor/include/kernels/elementwise_functions/abs.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ struct AbsFunctor
7373

7474
if constexpr (std::is_same_v<argT, bool> ||
7575
(std::is_integral<argT>::value &&
76-
std::is_unsigned<argT>::value))
77-
{
76+
std::is_unsigned<argT>::value)) {
7877
static_assert(std::is_same_v<resT, argT>);
7978
return x;
8079
}
@@ -83,8 +82,7 @@ struct AbsFunctor
8382
return detail::cabs(x);
8483
}
8584
else if constexpr (std::is_same_v<argT, sycl::half> ||
86-
std::is_floating_point_v<argT>)
87-
{
85+
std::is_floating_point_v<argT>) {
8886
return (sycl::signbit(x) ? -x : x);
8987
}
9088
else {

dpnp/tensor/libtensor/include/kernels/elementwise_functions/add.hpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,20 @@ struct AddFunctor
7171
resT operator()(const argT1 &in1, const argT2 &in2) const
7272
{
7373
if constexpr (tu_ns::is_complex<argT1>::value &&
74-
tu_ns::is_complex<argT2>::value)
75-
{
74+
tu_ns::is_complex<argT2>::value) {
7675
using rT1 = typename argT1::value_type;
7776
using rT2 = typename argT2::value_type;
7877

7978
return exprm_ns::complex<rT1>(in1) + exprm_ns::complex<rT2>(in2);
8079
}
8180
else if constexpr (tu_ns::is_complex<argT1>::value &&
82-
!tu_ns::is_complex<argT2>::value)
83-
{
81+
!tu_ns::is_complex<argT2>::value) {
8482
using rT1 = typename argT1::value_type;
8583

8684
return exprm_ns::complex<rT1>(in1) + in2;
8785
}
8886
else if constexpr (!tu_ns::is_complex<argT1>::value &&
89-
tu_ns::is_complex<argT2>::value)
90-
{
87+
tu_ns::is_complex<argT2>::value) {
9188
using rT2 = typename argT2::value_type;
9289

9390
return in1 + exprm_ns::complex<rT2>(in2);
@@ -402,8 +399,7 @@ struct AddContigMatrixContigRowBroadcastFactory
402399
using resT = typename AddOutputType<T1, T2>::value_type;
403400
if constexpr (dpctl::tensor::type_utils::is_complex<T1>::value ||
404401
dpctl::tensor::type_utils::is_complex<T2>::value ||
405-
dpctl::tensor::type_utils::is_complex<resT>::value)
406-
{
402+
dpctl::tensor::type_utils::is_complex<resT>::value) {
407403
fnT fn = nullptr;
408404
return fn;
409405
}
@@ -449,8 +445,7 @@ struct AddContigRowContigMatrixBroadcastFactory
449445
using resT = typename AddOutputType<T1, T2>::value_type;
450446
if constexpr (dpctl::tensor::type_utils::is_complex<T1>::value ||
451447
dpctl::tensor::type_utils::is_complex<T2>::value ||
452-
dpctl::tensor::type_utils::is_complex<resT>::value)
453-
{
448+
dpctl::tensor::type_utils::is_complex<resT>::value) {
454449
fnT fn = nullptr;
455450
return fn;
456451
}
@@ -472,10 +467,7 @@ struct AddInplaceFunctor
472467
using supports_vec = std::negation<
473468
std::disjunction<tu_ns::is_complex<argT>, tu_ns::is_complex<resT>>>;
474469

475-
void operator()(resT &res, const argT &in)
476-
{
477-
res += in;
478-
}
470+
void operator()(resT &res, const argT &in) { res += in; }
479471

480472
template <int vec_sz>
481473
void operator()(sycl::vec<resT, vec_sz> &res,
@@ -672,8 +664,7 @@ struct AddInplaceRowMatrixBroadcastFactory
672664
}
673665
else {
674666
if constexpr (dpctl::tensor::type_utils::is_complex<T1>::value ||
675-
dpctl::tensor::type_utils::is_complex<T2>::value)
676-
{
667+
dpctl::tensor::type_utils::is_complex<T2>::value) {
677668
fnT fn = nullptr;
678669
return fn;
679670
}

dpnp/tensor/libtensor/include/kernels/elementwise_functions/atanh.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ struct AtanhFunctor
123123
*/
124124
const realT RECIP_EPSILON =
125125
realT(1) / std::numeric_limits<realT>::epsilon();
126-
if (sycl::fabs(x) > RECIP_EPSILON || sycl::fabs(y) > RECIP_EPSILON)
127-
{
126+
if (sycl::fabs(x) > RECIP_EPSILON ||
127+
sycl::fabs(y) > RECIP_EPSILON) {
128128
const realT pi_half = sycl::atan(realT(1)) * 2;
129129

130130
const realT res_re = realT(0);

dpnp/tensor/libtensor/include/kernels/elementwise_functions/bitwise_and.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,8 @@ struct BitwiseAndInplaceTypeMapFactory
372372
/*! @brief get typeid for output type of x &= y */
373373
std::enable_if_t<std::is_same<fnT, int>::value, int> get()
374374
{
375-
if constexpr (BitwiseAndInplaceTypePairSupport<argT, resT>::is_defined)
376-
{
375+
if constexpr (BitwiseAndInplaceTypePairSupport<argT,
376+
resT>::is_defined) {
377377
return td_ns::GetTypeid<resT>{}.get();
378378
}
379379
else {

dpnp/tensor/libtensor/include/kernels/elementwise_functions/bitwise_left_shift.hpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,7 @@ struct BitwiseLeftShiftInplaceFunctor
307307
using supports_sg_loadstore = typename std::true_type;
308308
using supports_vec = typename std::true_type;
309309

310-
void operator()(resT &res, const argT &in) const
311-
{
312-
impl(res, in);
313-
}
310+
void operator()(resT &res, const argT &in) const { impl(res, in); }
314311

315312
template <int vec_sz>
316313
void operator()(sycl::vec<resT, vec_sz> &res,
@@ -392,9 +389,8 @@ struct BitwiseLeftShiftInplaceTypeMapFactory
392389
/*! @brief get typeid for output type of x <<= y */
393390
std::enable_if_t<std::is_same<fnT, int>::value, int> get()
394391
{
395-
if constexpr (BitwiseLeftShiftInplaceTypePairSupport<argT,
396-
resT>::is_defined)
397-
{
392+
if constexpr (BitwiseLeftShiftInplaceTypePairSupport<
393+
argT, resT>::is_defined) {
398394
return td_ns::GetTypeid<resT>{}.get();
399395
}
400396
else {

0 commit comments

Comments
 (0)