From 09bba32f153ce01f76bd274d72e8bf62f1c58f14 Mon Sep 17 00:00:00 2001 From: enkilee Date: Mon, 3 Jul 2023 05:37:43 +0000 Subject: [PATCH 1/5] fix cpplint --- paddle/cinn/backends/nvrtc/header_generator.cc | 2 +- paddle/cinn/common/arithmatic.h | 4 ++-- paddle/cinn/common/target.cc | 5 ----- paddle/cinn/common/type.cc | 2 -- paddle/cinn/frontend/computation.h | 5 +++++ paddle/cinn/frontend/pass/pass_test_helper.h | 5 +++++ paddle/cinn/frontend/pass/transpose_folding_base.h | 5 +++++ paddle/cinn/hlir/op/contrib/logical_right_shift.cc | 1 + paddle/cinn/hlir/op/contrib/reciprocal.cc | 1 + paddle/cinn/hlir/op/custom_call.cc | 2 +- paddle/cinn/hlir/op/transform.cc | 1 - paddle/cinn/hlir/pass/infershape.h | 5 +++++ paddle/cinn/poly/domain_add_unit_loop_mutator.h | 5 +++++ paddle/cinn/runtime/cpu/mkldnn_math.h | 2 +- paddle/cinn/runtime/cuda/test_util.h | 5 +++++ paddle/cinn/runtime/tiny_runtime.cc | 2 +- 16 files changed, 38 insertions(+), 14 deletions(-) diff --git a/paddle/cinn/backends/nvrtc/header_generator.cc b/paddle/cinn/backends/nvrtc/header_generator.cc index 328b0ce1f53be..874cddc7e905e 100644 --- a/paddle/cinn/backends/nvrtc/header_generator.cc +++ b/paddle/cinn/backends/nvrtc/header_generator.cc @@ -14,8 +14,8 @@ #include "paddle/cinn/backends/nvrtc/header_generator.h" +#include #include "glog/logging.h" -#include "jitify.hpp" namespace cinn { namespace backends { diff --git a/paddle/cinn/common/arithmatic.h b/paddle/cinn/common/arithmatic.h index e73a9bac3ede2..d24d17ab317e2 100644 --- a/paddle/cinn/common/arithmatic.h +++ b/paddle/cinn/common/arithmatic.h @@ -18,8 +18,6 @@ */ #pragma once -#include "paddle/cinn/ir/ir.h" - #include #include @@ -28,6 +26,8 @@ #include #include +#include "paddle/cinn/ir/ir.h" + #ifdef As #undef As #endif diff --git a/paddle/cinn/common/target.cc b/paddle/cinn/common/target.cc index 42a130163a130..95d57c3172aa3 100644 --- a/paddle/cinn/common/target.cc +++ b/paddle/cinn/common/target.cc @@ -23,11 +23,6 @@ #include "paddle/cinn/common/target.h" #include "paddle/cinn/runtime/cinn_runtime.h" -#ifdef CINN_WITH_CUDA -#include -#include -#endif - namespace cinn { namespace common { diff --git a/paddle/cinn/common/type.cc b/paddle/cinn/common/type.cc index ad5c8412d950b..2b15575708164 100644 --- a/paddle/cinn/common/type.cc +++ b/paddle/cinn/common/type.cc @@ -19,8 +19,6 @@ #include #include -#include "type.h" - namespace cinn { namespace common { diff --git a/paddle/cinn/frontend/computation.h b/paddle/cinn/frontend/computation.h index c464cb40d2a5c..2cf7a5158574a 100644 --- a/paddle/cinn/frontend/computation.h +++ b/paddle/cinn/frontend/computation.h @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifndef PADDLE_CINN_FRONTEND_COMPUTATION_H_ +#define PADDLE_CINN_FRONTEND_COMPUTATION_H_ + #include #include "paddle/cinn/frontend/net_builder.h" @@ -169,3 +172,5 @@ class CinnComputation { } // namespace frontend } // namespace cinn + +#endif // PADDLE_CINN_FRONTEND_COMPUTATION_H_ diff --git a/paddle/cinn/frontend/pass/pass_test_helper.h b/paddle/cinn/frontend/pass/pass_test_helper.h index 5c57835e1f161..0af169088a6ca 100644 --- a/paddle/cinn/frontend/pass/pass_test_helper.h +++ b/paddle/cinn/frontend/pass/pass_test_helper.h @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifndef PADDLE_CINN_FRONTEND_PASS_PASS_TEST_HELPER_H_ +#define PADDLE_CINN_FRONTEND_PASS_PASS_TEST_HELPER_H_ + #include #include @@ -240,3 +243,5 @@ inline bool CompareProgramPassResult( } // namespace frontend } // namespace cinn + +#endif // PADDLE_CINN_FRONTEND_PASS_PASS_TEST_HELPER_H_ diff --git a/paddle/cinn/frontend/pass/transpose_folding_base.h b/paddle/cinn/frontend/pass/transpose_folding_base.h index fbcb384b1704d..a9e7bf7cd9aa2 100644 --- a/paddle/cinn/frontend/pass/transpose_folding_base.h +++ b/paddle/cinn/frontend/pass/transpose_folding_base.h @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifndef PADDLE_CINN_FRONTEND_PASS_TRANSPOSE_FOLDING_BASE_H_ +#define PADDLE_CINN_FRONTEND_PASS_TRANSPOSE_FOLDING_BASE_H_ + #include #include @@ -228,3 +231,5 @@ class TransposeFoldingBase : public ProgramPass { }; } // namespace cinn::frontend::pass + +#endif // PADDLE_CINN_FRONTEND_PASS_TRANSPOSE_FOLDING_BASE_H_ diff --git a/paddle/cinn/hlir/op/contrib/logical_right_shift.cc b/paddle/cinn/hlir/op/contrib/logical_right_shift.cc index 68f117aad4956..1f16d2195c611 100644 --- a/paddle/cinn/hlir/op/contrib/logical_right_shift.cc +++ b/paddle/cinn/hlir/op/contrib/logical_right_shift.cc @@ -26,6 +26,7 @@ #include "paddle/cinn/hlir/framework/node.h" #include "paddle/cinn/hlir/framework/op.h" #include "paddle/cinn/hlir/framework/op_strategy.h" +#include "paddle/cinn/hlir/op/contrib/logical_right_shift.h" #include "paddle/cinn/hlir/op/op_util.h" #include "paddle/cinn/hlir/pe/ir_schedule_pe.h" #include "paddle/cinn/hlir/pe/nn.h" diff --git a/paddle/cinn/hlir/op/contrib/reciprocal.cc b/paddle/cinn/hlir/op/contrib/reciprocal.cc index 09d180601ac10..50fbba762342a 100644 --- a/paddle/cinn/hlir/op/contrib/reciprocal.cc +++ b/paddle/cinn/hlir/op/contrib/reciprocal.cc @@ -26,6 +26,7 @@ #include "paddle/cinn/hlir/framework/node.h" #include "paddle/cinn/hlir/framework/op.h" #include "paddle/cinn/hlir/framework/op_strategy.h" +#include "paddle/cinn/hlir/op/contrib/reciprocal.h" #include "paddle/cinn/hlir/op/op_util.h" #include "paddle/cinn/hlir/pe/ir_schedule_pe.h" #include "paddle/cinn/hlir/pe/nn.h" diff --git a/paddle/cinn/hlir/op/custom_call.cc b/paddle/cinn/hlir/op/custom_call.cc index c109df2ec2866..5f272b98c226a 100644 --- a/paddle/cinn/hlir/op/custom_call.cc +++ b/paddle/cinn/hlir/op/custom_call.cc @@ -27,7 +27,7 @@ #include "paddle/cinn/utils/string.h" #ifdef CINN_WITH_CUDNN -#include "cudnn.h" +#include #endif namespace cinn { diff --git a/paddle/cinn/hlir/op/transform.cc b/paddle/cinn/hlir/op/transform.cc index 1f362dc76fce4..78d24cba7035d 100644 --- a/paddle/cinn/hlir/op/transform.cc +++ b/paddle/cinn/hlir/op/transform.cc @@ -25,7 +25,6 @@ #include "paddle/cinn/hlir/pe/ir_schedule_pe.h" #include "paddle/cinn/hlir/pe/nn.h" #include "paddle/cinn/hlir/pe/schedule.h" -#include "paddle/cinn/hlir/pe/transform.h" #include "paddle/cinn/ir/ir_printer.h" #include "paddle/cinn/utils/string.h" diff --git a/paddle/cinn/hlir/pass/infershape.h b/paddle/cinn/hlir/pass/infershape.h index a9b9c8a528ee7..1ded5024c96a9 100644 --- a/paddle/cinn/hlir/pass/infershape.h +++ b/paddle/cinn/hlir/pass/infershape.h @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifndef PADDLE_CINN_HLIR_PASS_INFERSHAPE_H_ +#define PADDLE_CINN_HLIR_PASS_INFERSHAPE_H_ + #include "paddle/cinn/common/graph_utils.h" #include "paddle/cinn/hlir/framework/graph.h" #include "paddle/cinn/hlir/framework/pass.h" @@ -28,3 +31,5 @@ void InferShape( } // namespace pass } // namespace hlir } // namespace cinn + +#endif // PADDLE_CINN_HLIR_PASS_INFERSHAPE_H_ diff --git a/paddle/cinn/poly/domain_add_unit_loop_mutator.h b/paddle/cinn/poly/domain_add_unit_loop_mutator.h index 0b2ce648b760c..168e16c169673 100644 --- a/paddle/cinn/poly/domain_add_unit_loop_mutator.h +++ b/paddle/cinn/poly/domain_add_unit_loop_mutator.h @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifndef PADDLE_CINN_POLY_DOMAIN_ADD_UNIT_LOOP_MUTATOR_H_ +#define PADDLE_CINN_POLY_DOMAIN_ADD_UNIT_LOOP_MUTATOR_H_ + #include #include @@ -50,3 +53,5 @@ class DomainAddUnitLoopMutator : public ir::IRMutator<> { } // namespace poly } // namespace cinn + +#endif // PADDLE_CINN_POLY_DOMAIN_ADD_UNIT_LOOP_MUTATOR_H_ diff --git a/paddle/cinn/runtime/cpu/mkldnn_math.h b/paddle/cinn/runtime/cpu/mkldnn_math.h index c8cb49c1cc329..6d438fd627f47 100644 --- a/paddle/cinn/runtime/cpu/mkldnn_math.h +++ b/paddle/cinn/runtime/cpu/mkldnn_math.h @@ -16,7 +16,7 @@ #include "paddle/cinn/runtime/cinn_runtime.h" #ifdef CINN_WITH_MKLDNN -#include "dnnl.hpp" +#include #endif // define some C APIs diff --git a/paddle/cinn/runtime/cuda/test_util.h b/paddle/cinn/runtime/cuda/test_util.h index 7a5683471dc3c..8e27f29a646b6 100644 --- a/paddle/cinn/runtime/cuda/test_util.h +++ b/paddle/cinn/runtime/cuda/test_util.h @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifndef PADDLE_CINN_RUNTIME_CUDA_TEST_UTIL_H_ +#define PADDLE_CINN_RUNTIME_CUDA_TEST_UTIL_H_ + #include #include @@ -54,3 +57,5 @@ class Vector { } // namespace cuda } // namespace runtime } // namespace cinn + +#endif // PADDLE_CINN_RUNTIME_CUDA_TEST_UTIL_H_ diff --git a/paddle/cinn/runtime/tiny_runtime.cc b/paddle/cinn/runtime/tiny_runtime.cc index 65bb07759c034..13ca1ea487bd3 100644 --- a/paddle/cinn/runtime/tiny_runtime.cc +++ b/paddle/cinn/runtime/tiny_runtime.cc @@ -21,7 +21,7 @@ #include #include -#include "cinn_runtime.h" +#include "paddle/cinn/runtime/cinn_runtime.h" extern "C" { int max_num_workers = std::thread::hardware_concurrency(); From e2a24073326b270938fb6425445c3f446f404e8a Mon Sep 17 00:00:00 2001 From: enkilee Date: Mon, 3 Jul 2023 07:40:02 +0000 Subject: [PATCH 2/5] fix --- paddle/cinn/backends/nvrtc/header_generator.cc | 2 +- paddle/cinn/frontend/computation.h | 6 +----- paddle/cinn/frontend/pass/pass_test_helper.h | 5 +---- paddle/cinn/frontend/pass/transpose_folding_base.h | 5 +---- paddle/cinn/hlir/pass/infershape.h | 5 +---- paddle/cinn/poly/domain_add_unit_loop_mutator.h | 5 +---- paddle/cinn/runtime/cpu/mkldnn_math.h | 2 +- paddle/cinn/runtime/cuda/test_util.h | 6 +----- 8 files changed, 8 insertions(+), 28 deletions(-) diff --git a/paddle/cinn/backends/nvrtc/header_generator.cc b/paddle/cinn/backends/nvrtc/header_generator.cc index 874cddc7e905e..d4b2b9504673f 100644 --- a/paddle/cinn/backends/nvrtc/header_generator.cc +++ b/paddle/cinn/backends/nvrtc/header_generator.cc @@ -14,8 +14,8 @@ #include "paddle/cinn/backends/nvrtc/header_generator.h" -#include #include "glog/logging.h" +#include "jitify.hpp" // NOLINT namespace cinn { namespace backends { diff --git a/paddle/cinn/frontend/computation.h b/paddle/cinn/frontend/computation.h index 2cf7a5158574a..8b16f9483320f 100644 --- a/paddle/cinn/frontend/computation.h +++ b/paddle/cinn/frontend/computation.h @@ -12,9 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef PADDLE_CINN_FRONTEND_COMPUTATION_H_ -#define PADDLE_CINN_FRONTEND_COMPUTATION_H_ - +#pragma once #include #include "paddle/cinn/frontend/net_builder.h" @@ -172,5 +170,3 @@ class CinnComputation { } // namespace frontend } // namespace cinn - -#endif // PADDLE_CINN_FRONTEND_COMPUTATION_H_ diff --git a/paddle/cinn/frontend/pass/pass_test_helper.h b/paddle/cinn/frontend/pass/pass_test_helper.h index 0af169088a6ca..8215703c0907f 100644 --- a/paddle/cinn/frontend/pass/pass_test_helper.h +++ b/paddle/cinn/frontend/pass/pass_test_helper.h @@ -12,8 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef PADDLE_CINN_FRONTEND_PASS_PASS_TEST_HELPER_H_ -#define PADDLE_CINN_FRONTEND_PASS_PASS_TEST_HELPER_H_ +#pragma once #include #include @@ -243,5 +242,3 @@ inline bool CompareProgramPassResult( } // namespace frontend } // namespace cinn - -#endif // PADDLE_CINN_FRONTEND_PASS_PASS_TEST_HELPER_H_ diff --git a/paddle/cinn/frontend/pass/transpose_folding_base.h b/paddle/cinn/frontend/pass/transpose_folding_base.h index a9e7bf7cd9aa2..4acc8e4f6d1f6 100644 --- a/paddle/cinn/frontend/pass/transpose_folding_base.h +++ b/paddle/cinn/frontend/pass/transpose_folding_base.h @@ -12,8 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef PADDLE_CINN_FRONTEND_PASS_TRANSPOSE_FOLDING_BASE_H_ -#define PADDLE_CINN_FRONTEND_PASS_TRANSPOSE_FOLDING_BASE_H_ +#pragma once #include @@ -231,5 +230,3 @@ class TransposeFoldingBase : public ProgramPass { }; } // namespace cinn::frontend::pass - -#endif // PADDLE_CINN_FRONTEND_PASS_TRANSPOSE_FOLDING_BASE_H_ diff --git a/paddle/cinn/hlir/pass/infershape.h b/paddle/cinn/hlir/pass/infershape.h index 1ded5024c96a9..7ed0ca5fe78ae 100644 --- a/paddle/cinn/hlir/pass/infershape.h +++ b/paddle/cinn/hlir/pass/infershape.h @@ -12,8 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef PADDLE_CINN_HLIR_PASS_INFERSHAPE_H_ -#define PADDLE_CINN_HLIR_PASS_INFERSHAPE_H_ +#pragma once #include "paddle/cinn/common/graph_utils.h" #include "paddle/cinn/hlir/framework/graph.h" @@ -31,5 +30,3 @@ void InferShape( } // namespace pass } // namespace hlir } // namespace cinn - -#endif // PADDLE_CINN_HLIR_PASS_INFERSHAPE_H_ diff --git a/paddle/cinn/poly/domain_add_unit_loop_mutator.h b/paddle/cinn/poly/domain_add_unit_loop_mutator.h index 168e16c169673..6c0a289ef3675 100644 --- a/paddle/cinn/poly/domain_add_unit_loop_mutator.h +++ b/paddle/cinn/poly/domain_add_unit_loop_mutator.h @@ -12,8 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef PADDLE_CINN_POLY_DOMAIN_ADD_UNIT_LOOP_MUTATOR_H_ -#define PADDLE_CINN_POLY_DOMAIN_ADD_UNIT_LOOP_MUTATOR_H_ +#pragma once #include #include @@ -53,5 +52,3 @@ class DomainAddUnitLoopMutator : public ir::IRMutator<> { } // namespace poly } // namespace cinn - -#endif // PADDLE_CINN_POLY_DOMAIN_ADD_UNIT_LOOP_MUTATOR_H_ diff --git a/paddle/cinn/runtime/cpu/mkldnn_math.h b/paddle/cinn/runtime/cpu/mkldnn_math.h index 6d438fd627f47..8e6b200378873 100644 --- a/paddle/cinn/runtime/cpu/mkldnn_math.h +++ b/paddle/cinn/runtime/cpu/mkldnn_math.h @@ -16,7 +16,7 @@ #include "paddle/cinn/runtime/cinn_runtime.h" #ifdef CINN_WITH_MKLDNN -#include +#include "dnnl.hpp" // NOLINT #endif // define some C APIs diff --git a/paddle/cinn/runtime/cuda/test_util.h b/paddle/cinn/runtime/cuda/test_util.h index 8e27f29a646b6..71786653b49dd 100644 --- a/paddle/cinn/runtime/cuda/test_util.h +++ b/paddle/cinn/runtime/cuda/test_util.h @@ -12,9 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef PADDLE_CINN_RUNTIME_CUDA_TEST_UTIL_H_ -#define PADDLE_CINN_RUNTIME_CUDA_TEST_UTIL_H_ - +#pragma once #include #include @@ -57,5 +55,3 @@ class Vector { } // namespace cuda } // namespace runtime } // namespace cinn - -#endif // PADDLE_CINN_RUNTIME_CUDA_TEST_UTIL_H_ From 5d7f969948a080ab1bdf6dc4692aa2c380dcee92 Mon Sep 17 00:00:00 2001 From: SigureMo Date: Mon, 3 Jul 2023 23:50:12 +0800 Subject: [PATCH 3/5] part 1, [build/include_order] --- .pre-commit-config.yaml | 5 ---- .../cinn/backends/nvrtc/header_generator.cc | 2 +- paddle/cinn/common/target.cc | 5 ++++ paddle/cinn/common/type.cc | 2 ++ paddle/cinn/frontend/computation.h | 1 - paddle/cinn/frontend/pass/pass_test_helper.h | 4 +-- .../frontend/pass/transpose_folding_base.h | 2 -- .../hlir/op/contrib/logical_right_shift.cc | 1 - paddle/cinn/hlir/op/contrib/reciprocal.cc | 1 - paddle/cinn/hlir/op/custom_call.cc | 2 +- paddle/cinn/hlir/op/transform.cc | 1 + paddle/cinn/hlir/pass/infershape.h | 2 -- .../cinn/poly/domain_add_unit_loop_mutator.h | 2 -- paddle/cinn/runtime/cpu/mkldnn_math.h | 2 +- paddle/cinn/runtime/cuda/test_util.h | 1 - paddle/cinn/runtime/tiny_runtime.cc | 26 +++++++++---------- 16 files changed, 25 insertions(+), 34 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 481f05c46e8e5..fa4765625d79f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -99,11 +99,6 @@ repos: - --extensions=c,cc,cxx,cpp,cu,cuh,h,hpp,hxx,kps - --filter=-readability/fn_size,-build/include_what_you_use,-build/c++11,-whitespace/parens - --quiet - exclude: | - (?x)^( - paddle/cinn/.+| - test/cpp/cinn/.+ - )$ # For CMake files - repo: local hooks: diff --git a/paddle/cinn/backends/nvrtc/header_generator.cc b/paddle/cinn/backends/nvrtc/header_generator.cc index d4b2b9504673f..328b0ce1f53be 100644 --- a/paddle/cinn/backends/nvrtc/header_generator.cc +++ b/paddle/cinn/backends/nvrtc/header_generator.cc @@ -15,7 +15,7 @@ #include "paddle/cinn/backends/nvrtc/header_generator.h" #include "glog/logging.h" -#include "jitify.hpp" // NOLINT +#include "jitify.hpp" namespace cinn { namespace backends { diff --git a/paddle/cinn/common/target.cc b/paddle/cinn/common/target.cc index 95d57c3172aa3..42a130163a130 100644 --- a/paddle/cinn/common/target.cc +++ b/paddle/cinn/common/target.cc @@ -23,6 +23,11 @@ #include "paddle/cinn/common/target.h" #include "paddle/cinn/runtime/cinn_runtime.h" +#ifdef CINN_WITH_CUDA +#include +#include +#endif + namespace cinn { namespace common { diff --git a/paddle/cinn/common/type.cc b/paddle/cinn/common/type.cc index 2b15575708164..ad5c8412d950b 100644 --- a/paddle/cinn/common/type.cc +++ b/paddle/cinn/common/type.cc @@ -19,6 +19,8 @@ #include #include +#include "type.h" + namespace cinn { namespace common { diff --git a/paddle/cinn/frontend/computation.h b/paddle/cinn/frontend/computation.h index 8b16f9483320f..c464cb40d2a5c 100644 --- a/paddle/cinn/frontend/computation.h +++ b/paddle/cinn/frontend/computation.h @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#pragma once #include #include "paddle/cinn/frontend/net_builder.h" diff --git a/paddle/cinn/frontend/pass/pass_test_helper.h b/paddle/cinn/frontend/pass/pass_test_helper.h index 8215703c0907f..e56746a86368a 100644 --- a/paddle/cinn/frontend/pass/pass_test_helper.h +++ b/paddle/cinn/frontend/pass/pass_test_helper.h @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#pragma once - #include #include @@ -145,7 +143,7 @@ inline std::vector RunProgram( struct OptimizeConfig { struct PassGroup; - OptimizeConfig(const PassGroup& program_passes) + explicit OptimizeConfig(const PassGroup& program_passes) : program_passes{program_passes} { if (FLAGS_cinn_use_op_fusion) { graph_passes = {{"OpFusionPass", "FusionMergePass"}, diff --git a/paddle/cinn/frontend/pass/transpose_folding_base.h b/paddle/cinn/frontend/pass/transpose_folding_base.h index 4acc8e4f6d1f6..fbcb384b1704d 100644 --- a/paddle/cinn/frontend/pass/transpose_folding_base.h +++ b/paddle/cinn/frontend/pass/transpose_folding_base.h @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#pragma once - #include #include diff --git a/paddle/cinn/hlir/op/contrib/logical_right_shift.cc b/paddle/cinn/hlir/op/contrib/logical_right_shift.cc index 1f16d2195c611..68f117aad4956 100644 --- a/paddle/cinn/hlir/op/contrib/logical_right_shift.cc +++ b/paddle/cinn/hlir/op/contrib/logical_right_shift.cc @@ -26,7 +26,6 @@ #include "paddle/cinn/hlir/framework/node.h" #include "paddle/cinn/hlir/framework/op.h" #include "paddle/cinn/hlir/framework/op_strategy.h" -#include "paddle/cinn/hlir/op/contrib/logical_right_shift.h" #include "paddle/cinn/hlir/op/op_util.h" #include "paddle/cinn/hlir/pe/ir_schedule_pe.h" #include "paddle/cinn/hlir/pe/nn.h" diff --git a/paddle/cinn/hlir/op/contrib/reciprocal.cc b/paddle/cinn/hlir/op/contrib/reciprocal.cc index 50fbba762342a..09d180601ac10 100644 --- a/paddle/cinn/hlir/op/contrib/reciprocal.cc +++ b/paddle/cinn/hlir/op/contrib/reciprocal.cc @@ -26,7 +26,6 @@ #include "paddle/cinn/hlir/framework/node.h" #include "paddle/cinn/hlir/framework/op.h" #include "paddle/cinn/hlir/framework/op_strategy.h" -#include "paddle/cinn/hlir/op/contrib/reciprocal.h" #include "paddle/cinn/hlir/op/op_util.h" #include "paddle/cinn/hlir/pe/ir_schedule_pe.h" #include "paddle/cinn/hlir/pe/nn.h" diff --git a/paddle/cinn/hlir/op/custom_call.cc b/paddle/cinn/hlir/op/custom_call.cc index 5f272b98c226a..c109df2ec2866 100644 --- a/paddle/cinn/hlir/op/custom_call.cc +++ b/paddle/cinn/hlir/op/custom_call.cc @@ -27,7 +27,7 @@ #include "paddle/cinn/utils/string.h" #ifdef CINN_WITH_CUDNN -#include +#include "cudnn.h" #endif namespace cinn { diff --git a/paddle/cinn/hlir/op/transform.cc b/paddle/cinn/hlir/op/transform.cc index 78d24cba7035d..1f362dc76fce4 100644 --- a/paddle/cinn/hlir/op/transform.cc +++ b/paddle/cinn/hlir/op/transform.cc @@ -25,6 +25,7 @@ #include "paddle/cinn/hlir/pe/ir_schedule_pe.h" #include "paddle/cinn/hlir/pe/nn.h" #include "paddle/cinn/hlir/pe/schedule.h" +#include "paddle/cinn/hlir/pe/transform.h" #include "paddle/cinn/ir/ir_printer.h" #include "paddle/cinn/utils/string.h" diff --git a/paddle/cinn/hlir/pass/infershape.h b/paddle/cinn/hlir/pass/infershape.h index 7ed0ca5fe78ae..a9b9c8a528ee7 100644 --- a/paddle/cinn/hlir/pass/infershape.h +++ b/paddle/cinn/hlir/pass/infershape.h @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#pragma once - #include "paddle/cinn/common/graph_utils.h" #include "paddle/cinn/hlir/framework/graph.h" #include "paddle/cinn/hlir/framework/pass.h" diff --git a/paddle/cinn/poly/domain_add_unit_loop_mutator.h b/paddle/cinn/poly/domain_add_unit_loop_mutator.h index 6c0a289ef3675..0b2ce648b760c 100644 --- a/paddle/cinn/poly/domain_add_unit_loop_mutator.h +++ b/paddle/cinn/poly/domain_add_unit_loop_mutator.h @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#pragma once - #include #include diff --git a/paddle/cinn/runtime/cpu/mkldnn_math.h b/paddle/cinn/runtime/cpu/mkldnn_math.h index 8e6b200378873..c8cb49c1cc329 100644 --- a/paddle/cinn/runtime/cpu/mkldnn_math.h +++ b/paddle/cinn/runtime/cpu/mkldnn_math.h @@ -16,7 +16,7 @@ #include "paddle/cinn/runtime/cinn_runtime.h" #ifdef CINN_WITH_MKLDNN -#include "dnnl.hpp" // NOLINT +#include "dnnl.hpp" #endif // define some C APIs diff --git a/paddle/cinn/runtime/cuda/test_util.h b/paddle/cinn/runtime/cuda/test_util.h index 71786653b49dd..7a5683471dc3c 100644 --- a/paddle/cinn/runtime/cuda/test_util.h +++ b/paddle/cinn/runtime/cuda/test_util.h @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#pragma once #include #include diff --git a/paddle/cinn/runtime/tiny_runtime.cc b/paddle/cinn/runtime/tiny_runtime.cc index 13ca1ea487bd3..8fb0238cbc31d 100644 --- a/paddle/cinn/runtime/tiny_runtime.cc +++ b/paddle/cinn/runtime/tiny_runtime.cc @@ -21,7 +21,7 @@ #include #include -#include "paddle/cinn/runtime/cinn_runtime.h" +#include "cinn_runtime.h" extern "C" { int max_num_workers = std::thread::hardware_concurrency(); @@ -62,13 +62,13 @@ void *load_program(const char *paramfile) { return nullptr; } // TODO(hp03): check param file version - ctx->major_v = *(int *)(buf + 4); - ctx->minor_v = *(int *)(buf + 8); + ctx->major_v = *reinterpret_cast(buf + 4); + ctx->minor_v = *reinterpret_cast(buf + 8); - int *namelist_pos = (int *)(buf + 16); - int *podvalue_pos = (int *)(buf + *namelist_pos); - int *persistent_pos = (int *)(buf + *podvalue_pos); - int *inst_pos = (int *)(buf + *persistent_pos); + int *namelist_pos = reinterpret_cast(buf + 16); + int *podvalue_pos = reinterpret_cast(buf + *namelist_pos); + int *persistent_pos = reinterpret_cast(buf + *podvalue_pos); + int *inst_pos = reinterpret_cast(buf + *persistent_pos); if (fsize < *inst_pos) { return nullptr; } @@ -78,11 +78,11 @@ void *load_program(const char *paramfile) { std::map name2index; for (int i = 0; i < namelen; i++) { int offset = (namelist_pos + 2)[i]; - namev[i] = (char *)(buf + offset); + namev[i] = reinterpret_cast(buf + offset); name2index[namev[i]] = i; } - cinn_buffer_t *cb = (cinn_buffer_t *)(buf + podvalue_pos[1]); + cinn_buffer_t *cb = reinterpret_cast(buf + podvalue_pos[1]); for (int i = 0; i < namelen; i++) { // currently only CPU device is supported, so just use malloc if (cb[i].memory) { @@ -107,9 +107,9 @@ void *load_program(const char *paramfile) { int instargc = inst_pos[2 + i * 3 + 1]; ctx->inst_argc.push_back(instargc); cinn_pod_value_t *argv = - (cinn_pod_value_t *)(buf + inst_pos[2 + i * 3 + 2]); + reinterpret_cast(buf + inst_pos[2 + i * 3 + 2]); for (int i = 0; i < instargc; i++) { - int idx = (uintptr_t)((cinn_buffer_t *)argv[i]); + int idx = (uintptr_t)((cinn_buffer_t *)(argv[i])); // NOLINT cinn_value_t tmp_v; tmp_v.v_handle = &cb[idx]; argv[i].set_value(tmp_v); @@ -127,7 +127,7 @@ int set_maxconcurrency(int c) { typedef void (*func_t)(cinn_pod_value_t *, int); void run_program(void *ctx) { - param_context_t *pc = (param_context_t *)ctx; + param_context_t *pc = reinterpret_cast(ctx); for (int i = 0; i < pc->instructions.size(); i++) { const char *sym = pc->instructions[i].c_str(); void *p = dlsym(RTLD_DEFAULT, sym); @@ -137,7 +137,7 @@ void run_program(void *ctx) { } cinn_pod_value_t *get_pod_value(void *ctx, const char *tname) { - param_context_t *pc = (param_context_t *)ctx; + param_context_t *pc = reinterpret_cast(ctx); if (pc->name2podvalue.find(tname) != pc->name2podvalue.end()) { return &pc->name2podvalue[tname]; } From d42f369aac9324a19229a4144904552cc1b189eb Mon Sep 17 00:00:00 2001 From: SigureMo Date: Tue, 4 Jul 2023 00:13:17 +0800 Subject: [PATCH 4/5] Revert "part 1, [build/include_order]" This reverts commit 5d7f969948a080ab1bdf6dc4692aa2c380dcee92. --- .pre-commit-config.yaml | 5 ++++ .../cinn/backends/nvrtc/header_generator.cc | 2 +- paddle/cinn/common/target.cc | 5 ---- paddle/cinn/common/type.cc | 2 -- paddle/cinn/frontend/computation.h | 1 + paddle/cinn/frontend/pass/pass_test_helper.h | 4 ++- .../frontend/pass/transpose_folding_base.h | 2 ++ .../hlir/op/contrib/logical_right_shift.cc | 1 + paddle/cinn/hlir/op/contrib/reciprocal.cc | 1 + paddle/cinn/hlir/op/custom_call.cc | 2 +- paddle/cinn/hlir/op/transform.cc | 1 - paddle/cinn/hlir/pass/infershape.h | 2 ++ .../cinn/poly/domain_add_unit_loop_mutator.h | 2 ++ paddle/cinn/runtime/cpu/mkldnn_math.h | 2 +- paddle/cinn/runtime/cuda/test_util.h | 1 + paddle/cinn/runtime/tiny_runtime.cc | 26 +++++++++---------- 16 files changed, 34 insertions(+), 25 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fa4765625d79f..481f05c46e8e5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -99,6 +99,11 @@ repos: - --extensions=c,cc,cxx,cpp,cu,cuh,h,hpp,hxx,kps - --filter=-readability/fn_size,-build/include_what_you_use,-build/c++11,-whitespace/parens - --quiet + exclude: | + (?x)^( + paddle/cinn/.+| + test/cpp/cinn/.+ + )$ # For CMake files - repo: local hooks: diff --git a/paddle/cinn/backends/nvrtc/header_generator.cc b/paddle/cinn/backends/nvrtc/header_generator.cc index 328b0ce1f53be..d4b2b9504673f 100644 --- a/paddle/cinn/backends/nvrtc/header_generator.cc +++ b/paddle/cinn/backends/nvrtc/header_generator.cc @@ -15,7 +15,7 @@ #include "paddle/cinn/backends/nvrtc/header_generator.h" #include "glog/logging.h" -#include "jitify.hpp" +#include "jitify.hpp" // NOLINT namespace cinn { namespace backends { diff --git a/paddle/cinn/common/target.cc b/paddle/cinn/common/target.cc index 42a130163a130..95d57c3172aa3 100644 --- a/paddle/cinn/common/target.cc +++ b/paddle/cinn/common/target.cc @@ -23,11 +23,6 @@ #include "paddle/cinn/common/target.h" #include "paddle/cinn/runtime/cinn_runtime.h" -#ifdef CINN_WITH_CUDA -#include -#include -#endif - namespace cinn { namespace common { diff --git a/paddle/cinn/common/type.cc b/paddle/cinn/common/type.cc index ad5c8412d950b..2b15575708164 100644 --- a/paddle/cinn/common/type.cc +++ b/paddle/cinn/common/type.cc @@ -19,8 +19,6 @@ #include #include -#include "type.h" - namespace cinn { namespace common { diff --git a/paddle/cinn/frontend/computation.h b/paddle/cinn/frontend/computation.h index c464cb40d2a5c..8b16f9483320f 100644 --- a/paddle/cinn/frontend/computation.h +++ b/paddle/cinn/frontend/computation.h @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#pragma once #include #include "paddle/cinn/frontend/net_builder.h" diff --git a/paddle/cinn/frontend/pass/pass_test_helper.h b/paddle/cinn/frontend/pass/pass_test_helper.h index e56746a86368a..8215703c0907f 100644 --- a/paddle/cinn/frontend/pass/pass_test_helper.h +++ b/paddle/cinn/frontend/pass/pass_test_helper.h @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#pragma once + #include #include @@ -143,7 +145,7 @@ inline std::vector RunProgram( struct OptimizeConfig { struct PassGroup; - explicit OptimizeConfig(const PassGroup& program_passes) + OptimizeConfig(const PassGroup& program_passes) : program_passes{program_passes} { if (FLAGS_cinn_use_op_fusion) { graph_passes = {{"OpFusionPass", "FusionMergePass"}, diff --git a/paddle/cinn/frontend/pass/transpose_folding_base.h b/paddle/cinn/frontend/pass/transpose_folding_base.h index fbcb384b1704d..4acc8e4f6d1f6 100644 --- a/paddle/cinn/frontend/pass/transpose_folding_base.h +++ b/paddle/cinn/frontend/pass/transpose_folding_base.h @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#pragma once + #include #include diff --git a/paddle/cinn/hlir/op/contrib/logical_right_shift.cc b/paddle/cinn/hlir/op/contrib/logical_right_shift.cc index 68f117aad4956..1f16d2195c611 100644 --- a/paddle/cinn/hlir/op/contrib/logical_right_shift.cc +++ b/paddle/cinn/hlir/op/contrib/logical_right_shift.cc @@ -26,6 +26,7 @@ #include "paddle/cinn/hlir/framework/node.h" #include "paddle/cinn/hlir/framework/op.h" #include "paddle/cinn/hlir/framework/op_strategy.h" +#include "paddle/cinn/hlir/op/contrib/logical_right_shift.h" #include "paddle/cinn/hlir/op/op_util.h" #include "paddle/cinn/hlir/pe/ir_schedule_pe.h" #include "paddle/cinn/hlir/pe/nn.h" diff --git a/paddle/cinn/hlir/op/contrib/reciprocal.cc b/paddle/cinn/hlir/op/contrib/reciprocal.cc index 09d180601ac10..50fbba762342a 100644 --- a/paddle/cinn/hlir/op/contrib/reciprocal.cc +++ b/paddle/cinn/hlir/op/contrib/reciprocal.cc @@ -26,6 +26,7 @@ #include "paddle/cinn/hlir/framework/node.h" #include "paddle/cinn/hlir/framework/op.h" #include "paddle/cinn/hlir/framework/op_strategy.h" +#include "paddle/cinn/hlir/op/contrib/reciprocal.h" #include "paddle/cinn/hlir/op/op_util.h" #include "paddle/cinn/hlir/pe/ir_schedule_pe.h" #include "paddle/cinn/hlir/pe/nn.h" diff --git a/paddle/cinn/hlir/op/custom_call.cc b/paddle/cinn/hlir/op/custom_call.cc index c109df2ec2866..5f272b98c226a 100644 --- a/paddle/cinn/hlir/op/custom_call.cc +++ b/paddle/cinn/hlir/op/custom_call.cc @@ -27,7 +27,7 @@ #include "paddle/cinn/utils/string.h" #ifdef CINN_WITH_CUDNN -#include "cudnn.h" +#include #endif namespace cinn { diff --git a/paddle/cinn/hlir/op/transform.cc b/paddle/cinn/hlir/op/transform.cc index 1f362dc76fce4..78d24cba7035d 100644 --- a/paddle/cinn/hlir/op/transform.cc +++ b/paddle/cinn/hlir/op/transform.cc @@ -25,7 +25,6 @@ #include "paddle/cinn/hlir/pe/ir_schedule_pe.h" #include "paddle/cinn/hlir/pe/nn.h" #include "paddle/cinn/hlir/pe/schedule.h" -#include "paddle/cinn/hlir/pe/transform.h" #include "paddle/cinn/ir/ir_printer.h" #include "paddle/cinn/utils/string.h" diff --git a/paddle/cinn/hlir/pass/infershape.h b/paddle/cinn/hlir/pass/infershape.h index a9b9c8a528ee7..7ed0ca5fe78ae 100644 --- a/paddle/cinn/hlir/pass/infershape.h +++ b/paddle/cinn/hlir/pass/infershape.h @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#pragma once + #include "paddle/cinn/common/graph_utils.h" #include "paddle/cinn/hlir/framework/graph.h" #include "paddle/cinn/hlir/framework/pass.h" diff --git a/paddle/cinn/poly/domain_add_unit_loop_mutator.h b/paddle/cinn/poly/domain_add_unit_loop_mutator.h index 0b2ce648b760c..6c0a289ef3675 100644 --- a/paddle/cinn/poly/domain_add_unit_loop_mutator.h +++ b/paddle/cinn/poly/domain_add_unit_loop_mutator.h @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#pragma once + #include #include diff --git a/paddle/cinn/runtime/cpu/mkldnn_math.h b/paddle/cinn/runtime/cpu/mkldnn_math.h index c8cb49c1cc329..8e6b200378873 100644 --- a/paddle/cinn/runtime/cpu/mkldnn_math.h +++ b/paddle/cinn/runtime/cpu/mkldnn_math.h @@ -16,7 +16,7 @@ #include "paddle/cinn/runtime/cinn_runtime.h" #ifdef CINN_WITH_MKLDNN -#include "dnnl.hpp" +#include "dnnl.hpp" // NOLINT #endif // define some C APIs diff --git a/paddle/cinn/runtime/cuda/test_util.h b/paddle/cinn/runtime/cuda/test_util.h index 7a5683471dc3c..71786653b49dd 100644 --- a/paddle/cinn/runtime/cuda/test_util.h +++ b/paddle/cinn/runtime/cuda/test_util.h @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#pragma once #include #include diff --git a/paddle/cinn/runtime/tiny_runtime.cc b/paddle/cinn/runtime/tiny_runtime.cc index 8fb0238cbc31d..13ca1ea487bd3 100644 --- a/paddle/cinn/runtime/tiny_runtime.cc +++ b/paddle/cinn/runtime/tiny_runtime.cc @@ -21,7 +21,7 @@ #include #include -#include "cinn_runtime.h" +#include "paddle/cinn/runtime/cinn_runtime.h" extern "C" { int max_num_workers = std::thread::hardware_concurrency(); @@ -62,13 +62,13 @@ void *load_program(const char *paramfile) { return nullptr; } // TODO(hp03): check param file version - ctx->major_v = *reinterpret_cast(buf + 4); - ctx->minor_v = *reinterpret_cast(buf + 8); + ctx->major_v = *(int *)(buf + 4); + ctx->minor_v = *(int *)(buf + 8); - int *namelist_pos = reinterpret_cast(buf + 16); - int *podvalue_pos = reinterpret_cast(buf + *namelist_pos); - int *persistent_pos = reinterpret_cast(buf + *podvalue_pos); - int *inst_pos = reinterpret_cast(buf + *persistent_pos); + int *namelist_pos = (int *)(buf + 16); + int *podvalue_pos = (int *)(buf + *namelist_pos); + int *persistent_pos = (int *)(buf + *podvalue_pos); + int *inst_pos = (int *)(buf + *persistent_pos); if (fsize < *inst_pos) { return nullptr; } @@ -78,11 +78,11 @@ void *load_program(const char *paramfile) { std::map name2index; for (int i = 0; i < namelen; i++) { int offset = (namelist_pos + 2)[i]; - namev[i] = reinterpret_cast(buf + offset); + namev[i] = (char *)(buf + offset); name2index[namev[i]] = i; } - cinn_buffer_t *cb = reinterpret_cast(buf + podvalue_pos[1]); + cinn_buffer_t *cb = (cinn_buffer_t *)(buf + podvalue_pos[1]); for (int i = 0; i < namelen; i++) { // currently only CPU device is supported, so just use malloc if (cb[i].memory) { @@ -107,9 +107,9 @@ void *load_program(const char *paramfile) { int instargc = inst_pos[2 + i * 3 + 1]; ctx->inst_argc.push_back(instargc); cinn_pod_value_t *argv = - reinterpret_cast(buf + inst_pos[2 + i * 3 + 2]); + (cinn_pod_value_t *)(buf + inst_pos[2 + i * 3 + 2]); for (int i = 0; i < instargc; i++) { - int idx = (uintptr_t)((cinn_buffer_t *)(argv[i])); // NOLINT + int idx = (uintptr_t)((cinn_buffer_t *)argv[i]); cinn_value_t tmp_v; tmp_v.v_handle = &cb[idx]; argv[i].set_value(tmp_v); @@ -127,7 +127,7 @@ int set_maxconcurrency(int c) { typedef void (*func_t)(cinn_pod_value_t *, int); void run_program(void *ctx) { - param_context_t *pc = reinterpret_cast(ctx); + param_context_t *pc = (param_context_t *)ctx; for (int i = 0; i < pc->instructions.size(); i++) { const char *sym = pc->instructions[i].c_str(); void *p = dlsym(RTLD_DEFAULT, sym); @@ -137,7 +137,7 @@ void run_program(void *ctx) { } cinn_pod_value_t *get_pod_value(void *ctx, const char *tname) { - param_context_t *pc = reinterpret_cast(ctx); + param_context_t *pc = (param_context_t *)ctx; if (pc->name2podvalue.find(tname) != pc->name2podvalue.end()) { return &pc->name2podvalue[tname]; } From 118fc9b109a105e04591a4e25f3a320abb172a05 Mon Sep 17 00:00:00 2001 From: SigureMo Date: Tue, 4 Jul 2023 00:14:15 +0800 Subject: [PATCH 5/5] skip, [build/include_order] --- paddle/cinn/common/arithmatic.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paddle/cinn/common/arithmatic.h b/paddle/cinn/common/arithmatic.h index d24d17ab317e2..e73a9bac3ede2 100644 --- a/paddle/cinn/common/arithmatic.h +++ b/paddle/cinn/common/arithmatic.h @@ -18,6 +18,8 @@ */ #pragma once +#include "paddle/cinn/ir/ir.h" + #include #include @@ -26,8 +28,6 @@ #include #include -#include "paddle/cinn/ir/ir.h" - #ifdef As #undef As #endif