Skip to content

Commit b16ce18

Browse files
cyyeverfacebook-github-bot
authored andcommitted
Add more tidy checks and apply fixes (#4466)
Summary: Pull Request resolved: #4466 X-link: facebookresearch/FBGEMM#1525 Almost all fixes are replacing ``std::endl`` with '\n' and replacing `std::bind` with lambdas. Pull Request resolved: #4461 Reviewed By: cthi Differential Revision: D78024382 Pulled By: q10 fbshipit-source-id: 27301c44878863fd628d09ff5843ddf9093ab68f
1 parent 789ea2c commit b16ce18

25 files changed

+57
-47
lines changed

.clang-tidy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ InheritParentConfig: true
77
# @nolint
88
Checks: '
99
-*,
10+
clang-analyzer*,
11+
clang-diagnostic-missing-prototypes,
1012
cppcoreguidelines-init-variables,
1113
bugprone-argument-comment,
1214
misc-use-internal-linkage,
@@ -21,7 +23,6 @@ modernize*,
2123
-modernize-use-integer-sign-comparison
2224
-modernize-use-nodiscard,
2325
performance*,
24-
-performance-avoid-endl
2526
'
2627
CheckOptions:
2728
- key: facebook-cuda-safe-api-call-check.HandlerName

src/EmbeddingSpMDM.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ GenEmbeddingSpMDMLookup<
997997
}
998998

999999
if (err) {
1000-
std::cout << "Error: in fn add" << std::endl;
1000+
std::cout << "Error: in fn add" << '\n';
10011001
return nullptr;
10021002
}
10031003

src/EmbeddingSpMDMAutovec.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "fbgemm/FbgemmBuild.h"
1616
#include "fbgemm/FloatConversion.h"
1717

18-
#include <math.h>
18+
#include <cmath>
1919

2020
#include <algorithm>
2121
#include <array>

src/EmbeddingSpMDMNBit.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ GenEmbeddingSpMDMNBitLookup<
999999
err = runtime().add(&fn, &code);
10001000
}
10011001
if (err) {
1002-
cout << "Error: in fn add" << endl;
1002+
cout << "Error: in fn add" << '\n';
10031003
return nullptr;
10041004
}
10051005

src/EmbeddingStatsTracker.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ void EmbeddingStatsTracker::recordPattern(
5353
}
5454
for (const auto& pair : tables_) {
5555
const auto& pattern = pair.first;
56-
logFile_ << pattern.toString() << "freq=" << pair.second << ";"
57-
<< std::endl;
56+
logFile_ << pattern.toString() << "freq=" << pair.second << ";" << '\n';
5857
}
5958
logFile_.flush();
6059
logFile_.close();

src/Fbgemm.cc

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,29 +227,39 @@ bool fbgemmOptimizedGConv(const conv_param_t<SPATIAL_DIM>& conv_p) {
227227
std::all_of(
228228
conv_p.K.begin(),
229229
conv_p.K.end(),
230-
std::bind(areEqual, std::placeholders::_1, 3)) &&
230+
[areEqual](auto&& PH1) {
231+
return areEqual(std::forward<decltype(PH1)>(PH1), 3);
232+
}) &&
231233

232234
std::all_of(
233235
conv_p.pad.begin(),
234236
conv_p.pad.end(),
235-
std::bind(areEqual, std::placeholders::_1, 1)) &&
237+
[areEqual](auto&& PH1) {
238+
return areEqual(std::forward<decltype(PH1)>(PH1), 1);
239+
}) &&
236240

237241
std::all_of(
238242
conv_p.dilation.begin(),
239243
conv_p.dilation.end(),
240-
std::bind(areEqual, std::placeholders::_1, 1)) &&
244+
[areEqual](auto&& PH1) {
245+
return areEqual(std::forward<decltype(PH1)>(PH1), 1);
246+
}) &&
241247

242248
// Height/Width strides should be the same and
243249
// should be either 1 or 2
244250
// Temporal stride can be anything.
245251
(std::all_of(
246252
conv_p.stride.begin() + SPATIAL_DIM - 2,
247253
conv_p.stride.end(),
248-
std::bind(areEqual, std::placeholders::_1, 1)) ||
254+
[areEqual](auto&& PH1) {
255+
return areEqual(std::forward<decltype(PH1)>(PH1), 1);
256+
}) ||
249257
std::all_of(
250258
conv_p.stride.begin() + SPATIAL_DIM - 2,
251259
conv_p.stride.end(),
252-
std::bind(areEqual, std::placeholders::_1, 2))) &&
260+
[areEqual](auto&& PH1) {
261+
return areEqual(std::forward<decltype(PH1)>(PH1), 2);
262+
})) &&
253263
!conv_p.transposed;
254264
}
255265

src/FbgemmI64.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ CodeGenBase<int64_t, int64_t, int64_t, int64_t>::getOrCreate(
382382
err = runtime().add(&fn, &code);
383383
}
384384
if (err) {
385-
cout << "Error: in fn add" << endl;
385+
cout << "Error: in fn add" << '\n';
386386
return nullptr;
387387
}
388388

src/GenerateI8Depthwise.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ GenI8Depthwise::jit_kernel_signature GenI8Depthwise::getOrCreate(
564564
err = runtime().add(&fn, &code);
565565
}
566566
if (err) {
567-
std::cout << "Error: in fn add" << std::endl;
567+
std::cout << "Error: in fn add" << '\n';
568568
return nullptr;
569569
}
570570

src/GenerateKernelDirectConvU8S8S32ACC32.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ DirectConvCodeGenBase<uint8_t, int8_t, int32_t, int32_t>::getOrCreateDirectConv(
408408
err = runtime().add(&fn, &code);
409409
}
410410
if (err) {
411-
std::cout << "Error: in fn add" << std::endl;
411+
std::cout << "Error: in fn add" << '\n';
412412
return nullptr;
413413
}
414414

@@ -777,7 +777,7 @@ DirectConvCodeGenBase<uint8_t, int8_t, int32_t, int32_t>::
777777
err = runtime().add(&fn, &code);
778778
}
779779
if (err) {
780-
std::cout << "Error: in fn add" << std::endl;
780+
std::cout << "Error: in fn add" << '\n';
781781
return nullptr;
782782
}
783783

src/GenerateKernelU8S8S32ACC16.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ CodeGenBase<uint8_t, int8_t, int32_t, int16_t>::getOrCreate<inst_set_t::avx2>(
329329
err = runtime().add(&fn, &code);
330330
}
331331
if (err) {
332-
std::cout << "Error: in fn add" << std::endl;
332+
std::cout << "Error: in fn add" << '\n';
333333
return nullptr;
334334
}
335335

0 commit comments

Comments
 (0)