Unverified Commit 5683e6a6 authored by Xuehai Pan's avatar Xuehai Pan Committed by GitHub
Browse files

[CI][Lint] Retire `format.sh` and add `clang-tidy` to GHA workflow (#1044)

* [Lint] Retire `format.sh` and add `clang-tidy` to GHA workflow

* chore: update clang-tidy settings

* chore: upgrade clang-format and clang-tidy version

* lint: resolve clang-tidy errors

* [Maint] restore format.sh

* [CI] pre-commit autoupdate

* [Minor] fix `command -v` usage
parent 151d9e6b
...@@ -496,8 +496,9 @@ private: ...@@ -496,8 +496,9 @@ private:
if (reduce_extent == 1) { if (reduce_extent == 1) {
// special case, no reduction is needed. // special case, no reduction is needed.
std::vector<Stmt> stores; std::vector<Stmt> stores;
stores.reserve(size);
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
stores.push_back(BufferStore(buffers[i], values[i], {0})); stores.emplace_back(BufferStore(buffers[i], values[i], {0}));
} }
return SeqStmt::Flatten(stores); return SeqStmt::Flatten(stores);
} }
...@@ -604,7 +605,7 @@ private: ...@@ -604,7 +605,7 @@ private:
// Load reduction values, no synchronization needed. // Load reduction values, no synchronization needed.
Array<PrimExpr> a, b; Array<PrimExpr> a, b;
for (int i = 0; i < n_buffers; ++i) { for (int i = 0; i < n_buffers; ++i) {
Buffer shared_buf = shared_bufs[i]; const Buffer &shared_buf = shared_bufs[i];
BufferLoad val(shared_buf, zero_indices); BufferLoad val(shared_buf, zero_indices);
ICHECK_EQ(val->dtype, dtypes[i]); ICHECK_EQ(val->dtype, dtypes[i]);
a.push_back(val); a.push_back(val);
...@@ -623,7 +624,7 @@ private: ...@@ -623,7 +624,7 @@ private:
// branch with a warp sync call inside. // branch with a warp sync call inside.
PrimExpr other = WarpShuffle(builtin::tvm_warp_shuffle_down(), PrimExpr other = WarpShuffle(builtin::tvm_warp_shuffle_down(),
mask_buffer, val, offset); mask_buffer, val, offset);
Buffer local_buf = local_bufs[i]; const Buffer &local_buf = local_bufs[i];
Stmt s = BufferStore(local_buf, other, zero_indices); Stmt s = BufferStore(local_buf, other, zero_indices);
seq->push_back(s); seq->push_back(s);
...@@ -639,7 +640,7 @@ private: ...@@ -639,7 +640,7 @@ private:
std::vector<Stmt> stores; std::vector<Stmt> stores;
stores.reserve(n_buffers); stores.reserve(n_buffers);
for (int i = 0; i < n_buffers; ++i) { for (int i = 0; i < n_buffers; ++i) {
Buffer buf = shared_bufs[i]; const Buffer &buf = shared_bufs[i];
stores.push_back(BufferStore(buf, ret[i], zero_indices)); stores.push_back(BufferStore(buf, ret[i], zero_indices));
} }
......
...@@ -477,7 +477,7 @@ tvm::transform::Pass MakePackedAPI() { ...@@ -477,7 +477,7 @@ tvm::transform::Pass MakePackedAPI() {
Map<GlobalVar, String> packed_func_methods; Map<GlobalVar, String> packed_func_methods;
for (const auto &[gvar, base_func] : mod->functions) { for (const auto &[gvar, base_func] : mod->functions) {
if (auto opt = base_func.as<PrimFunc>()) { if (auto opt = base_func.as<PrimFunc>()) {
auto prim_func = opt.value(); const auto &prim_func = opt.value();
if (auto global_symbol = RequiresPackedAPI(prim_func)) { if (auto global_symbol = RequiresPackedAPI(prim_func)) {
packed_func_methods.Set(gvar, global_symbol.value()); packed_func_methods.Set(gvar, global_symbol.value());
} }
......
...@@ -209,7 +209,7 @@ void TileLangStorageAccessVisitor::VisitStmt_(const ForNode *op) { ...@@ -209,7 +209,7 @@ void TileLangStorageAccessVisitor::VisitStmt_(const ForNode *op) {
bool IsThreadInvariant(const PrimExpr &cond) { bool IsThreadInvariant(const PrimExpr &cond) {
if (auto call = cond.as<CallNode>()) { if (auto call = cond.as<CallNode>()) {
if (auto opt_call_op = call->op.as<Op>()) { if (auto opt_call_op = call->op.as<Op>()) {
auto call_op = opt_call_op.value(); const auto &call_op = opt_call_op.value();
if (call_op.same_as(builtin::tvm_thread_invariant())) { if (call_op.same_as(builtin::tvm_thread_invariant())) {
return true; return true;
} }
......
...@@ -530,10 +530,11 @@ private: ...@@ -530,10 +530,11 @@ private:
block_stmt.push_back(block->body); block_stmt.push_back(block->body);
cur_id++; cur_id++;
} }
new_body.push_back(MakeGroupBlock(block_stmt.size() == 1 new_body.push_back(MakeGroupBlock(
? block_stmt[0] block_stmt.size() == 1 ? block_stmt[0]
: SeqStmt(std::move(block_stmt)), // NOLINTNEXTLINE(performance-move-const-arg)
annotations)); : SeqStmt(std::move(block_stmt)),
annotations));
} }
Array<Integer> order_anno; Array<Integer> order_anno;
Array<Integer> stage_anno; Array<Integer> stage_anno;
...@@ -697,10 +698,12 @@ private: ...@@ -697,10 +698,12 @@ private:
continue; continue;
if (marker_.GetRole(op->seq[i]) == Role::kBoth) { if (marker_.GetRole(op->seq[i]) == Role::kBoth) {
block_stmt.push_back(seq_transformed[i]); block_stmt.push_back(seq_transformed[i]);
new_body.push_back(MakeGroupBlock( new_body.push_back(
block_stmt.size() == 1 ? block_stmt[0] MakeGroupBlock(block_stmt.size() == 1
: SeqStmt(std::move(block_stmt)), ? block_stmt[0]
annotations)); // NOLINTNEXTLINE(performance-move-const-arg)
: SeqStmt(std::move(block_stmt)),
annotations));
continue; continue;
} }
} }
...@@ -734,10 +737,12 @@ private: ...@@ -734,10 +737,12 @@ private:
} }
} }
collector.Clear(); collector.Clear();
new_body.push_back(MakeGroupBlock( new_body.push_back(
block_stmt.size() == 1 ? block_stmt[0] MakeGroupBlock(block_stmt.size() == 1
: SeqStmt(std::move(block_stmt)), ? block_stmt[0]
annotations)); // NOLINTNEXTLINE(performance-move-const-arg)
: SeqStmt(std::move(block_stmt)),
annotations));
} }
} }
} else { // consumer case } else { // consumer case
...@@ -766,10 +771,11 @@ private: ...@@ -766,10 +771,11 @@ private:
} }
} }
} }
new_body.push_back(MakeGroupBlock(block_stmt.size() == 1 new_body.push_back(MakeGroupBlock(
? block_stmt[0] block_stmt.size() == 1 ? block_stmt[0]
: SeqStmt(std::move(block_stmt)), // NOLINTNEXTLINE(performance-move-const-arg)
annotations)); : SeqStmt(std::move(block_stmt)),
annotations));
} }
// Filter out the producer stmts // Filter out the producer stmts
int cur_id = 0; int cur_id = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment