Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[misc] Update pre-commit hooks #4713

Merged
merged 4 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
ci:
autoupdate_schedule: quarterly
autoupdate_commit_msg: '[misc] Update pre-commit hooks'

exclude: ^((tests/python/test_exception|.*/examples/.*)\.py$|external/)
repos:
- repo: https://github.com/google/yapf
rev: v0.31.0
rev: v0.32.0
hooks:
- id: yapf
additional_dependencies: [toml]

- repo: https://github.com/timothycrosley/isort
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v10.0.1
rev: v13.0.1
hooks:
- id: clang-format
exclude: .*\.json$

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: https://github.com/PyCQA/pylint
rev: v2.13.1
rev: v2.13.4
hooks:
- id: pylint
args: ['-rn', '-sn']
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ filterwarnings = [

[tool.yapf]
based_on_style = "pep8"
blank_line_before_nested_class_or_def = false
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ coverage
Pillow
pybind11
GitPython
yapf==0.31.0
yapf
distro
sourceinspect
isort
Expand Down
2 changes: 1 addition & 1 deletion taichi/backends/cc/cc_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ inline std::string unary_op_type_symbol(UnaryOpType op) {
}

template <typename... Args>
inline int execute(std::string fmt, Args &&... args) {
inline int execute(std::string fmt, Args &&...args) {
auto cmd = fmt::format(fmt, std::forward<Args>(args)...);
TI_TRACE("Executing command: {}", cmd);
int ret = std::system(cmd.c_str());
Expand Down
6 changes: 3 additions & 3 deletions taichi/backends/cc/codegen_cc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class CCTransformer : public IRVisitor {
static inline std::string invoke_libc(std::string name,
DataType dt,
std::string const &fmt,
Args &&... args) {
Args &&...args) {
auto arguments = fmt::format(fmt, std::forward<Args>(args)...);
return invoke_libc(name, dt, arguments);
}
Expand Down Expand Up @@ -594,12 +594,12 @@ class CCTransformer : public IRVisitor {
}

template <typename... Args>
void emit(std::string f, Args &&... args) {
void emit(std::string f, Args &&...args) {
line_appender_.append(std::move(f), std::move(args)...);
}

template <typename... Args>
void emit_header(std::string f, Args &&... args) {
void emit_header(std::string f, Args &&...args) {
line_appender_header_.append(std::move(f), std::move(args)...);
}
}; // namespace cccp
Expand Down
2 changes: 1 addition & 1 deletion taichi/backends/cc/struct_cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CCLayoutGen {
void generate_types(SNode *snode);

template <typename... Args>
void emit(std::string f, Args &&... args) {
void emit(std::string f, Args &&...args) {
line_appender_.append(std::move(f), std::move(args)...);
}

Expand Down
2 changes: 1 addition & 1 deletion taichi/backends/metal/codegen_metal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ class KernelCodegenImpl : public IRVisitor {
}

template <typename... Args>
void emit(std::string f, Args &&... args) {
void emit(std::string f, Args &&...args) {
current_appender().append(std::move(f), std::forward<Args>(args)...);
}

Expand Down
4 changes: 2 additions & 2 deletions taichi/backends/metal/struct_metal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ class StructCompiler {
}

template <typename... Args>
void emit(std::string f, Args &&... args) {
void emit(std::string f, Args &&...args) {
line_appender_.append(std::move(f), std::move(args)...);
}

Expand Down Expand Up @@ -397,7 +397,7 @@ class RuntimeModuleCompiler {
}

template <typename... Args>
void emit(std::string f, Args &&... args) {
void emit(std::string f, Args &&...args) {
line_appender_.append(std::move(f), std::move(args)...);
}

Expand Down
2 changes: 1 addition & 1 deletion taichi/backends/opengl/codegen_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class KernelGen : public IRVisitor {
std::unordered_set<std::string> loaded_args_;

template <typename... Args>
void emit(std::string f, Args &&... args) {
void emit(std::string f, Args &&...args) {
line_appender_.append(std::move(f), std::move(args)...);
}

Expand Down
20 changes: 10 additions & 10 deletions taichi/codegen/spirv/spirv_ir_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace spirv {
template <bool stop, std::size_t I, typename F>
struct for_each_dispatcher {
template <typename T, typename... Args>
static void run(const F &f, T &&value, Args &&... args) { // NOLINT(*)
static void run(const F &f, T &&value, Args &&...args) { // NOLINT(*)
f(I, std::forward<T>(value));
for_each_dispatcher<sizeof...(Args) == 0, (I + 1), F>::run(
f, std::forward<Args>(args)...);
Expand All @@ -31,7 +31,7 @@ struct for_each_dispatcher<true, I, F> {
};

template <typename F, typename... Args>
inline void for_each(const F &f, Args &&... args) { // NOLINT(*)
inline void for_each(const F &f, Args &&...args) { // NOLINT(*)
for_each_dispatcher<sizeof...(Args) == 0, 0, F>::run(
f, std::forward<Args>(args)...);
}
Expand Down Expand Up @@ -165,7 +165,7 @@ class InstrBuilder {
}

template <typename... Args>
InstrBuilder &add_seq(Args &&... args) {
InstrBuilder &add_seq(Args &&...args) {
AddSeqHelper helper;
helper.builder = this;
for_each(helper, std::forward<Args>(args)...);
Expand Down Expand Up @@ -207,29 +207,29 @@ class IRBuilder {
}

template <typename... Args>
void debug(spv::Op op, Args &&... args) {
void debug(spv::Op op, Args &&...args) {
ib_.begin(op).add_seq(std::forward<Args>(args)...).commit(&debug_);
}

template <typename... Args>
void execution_mode(Value func, Args &&... args) {
void execution_mode(Value func, Args &&...args) {
ib_.begin(spv::OpExecutionMode)
.add_seq(func, std::forward<Args>(args)...)
.commit(&exec_mode_);
}

template <typename... Args>
void decorate(spv::Op op, Args &&... args) {
void decorate(spv::Op op, Args &&...args) {
ib_.begin(op).add_seq(std::forward<Args>(args)...).commit(&decorate_);
}

template <typename... Args>
void declare_global(spv::Op op, Args &&... args) {
void declare_global(spv::Op op, Args &&...args) {
ib_.begin(op).add_seq(std::forward<Args>(args)...).commit(&global_);
}

template <typename... Args>
Instr make_inst(spv::Op op, Args &&... args) {
Instr make_inst(spv::Op op, Args &&...args) {
return ib_.begin(op)
.add_seq(std::forward<Args>(args)...)
.commit(&function_);
Expand Down Expand Up @@ -267,7 +267,7 @@ class IRBuilder {

// Make a new SSA value
template <typename... Args>
Value make_value(spv::Op op, const SType &out_type, Args &&... args) {
Value make_value(spv::Op op, const SType &out_type, Args &&...args) {
Value val = new_value(out_type, ValueKind::kNormal);
make_inst(op, out_type, val, std::forward<Args>(args)...);
if (out_type.flag == TypeKind::kPtr) {
Expand Down Expand Up @@ -421,7 +421,7 @@ class IRBuilder {

// Create a GLSL450 call
template <typename... Args>
Value call_glsl450(const SType &ret_type, uint32_t inst_id, Args &&... args) {
Value call_glsl450(const SType &ret_type, uint32_t inst_id, Args &&...args) {
Value val = new_value(ret_type, ValueKind::kNormal);
ib_.begin(spv::OpExtInst)
.add_seq(ret_type, val, ext_glsl450_, inst_id)
Expand Down
4 changes: 2 additions & 2 deletions taichi/common/serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ typename std::enable_if<!std::is_same<SER, TextSerializer>::value, void>::type
serialize_kv_impl(SER &ser,
const std::array<std::string_view, N> &keys,
T &&head,
Args &&... rest) {
Args &&...rest) {
constexpr auto i = (N - 1 - sizeof...(Args));
std::string key{keys[i]};
ser(key.c_str(), head);
Expand All @@ -126,7 +126,7 @@ typename std::enable_if<std::is_same<SER, TextSerializer>::value, void>::type
serialize_kv_impl(SER &ser,
const std::array<std::string_view, N> &keys,
T &&head,
Args &&... rest) {
Args &&...rest) {
constexpr auto i = (N - 1 - sizeof...(Args));
std::string key{keys[i]};
ser(key.c_str(), head, true);
Expand Down
2 changes: 1 addition & 1 deletion taichi/ir/control_flow_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class ControlFlowGraph {
int final_node{0};

template <typename... Args>
CFGNode *push_back(Args &&... args) {
CFGNode *push_back(Args &&...args) {
nodes.emplace_back(std::make_unique<CFGNode>(std::forward<Args>(args)...));
return nodes.back().get();
}
Expand Down
2 changes: 1 addition & 1 deletion taichi/ir/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Expr {
Expr operator!();

template <typename T, typename... Args>
static Expr make(Args &&... args) {
static Expr make(Args &&...args) {
return Expr(std::make_shared<T>(std::forward<Args>(args)...));
}

Expand Down
2 changes: 1 addition & 1 deletion taichi/ir/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Expression {
}

template <typename T, typename... Args>
T *push_back(Args &&... args) {
T *push_back(Args &&...args) {
return stmts.push_back<T>(std::forward<Args>(args)...);
}

Expand Down
2 changes: 1 addition & 1 deletion taichi/ir/expression_printer.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class ExpressionHumanFriendlyPrinter : public ExpressionVisitor {

private:
template <typename... Args>
void emit(Args &&... args) {
void emit(Args &&...args) {
TI_ASSERT(os_);
(*os_ << ... << std::forward<Args>(args));
}
Expand Down
10 changes: 5 additions & 5 deletions taichi/ir/ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class VecStatement {
Stmt *push_back(pStmt &&stmt);

template <typename T, typename... Args>
T *push_back(Args &&... args) {
T *push_back(Args &&...args) {
auto up = std::make_unique<T>(std::forward<Args>(args)...);
auto ptr = up.get();
stmts.push_back(std::move(up));
Expand Down Expand Up @@ -458,7 +458,7 @@ class StmtFieldManager {
void operator()(const char *key, T &&value);

template <typename T, typename... Args>
void operator()(const char *key_, T &&t, Args &&... rest) {
void operator()(const char *key_, T &&t, Args &&...rest) {
std::string key(key_);
size_t pos = key.find(',');
std::string first_name = key.substr(0, pos);
Expand Down Expand Up @@ -572,12 +572,12 @@ class Stmt : public IRNode {
}

template <typename T, typename... Args>
static std::unique_ptr<T> make_typed(Args &&... args) {
static std::unique_ptr<T> make_typed(Args &&...args) {
return std::make_unique<T>(std::forward<Args>(args)...);
}

template <typename T, typename... Args>
static pStmt make(Args &&... args) {
static pStmt make(Args &&...args) {
return make_typed<T>(std::forward<Args>(args)...);
}

Expand Down Expand Up @@ -656,7 +656,7 @@ class Block : public IRNode {
}

template <typename T, typename... Args>
Stmt *push_back(Args &&... args) {
Stmt *push_back(Args &&...args) {
auto stmt = std::make_unique<T>(std::forward<Args>(args)...);
stmt->parent = this;
statements.emplace_back(std::move(stmt));
Expand Down
2 changes: 1 addition & 1 deletion taichi/ir/ir_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class IRBuilder {

// Print values and strings. Arguments can be Stmt* or std::string.
template <typename... Args>
PrintStmt *create_print(Args &&... args) {
PrintStmt *create_print(Args &&...args) {
return insert(Stmt::make_typed<PrintStmt>(std::forward<Args>(args)...));
}

Expand Down
8 changes: 4 additions & 4 deletions taichi/ir/statements.h
Original file line number Diff line number Diff line change
Expand Up @@ -691,13 +691,13 @@ class PrintStmt : public Stmt {
}

template <typename... Args>
PrintStmt(Stmt *t, Args &&... args)
PrintStmt(Stmt *t, Args &&...args)
: contents(make_entries(t, std::forward<Args>(args)...)) {
TI_STMT_REG_FIELDS;
}

template <typename... Args>
PrintStmt(const std::string &str, Args &&... args)
PrintStmt(const std::string &str, Args &&...args)
: contents(make_entries(str, std::forward<Args>(args)...)) {
TI_STMT_REG_FIELDS;
}
Expand All @@ -712,13 +712,13 @@ class PrintStmt : public Stmt {
template <typename T, typename... Args>
static void make_entries_helper(std::vector<PrintStmt::EntryType> &entries,
T &&t,
Args &&... values) {
Args &&...values) {
entries.push_back(EntryType{t});
make_entries_helper(entries, std::forward<Args>(values)...);
}

template <typename... Args>
static std::vector<EntryType> make_entries(Args &&... values) {
static std::vector<EntryType> make_entries(Args &&...values) {
std::vector<EntryType> ret;
make_entries_helper(ret, std::forward<Args>(values)...);
return ret;
Expand Down
2 changes: 1 addition & 1 deletion taichi/jit/jit_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class JITModule {
}

template <typename... Args, typename T>
static std::vector<void *> get_arg_pointers(T &t, Args &... args) {
static std::vector<void *> get_arg_pointers(T &t, Args &...args) {
auto ret = get_arg_pointers(args...);
ret.insert(ret.begin(), &t);
return ret;
Expand Down
6 changes: 3 additions & 3 deletions taichi/llvm/llvm_codegen_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ class LLVMModuleBuilder {
template <typename... Args>
llvm::Value *call(llvm::IRBuilder<> *builder,
const std::string &func_name,
Args &&... args) {
Args &&...args) {
auto func = get_runtime_function(func_name);
auto arglist = std::vector<llvm::Value *>({args...});
check_func_call_signature(func, arglist);
return builder->CreateCall(func, arglist);
}

template <typename... Args>
llvm::Value *call(const std::string &func_name, Args &&... args) {
llvm::Value *call(const std::string &func_name, Args &&...args) {
return call(this->builder.get(), func_name, std::forward<Args>(args)...);
}

Expand Down Expand Up @@ -183,7 +183,7 @@ class RuntimeObject {
}

template <typename... Args>
llvm::Value *call(const std::string &func_name, Args &&... args) {
llvm::Value *call(const std::string &func_name, Args &&...args) {
auto func = get_func(func_name);
auto arglist = std::vector<llvm::Value *>({ptr, args...});
check_func_call_signature(func, arglist);
Expand Down
Loading