Skip to content

Commit 4e6daea

Browse files
swolchokamathewc
authored andcommitted
clang-format aten/src/ATen/cpu/vec/*.h (pytorch#150426)
I got a complaint about indentation on pytorch#150380. Make the machines fix it for us. Pull Request resolved: pytorch#150426 Approved by: https://github.com/aditew01, https://github.com/cyyever, https://github.com/frost-intel, https://github.com/Skylion007
1 parent 17ef02a commit 4e6daea

File tree

9 files changed

+735
-385
lines changed

9 files changed

+735
-385
lines changed

.lintrunner.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ init_command = [
5555
code = 'CLANGFORMAT'
5656
include_patterns = [
5757
'aten/src/ATen/*.h',
58+
'aten/src/ATen/cpu/vec/*.h',
5859
'aten/src/ATen/mps/**/*.mm',
5960
'aten/src/ATen/mps/**/*.h',
6061
'aten/src/ATen/xpu/**/*.h',

aten/src/ATen/cpu/vec/functional_base.h

Lines changed: 85 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,21 @@ inline scalar_t vec_reduce_all(
2929

3030
template <typename scalar_t, typename Op>
3131
struct VecReduceAllSIMD {
32-
static inline scalar_t apply(const Op& vec_fun, const Vectorized<scalar_t>& acc_vec) {
32+
static inline scalar_t apply(
33+
const Op& vec_fun,
34+
const Vectorized<scalar_t>& acc_vec) {
3335
return vec_reduce_all(vec_fun, acc_vec, Vectorized<scalar_t>::size());
3436
}
3537
};
3638

37-
#if defined(__GNUC__) && (__GNUC__ > 5) && !defined(_MSC_VER) && !defined(C10_MOBILE)
39+
#if defined(__GNUC__) && (__GNUC__ > 5) && !defined(_MSC_VER) && \
40+
!defined(C10_MOBILE)
3841
#if defined(CPU_CAPABILITY_AVX2)
3942
template <typename Op>
4043
struct VecReduceAllSIMD<float, Op> {
41-
static inline float apply(const Op& vec_fun, const Vectorized<float>& acc_vec) {
44+
static inline float apply(
45+
const Op& vec_fun,
46+
const Vectorized<float>& acc_vec) {
4247
using Vec = Vectorized<float>;
4348
Vec v = acc_vec;
4449
// 128-bit shuffle
@@ -57,7 +62,9 @@ struct VecReduceAllSIMD<float, Op> {
5762
#if defined(CPU_CAPABILITY_AVX512)
5863
template <typename Op>
5964
struct VecReduceAllSIMD<float, Op> {
60-
static inline float apply(const Op& vec_fun, const Vectorized<float>& acc_vec) {
65+
static inline float apply(
66+
const Op& vec_fun,
67+
const Vectorized<float>& acc_vec) {
6168
using Vec = Vectorized<float>;
6269
Vec v = acc_vec;
6370
// 256-bit shuffle
@@ -76,36 +83,47 @@ struct VecReduceAllSIMD<float, Op> {
7683
}
7784
};
7885
#endif // defined(CPU_CAPABILITY_AVX512)
79-
#endif // defined(__GNUC__) && (__GNUC__ > 5) && !defined(_MSC_VER) && !defined(C10_MOBILE)
86+
#endif // defined(__GNUC__) && (__GNUC__ > 5) && !defined(_MSC_VER) &&
87+
// !defined(C10_MOBILE)
8088

81-
#if defined(__aarch64__) && !defined(C10_MOBILE) && !defined(__CUDACC__) && !defined(CPU_CAPABILITY_SVE)
89+
#if defined(__aarch64__) && !defined(C10_MOBILE) && !defined(__CUDACC__) && \
90+
!defined(CPU_CAPABILITY_SVE)
8291
template <typename Op>
8392
struct VecReduceAllSIMD<float, Op> {
84-
static inline float apply(const Op& vec_fun, const Vectorized<float>& acc_vec) {
93+
static inline float apply(
94+
const Op& vec_fun,
95+
const Vectorized<float>& acc_vec) {
8596
using Vec = Vectorized<float>;
8697
Vec v = acc_vec;
8798

88-
// 64-bit shuffle: [a1+a5, a2+a6, a3+a7, a4+a8, -, -, -, -] -> [a3+a7, a4+a8, a1+a5, a2+a6, -, -, -, -]
99+
// 64-bit shuffle: [a1+a5, a2+a6, a3+a7, a4+a8, -, -, -, -] -> [a3+a7,
100+
// a4+a8, a1+a5, a2+a6, -, -, -, -]
89101
float32x4_t v1_1 = vextq_f32(v, v, 2);
90102
Vec v1 = v1_1;
91103
// [a1+a3+a5+a7, a2+a4+a6+a8, a1+a3+a5+a7, a2+a4+a6+a8, -, -, -, -]
92104
v = vec_fun(v, v1);
93105

94-
// 32-bit shuffle: [a1+a3+a5+a7, a2+a4+a6+a8, a1+a3+a5+a7, a2+a4+a6+a8, -, -, -, -] -> [a2+a4+a6+a8, a1+a3+a5+a7, a2+a4+a6+a8, a1+a3+a5+a7, -, -, -, -]
106+
// 32-bit shuffle: [a1+a3+a5+a7, a2+a4+a6+a8, a1+a3+a5+a7, a2+a4+a6+a8, -,
107+
// -, -, -] -> [a2+a4+a6+a8, a1+a3+a5+a7, a2+a4+a6+a8, a1+a3+a5+a7, -, -, -,
108+
// -]
95109
v1_1 = vrev64q_f32(v);
96110
v1 = v1_1;
97-
// [a1+a2+a3+a4+a5+a6+a7+a8, a1+a2+a3+a4+a5+a6+a7+a8, a1+a2+a3+a4+a5+a6+a7+a8, a1+a2+a3+a4+a5+a6+a7+a8, -, -, -, -]
111+
// [a1+a2+a3+a4+a5+a6+a7+a8, a1+a2+a3+a4+a5+a6+a7+a8,
112+
// a1+a2+a3+a4+a5+a6+a7+a8, a1+a2+a3+a4+a5+a6+a7+a8, -, -, -, -]
98113
v = vec_fun(v, v1);
99114

100115
return v[0];
101116
}
102117
};
103118
#endif // defined(__aarch64__)
104119

105-
#if defined(__aarch64__) && !defined(C10_MOBILE) && !defined(__CUDACC__) && defined(CPU_CAPABILITY_SVE256)
120+
#if defined(__aarch64__) && !defined(C10_MOBILE) && !defined(__CUDACC__) && \
121+
defined(CPU_CAPABILITY_SVE256)
106122
template <typename Op>
107123
struct VecReduceAllSIMD<float, Op> {
108-
static inline float apply(const Op& vec_fun, const Vectorized<float>& acc_vec) {
124+
static inline float apply(
125+
const Op& vec_fun,
126+
const Vectorized<float>& acc_vec) {
109127
using Vec = Vectorized<float>;
110128
Vec v = acc_vec;
111129
// 128-bit shuffle
@@ -125,15 +143,21 @@ struct VecReduceAllSIMD<float, Op> {
125143
};
126144
#endif // defined(__aarch64__)
127145

128-
129146
template <typename scalar_t, typename Op>
130-
inline scalar_t vec_reduce_all(const Op& vec_fun, const Vectorized<scalar_t>& acc_vec) {
147+
inline scalar_t vec_reduce_all(
148+
const Op& vec_fun,
149+
const Vectorized<scalar_t>& acc_vec) {
131150
return VecReduceAllSIMD<scalar_t, Op>::apply(vec_fun, acc_vec);
132151
}
133152

134-
template <typename scalar_t, typename Op,
135-
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
136-
inline scalar_t reduce_all(const Op& vec_fun, const scalar_t* data, int64_t size) {
153+
template <
154+
typename scalar_t,
155+
typename Op,
156+
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
157+
inline scalar_t reduce_all(
158+
const Op& vec_fun,
159+
const scalar_t* data,
160+
int64_t size) {
137161
using Vec = vec::Vectorized<scalar_t>;
138162
if (size < Vec::size())
139163
return vec_reduce_all(vec_fun, Vec::loadu(data, size), size);
@@ -151,16 +175,22 @@ inline scalar_t reduce_all(const Op& vec_fun, const scalar_t* data, int64_t size
151175
}
152176

153177
// similar to reduce_all, but reduces into two outputs
154-
template <typename scalar_t, typename Op1, typename Op2,
155-
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
156-
inline std::pair<scalar_t, scalar_t> reduce2_all(const Op1& vec_fun1, const Op2& vec_fun2,
157-
const scalar_t* data, int64_t size) {
178+
template <
179+
typename scalar_t,
180+
typename Op1,
181+
typename Op2,
182+
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
183+
inline std::pair<scalar_t, scalar_t> reduce2_all(
184+
const Op1& vec_fun1,
185+
const Op2& vec_fun2,
186+
const scalar_t* data,
187+
int64_t size) {
158188
using Vec = vec::Vectorized<scalar_t>;
159189
if (size < Vec::size()) {
160190
auto loaded_data = Vec::loadu(data, size);
161191
return std::pair<scalar_t, scalar_t>(
162-
vec_reduce_all(vec_fun1, loaded_data, size),
163-
vec_reduce_all(vec_fun2, loaded_data, size));
192+
vec_reduce_all(vec_fun1, loaded_data, size),
193+
vec_reduce_all(vec_fun2, loaded_data, size));
164194
}
165195
int64_t d = Vec::size();
166196
Vec acc_vec1 = Vec::loadu(data);
@@ -176,12 +206,14 @@ inline std::pair<scalar_t, scalar_t> reduce2_all(const Op1& vec_fun1, const Op2&
176206
acc_vec2 = Vec::set(acc_vec2, vec_fun2(acc_vec2, data_vec), size - d);
177207
}
178208
return std::pair<scalar_t, scalar_t>(
179-
vec_reduce_all(vec_fun1, acc_vec1),
180-
vec_reduce_all(vec_fun2, acc_vec2));
209+
vec_reduce_all(vec_fun1, acc_vec1), vec_reduce_all(vec_fun2, acc_vec2));
181210
}
182211

183-
template <typename scalar_t, typename MapOp, typename ReduceOp,
184-
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
212+
template <
213+
typename scalar_t,
214+
typename MapOp,
215+
typename ReduceOp,
216+
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
185217
inline scalar_t map_reduce_all(
186218
const MapOp& map_fun,
187219
const ReduceOp& red_fun,
@@ -205,8 +237,11 @@ inline scalar_t map_reduce_all(
205237
return vec_reduce_all(red_fun, acc_vec);
206238
}
207239

208-
template <typename scalar_t, typename MapOp, typename ReduceOp,
209-
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
240+
template <
241+
typename scalar_t,
242+
typename MapOp,
243+
typename ReduceOp,
244+
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
210245
inline scalar_t map2_reduce_all(
211246
const MapOp& map_fun,
212247
const ReduceOp& red_fun,
@@ -237,8 +272,11 @@ inline scalar_t map2_reduce_all(
237272
return vec_reduce_all(red_fun, acc_vec);
238273
}
239274

240-
template <typename scalar_t, typename MapOp, typename ReduceOp,
241-
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
275+
template <
276+
typename scalar_t,
277+
typename MapOp,
278+
typename ReduceOp,
279+
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
242280
inline scalar_t map3_reduce_all(
243281
const MapOp& map_fun,
244282
const ReduceOp& red_fun,
@@ -274,8 +312,10 @@ inline scalar_t map3_reduce_all(
274312
return vec_reduce_all(red_fun, acc_vec);
275313
}
276314

277-
template <typename scalar_t, typename Op,
278-
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
315+
template <
316+
typename scalar_t,
317+
typename Op,
318+
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
279319
inline void map(
280320
const Op& vec_fun,
281321
scalar_t* output_data,
@@ -293,8 +333,10 @@ inline void map(
293333
}
294334
}
295335

296-
template <typename scalar_t, typename Op,
297-
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
336+
template <
337+
typename scalar_t,
338+
typename Op,
339+
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
298340
inline void map2(
299341
const Op& vec_fun,
300342
scalar_t* output_data,
@@ -317,8 +359,10 @@ inline void map2(
317359
}
318360
}
319361

320-
template <typename scalar_t, typename Op,
321-
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
362+
template <
363+
typename scalar_t,
364+
typename Op,
365+
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
322366
inline void map3(
323367
const Op& vec_fun,
324368
scalar_t* output_data,
@@ -344,8 +388,10 @@ inline void map3(
344388
}
345389
}
346390

347-
template <typename scalar_t, typename Op,
348-
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
391+
template <
392+
typename scalar_t,
393+
typename Op,
394+
typename std::enable_if_t<!is_reduced_floating_point_v<scalar_t>, int> = 0>
349395
inline void map4(
350396
const Op& vec_fun,
351397
scalar_t* output_data,

0 commit comments

Comments
 (0)