Skip to content

Commit eacd4c4

Browse files
authored
[Clean-up] Clang-format some existing files (#3179)
- Updated the clang-format to the latest (21) - Reformatted all existing files using this new clang-format BUG=SImple-clean-up
1 parent 135102f commit eacd4c4

File tree

12 files changed

+90
-69
lines changed

12 files changed

+90
-69
lines changed

ci/Dockerfile.micro

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ RUN apt-get install -y zip xxd sudo
3737
RUN apt install -y lsb-release wget software-properties-common gnupg
3838
RUN wget https://apt.llvm.org/llvm.sh
3939
RUN chmod +x llvm.sh
40-
RUN ./llvm.sh 16
41-
RUN ln -s /usr/bin/clang-16 /usr/bin/clang
42-
RUN ln -s /usr/bin/clang++-16 /usr/bin/clang++
40+
RUN ./llvm.sh 21
41+
RUN ln -s /usr/bin/clang-21 /usr/bin/clang
42+
RUN ln -s /usr/bin/clang++-21 /usr/bin/clang++
4343

44-
RUN apt-get install clang-format-16
45-
RUN ln -s /usr/bin/clang-format-16 /usr/bin/clang-format
44+
RUN apt-get install clang-format-21
45+
RUN ln -s /usr/bin/clang-format-21 /usr/bin/clang-format
4646

4747
# Needed when using the Dockerfile locally.
4848
RUN git config --global --add safe.directory /opt/tflm

tensorflow/lite/experimental/microfrontend/lib/filterbank_test.cc

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ TF_LITE_MICRO_TEST(FilterbankTest_CheckChannelFrequencyStarts) {
7676
kSampleRate, kSpectrumSize));
7777

7878
const int16_t expected[] = {0, 4, 8};
79-
TF_LITE_MICRO_EXPECT_EQ(state.num_channels + 1,
80-
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
79+
TF_LITE_MICRO_EXPECT_EQ(
80+
state.num_channels + 1,
81+
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
8182
int i;
8283
for (i = 0; i <= state.num_channels; ++i) {
8384
TF_LITE_MICRO_EXPECT_EQ(state.channel_frequency_starts[i], expected[i]);
@@ -93,8 +94,9 @@ TF_LITE_MICRO_TEST(FilterbankTest_CheckChannelWeightStarts) {
9394
kSampleRate, kSpectrumSize));
9495

9596
const int16_t expected[] = {0, 8, 16};
96-
TF_LITE_MICRO_EXPECT_EQ(state.num_channels + 1,
97-
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
97+
TF_LITE_MICRO_EXPECT_EQ(
98+
state.num_channels + 1,
99+
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
98100
int i;
99101
for (i = 0; i <= state.num_channels; ++i) {
100102
TF_LITE_MICRO_EXPECT_EQ(state.channel_weight_starts[i], expected[i]);
@@ -110,8 +112,9 @@ TF_LITE_MICRO_TEST(FilterbankTest_CheckChannelWidths) {
110112
kSampleRate, kSpectrumSize));
111113

112114
const int16_t expected[] = {8, 8, 8};
113-
TF_LITE_MICRO_EXPECT_EQ(state.num_channels + 1,
114-
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
115+
TF_LITE_MICRO_EXPECT_EQ(
116+
state.num_channels + 1,
117+
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
115118
int i;
116119
for (i = 0; i <= state.num_channels; ++i) {
117120
TF_LITE_MICRO_EXPECT_EQ(state.channel_widths[i], expected[i]);
@@ -129,9 +132,10 @@ TF_LITE_MICRO_TEST(FilterbankTest_CheckWeights) {
129132
const int16_t expected[] = {0, 3277, 2217, 1200, 222, 0, 0, 0,
130133
0, 3376, 2468, 1591, 744, 0, 0, 0,
131134
0, 4020, 3226, 2456, 1708, 983, 277, 0};
132-
TF_LITE_MICRO_EXPECT_EQ(state.channel_weight_starts[state.num_channels] +
133-
state.channel_widths[state.num_channels],
134-
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
135+
TF_LITE_MICRO_EXPECT_EQ(
136+
state.channel_weight_starts[state.num_channels] +
137+
state.channel_widths[state.num_channels],
138+
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
135139
for (size_t i = 0; i < sizeof(expected) / sizeof(expected[0]); ++i) {
136140
TF_LITE_MICRO_EXPECT_EQ(state.weights[i], expected[i]);
137141
}
@@ -148,9 +152,10 @@ TF_LITE_MICRO_TEST(FilterbankTest_CheckUnweights) {
148152
const int16_t expected[] = {0, 819, 1879, 2896, 3874, 0, 0, 0,
149153
0, 720, 1628, 2505, 3352, 0, 0, 0,
150154
0, 76, 870, 1640, 2388, 3113, 3819, 0};
151-
TF_LITE_MICRO_EXPECT_EQ(state.channel_weight_starts[state.num_channels] +
152-
state.channel_widths[state.num_channels],
153-
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
155+
TF_LITE_MICRO_EXPECT_EQ(
156+
state.channel_weight_starts[state.num_channels] +
157+
state.channel_widths[state.num_channels],
158+
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
154159
for (size_t i = 0; i < sizeof(expected) / sizeof(expected[0]); ++i) {
155160
TF_LITE_MICRO_EXPECT_EQ(state.unweights[i], expected[i]);
156161
}
@@ -204,8 +209,9 @@ TF_LITE_MICRO_TEST(FilterbankTest_CheckSqrt) {
204209
uint32_t* scaled_filterbank = FilterbankSqrt(&state, kScaleShift);
205210

206211
const uint32_t expected[] = {247311, 508620};
207-
TF_LITE_MICRO_EXPECT_EQ(state.num_channels,
208-
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
212+
TF_LITE_MICRO_EXPECT_EQ(
213+
state.num_channels,
214+
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
209215
int i;
210216
for (i = 0; i < state.num_channels; ++i) {
211217
TF_LITE_MICRO_EXPECT_EQ(scaled_filterbank[i], expected[i]);

tensorflow/lite/experimental/microfrontend/lib/noise_reduction_test.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ TF_LITE_MICRO_TEST(NoiseReductionTest_TestNoiseReductionEstimate) {
4848
NoiseReductionApply(&state, signal);
4949

5050
const uint32_t expected[] = {6321887, 31248341};
51-
TF_LITE_MICRO_EXPECT_EQ(state.num_channels,
52-
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
51+
TF_LITE_MICRO_EXPECT_EQ(
52+
state.num_channels,
53+
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
5354
int i;
5455
for (i = 0; i < state.num_channels; ++i) {
5556
TF_LITE_MICRO_EXPECT_EQ(state.estimate[i], expected[i]);
@@ -68,8 +69,9 @@ TF_LITE_MICRO_TEST(NoiseReductionTest_TestNoiseReduction) {
6869
NoiseReductionApply(&state, signal);
6970

7071
const uint32_t expected[] = {241137, 478104};
71-
TF_LITE_MICRO_EXPECT_EQ(state.num_channels,
72-
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
72+
TF_LITE_MICRO_EXPECT_EQ(
73+
state.num_channels,
74+
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
7375
int i;
7476
for (i = 0; i < state.num_channels; ++i) {
7577
TF_LITE_MICRO_EXPECT_EQ(signal[i], expected[i]);

tensorflow/lite/experimental/microfrontend/lib/pcan_gain_control_test.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ TF_LITE_MICRO_TEST(PcanGainControlTest_TestPcanGainControl) {
5252
PcanGainControlApply(&state, signal);
5353

5454
const uint32_t expected[] = {3578, 1533};
55-
TF_LITE_MICRO_EXPECT_EQ(state.num_channels,
56-
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
55+
TF_LITE_MICRO_EXPECT_EQ(
56+
state.num_channels,
57+
static_cast<int>(sizeof(expected) / sizeof(expected[0])));
5758
int i;
5859
for (i = 0; i < state.num_channels; ++i) {
5960
TF_LITE_MICRO_EXPECT_EQ(signal[i], expected[i]);

tensorflow/lite/micro/cortex_m_corstone_300/system_setup.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ uint32_t GetCurrentTimeTicks() {
104104

105105
#ifdef ETHOS_U
106106
#if defined(ETHOSU_FAST_MEMORY_SIZE) && ETHOSU_FAST_MEMORY_SIZE > 0
107-
__attribute__((aligned(16), section(".bss.ethosu_scratch")))
108-
uint8_t ethosu0_scratch[ETHOSU_FAST_MEMORY_SIZE];
107+
__attribute__((aligned(16), section(".bss.ethosu_scratch"))) uint8_t
108+
ethosu0_scratch[ETHOSU_FAST_MEMORY_SIZE];
109109
#else
110110
#define ethosu0_scratch 0
111111
#define ETHOSU_FAST_MEMORY_SIZE 0

tensorflow/lite/micro/kernels/arc_mli/mli_function_specializations.h

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ typedef mli_status (*conv_func_ptr)(const mli_tensor* /*in*/,
2525
mli_tensor* /*out*/);
2626

2727
#ifdef MLI_2_0
28-
conv_func_ptr __attribute__((weak))
29-
mli_krn_conv2d_hwcn(const mli_tensor* weights) {
28+
conv_func_ptr
29+
__attribute__((weak)) mli_krn_conv2d_hwcn(const mli_tensor* weights) {
3030
int filter_w = weights->shape[KRNL_W_DIM_HWCN];
3131
int filter_h = weights->shape[KRNL_H_DIM_HWCN];
3232

@@ -41,8 +41,9 @@ mli_krn_conv2d_hwcn(const mli_tensor* weights) {
4141
}
4242
}
4343
#else
44-
conv_func_ptr __attribute__((weak))
45-
mli_krn_conv2d_hwcn(const mli_tensor* weights, const mli_conv2d_cfg* cfg) {
44+
conv_func_ptr
45+
__attribute__((weak)) mli_krn_conv2d_hwcn(const mli_tensor* weights,
46+
const mli_conv2d_cfg* cfg) {
4647
return mli_krn_conv2d_nhwc_sa8_sa8_sa32;
4748
}
4849
#endif
@@ -55,8 +56,8 @@ typedef mli_status (*depthwise_func_ptr)(const mli_tensor* /*in*/,
5556
mli_tensor* /*out*/);
5657

5758
#ifdef MLI_2_0
58-
depthwise_func_ptr __attribute__((weak))
59-
mli_krn_depthwise_conv2d(const mli_tensor* weights) {
59+
depthwise_func_ptr
60+
__attribute__((weak)) mli_krn_depthwise_conv2d(const mli_tensor* weights) {
6061
int filter_w = weights->shape[KRNL_DW_W_DIM_HW1N];
6162
int filter_h = weights->shape[KRNL_DW_H_DIM_HW1N];
6263

@@ -69,15 +70,16 @@ mli_krn_depthwise_conv2d(const mli_tensor* weights) {
6970
}
7071
}
7172
#else
72-
depthwise_func_ptr __attribute__((weak))
73-
mli_krn_depthwise_conv2d(const mli_tensor* weights, const mli_conv2d_cfg* cfg) {
73+
depthwise_func_ptr
74+
__attribute__((weak)) mli_krn_depthwise_conv2d(const mli_tensor* weights,
75+
const mli_conv2d_cfg* cfg) {
7476
return mli_krn_depthwise_conv2d_hwcn_sa8_sa8_sa32;
7577
}
7678
#endif
7779

7880
#ifdef MLI_2_0
79-
depthwise_func_ptr __attribute__((weak))
80-
mli_krn_group_conv2d(const mli_tensor* weights) {
81+
depthwise_func_ptr
82+
__attribute__((weak)) mli_krn_group_conv2d(const mli_tensor* weights) {
8183
int filter_w = weights->shape[KRNL_DW_W_DIM_HW1N];
8284
int filter_h = weights->shape[KRNL_DW_H_DIM_HW1N];
8385

@@ -97,8 +99,8 @@ typedef mli_status (*pooling_func_ptr)(const mli_tensor* /*in*/,
9799
mli_tensor* /*out*/);
98100

99101
#ifdef MLI_2_0
100-
pooling_func_ptr __attribute__((weak))
101-
mli_krn_avepool(const mli_pool_cfg* cfg) {
102+
pooling_func_ptr
103+
__attribute__((weak)) mli_krn_avepool(const mli_pool_cfg* cfg) {
102104
int filter_w = cfg->kernel_width;
103105
int filter_h = cfg->kernel_height;
104106

@@ -111,15 +113,15 @@ mli_krn_avepool(const mli_pool_cfg* cfg) {
111113
}
112114
}
113115
#else
114-
pooling_func_ptr __attribute__((weak))
115-
mli_krn_avepool(const mli_pool_cfg* cfg) {
116+
pooling_func_ptr
117+
__attribute__((weak)) mli_krn_avepool(const mli_pool_cfg* cfg) {
116118
return mli_krn_avepool_hwc_sa8;
117119
}
118120
#endif
119121

120122
#ifdef MLI_2_0
121-
pooling_func_ptr __attribute__((weak))
122-
mli_krn_maxpool(const mli_pool_cfg* cfg) {
123+
pooling_func_ptr
124+
__attribute__((weak)) mli_krn_maxpool(const mli_pool_cfg* cfg) {
123125
int filter_w = cfg->kernel_width;
124126
int filter_h = cfg->kernel_height;
125127

@@ -132,8 +134,8 @@ mli_krn_maxpool(const mli_pool_cfg* cfg) {
132134
}
133135
}
134136
#else
135-
pooling_func_ptr __attribute__((weak))
136-
mli_krn_maxpool(const mli_pool_cfg* cfg) {
137+
pooling_func_ptr
138+
__attribute__((weak)) mli_krn_maxpool(const mli_pool_cfg* cfg) {
137139
return mli_krn_maxpool_hwc_sa8;
138140
}
139141
#endif

tensorflow/lite/micro/kernels/arc_mli/mli_interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class MliTensorInterface {
3333
public:
3434
// Make sure that lifetime of MliTensorInterface instance isn't bigger than
3535
// related mli_tensor.
36-
MliTensorInterface(mli_tensor* tensor) : tensor_(tensor){};
36+
MliTensorInterface(mli_tensor* tensor) : tensor_(tensor) {};
3737
MliTensorInterface() = default;
3838
~MliTensorInterface() = default;
3939

tensorflow/lite/micro/kernels/circular_buffer.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ TfLiteStatus CircularBufferEval(TfLiteContext* context, TfLiteNode* node) {
9191
EvalInt8(tflite::micro::GetTensorData<int8_t>(input), num_slots, depth,
9292
tflite::micro::GetTensorData<int8_t>(output));
9393
} else {
94-
MicroPrintf("Type %s (%d) not supported.",
95-
TfLiteTypeGetName(input->type), input->type);
94+
MicroPrintf("Type %s (%d) not supported.", TfLiteTypeGetName(input->type),
95+
input->type);
9696
return kTfLiteError;
9797
}
9898

tensorflow/lite/micro/kernels/reduce_common.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ enum MinMaxEvalType { kEvalMin, kEvalMax };
120120
template <typename T>
121121
struct MinMaxReducerCompare {
122122
MinMaxReducerCompare() = delete;
123-
MinMaxReducerCompare(MinMaxEvalType evalType) : type_(evalType){};
123+
MinMaxReducerCompare(MinMaxEvalType evalType) : type_(evalType) {};
124124

125125
constexpr T initialValue() const {
126126
return (type_ == kEvalMin) ? std::numeric_limits<T>::max()

tensorflow/lite/micro/kernels/resize_bilinear_test.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,10 @@ TF_LITE_MICRO_TEST(VerticalResizeInt8) {
168168
TF_LITE_MICRO_TEST(TwoDimensionalResize) {
169169
int input_dims[] = {4, 1, 2, 2, 1};
170170
const float input_data[] = {
171-
3, 6, //
172-
9, 12, //
171+
3,
172+
6, //
173+
9,
174+
12, //
173175
};
174176
const int32_t expected_size_data[] = {3, 3};
175177
const float expected_output_data[] = {
@@ -194,8 +196,10 @@ TF_LITE_MICRO_TEST(TwoDimensionalResize) {
194196
TF_LITE_MICRO_TEST(TwoDimensionalResizeInt8) {
195197
int input_dims[] = {4, 1, 2, 2, 1};
196198
const int8_t input_data[] = {
197-
3, 6, //
198-
9, 12, //
199+
3,
200+
6, //
201+
9,
202+
12, //
199203
};
200204
const int32_t expected_size_data[] = {3, 3};
201205
const int8_t expected_output_data[] = {

0 commit comments

Comments
 (0)