From 884f4f81c4713b6cab78412e45ab570cdb9214c6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 26 Apr 2022 13:27:11 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- taichi/analysis/gen_offline_cache_key.cpp | 31 +++++++++++++---------- taichi/analysis/offline_cache_util.cpp | 3 +-- taichi/inc/frontend_statements.inc.h | 2 +- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/taichi/analysis/gen_offline_cache_key.cpp b/taichi/analysis/gen_offline_cache_key.cpp index e77d74dee1f4e..e2a336c6b6252 100644 --- a/taichi/analysis/gen_offline_cache_key.cpp +++ b/taichi/analysis/gen_offline_cache_key.cpp @@ -37,8 +37,10 @@ enum class ExternalFuncType : std::uint8_t { class ASTSerializer : public IRVisitor { public: - ASTSerializer(Program *prog, ExpressionPrinter *expr_printer, std::ostream *os) - : prog_(prog), os_(os), expr_printer_(expr_printer) { + ASTSerializer(Program *prog, + ExpressionPrinter *expr_printer, + std::ostream *os) + : prog_(prog), os_(os), expr_printer_(expr_printer) { this->allow_undefined_visitor = true; expr_printer_->set_ostream(os); } @@ -95,7 +97,8 @@ class ASTSerializer : public IRVisitor { emit(stmt->op_type); emit(stmt->snode); std::size_t count = stmt->indices.size(); - if (stmt->val.expr) ++count; + if (stmt->val.expr) + ++count; emit(count); for (const auto &i : stmt->indices.exprs) { emit(i); @@ -184,7 +187,8 @@ class ASTSerializer : public IRVisitor { } void visit(FrontendExternalFuncStmt *stmt) override { - // Note: The result of serializing FrontendExternalFuncStmt is not parsable now + // Note: The result of serializing FrontendExternalFuncStmt is not parsable + // now emit(StmtOpCode::FrontendExternalFuncStmt); if (stmt->so_func != nullptr) { emit(ExternalFuncType::SO); @@ -201,7 +205,8 @@ class ASTSerializer : public IRVisitor { } static void run(Program *prog, IRNode *ast, std::ostream *os) { - // Temporary: using ExpressionOfflineCacheKeyGenerator, which will be refactored + // Temporary: using ExpressionOfflineCacheKeyGenerator, which will be + // refactored ExpressionOfflineCacheKeyGenerator generator(prog); ASTSerializer serializer(prog, &generator, os); ast->accept(&serializer); @@ -221,10 +226,10 @@ class ASTSerializer : public IRVisitor { for (auto &[func, visited] : real_funcs_) { if (!visited) { visited = true; - func->ir->accept(this); // Maybe add new func + func->ir->accept(this); // Maybe add new func } } - } while(real_funcs_.size() > last_size); + } while (real_funcs_.size() > last_size); this->set_ostream(curr_os); expr_printer_->set_ostream(curr_os); emit(static_cast(real_funcs_.size())); @@ -243,7 +248,7 @@ class ASTSerializer : public IRVisitor { emit_bytes(string_pool_.data(), string_pool_.size()); } - template + template void emit_pod(const T &val) { static_assert(std::is_pod::value); TI_ASSERT(os_); @@ -255,7 +260,7 @@ class ASTSerializer : public IRVisitor { os_->write(bytes, len); } - template + template void emit(const std::unordered_map &map) { emit(static_cast(map.size())); for (const auto &[k, v] : map) { @@ -264,13 +269,13 @@ class ASTSerializer : public IRVisitor { } } - template + template void emit(const std::pair &pair) { emit(pair.first); emit(pair.second); } - template + template void emit(const std::map &map) { emit(static_cast(map.size())); for (const auto &[k, v] : map) { @@ -421,8 +426,8 @@ class ASTSerializer : public IRVisitor { Program *prog_{nullptr}; std::ostream *os_{nullptr}; ExpressionPrinter *expr_printer_{nullptr}; - std::unordered_set snode_tree_roots_; - std::unordered_map real_funcs_; + std::unordered_set snode_tree_roots_; + std::unordered_map real_funcs_; std::vector string_pool_; }; diff --git a/taichi/analysis/offline_cache_util.cpp b/taichi/analysis/offline_cache_util.cpp index b8701561e8553..140a3915df67a 100644 --- a/taichi/analysis/offline_cache_util.cpp +++ b/taichi/analysis/offline_cache_util.cpp @@ -153,8 +153,7 @@ std::string get_hashed_offline_cache_key(CompileConfig *config, std::string kernel_ast_string; if (kernel) { std::ostringstream oss; - gen_offline_cache_key(kernel->program, kernel->ir.get(), - &oss); + gen_offline_cache_key(kernel->program, kernel->ir.get(), &oss); kernel_ast_string = oss.str(); } diff --git a/taichi/inc/frontend_statements.inc.h b/taichi/inc/frontend_statements.inc.h index 8ead3044c6a21..cf61ef62e9eaa 100644 --- a/taichi/inc/frontend_statements.inc.h +++ b/taichi/inc/frontend_statements.inc.h @@ -12,4 +12,4 @@ PER_STATEMENT(FrontendEvalStmt) PER_STATEMENT(FrontendSNodeOpStmt) // activate, deactivate, append, clear PER_STATEMENT(FrontendAssertStmt) PER_STATEMENT(FrontendFuncDefStmt) -PER_STATEMENT(FrontendReturnStmt) \ No newline at end of file +PER_STATEMENT(FrontendReturnStmt)