From 397d05671cb5699c4a776414fbecd36c031fdd83 Mon Sep 17 00:00:00 2001 From: superjomn Date: Tue, 14 May 2019 11:24:49 +0800 Subject: [PATCH] update cpplint test=develop --- paddle/fluid/lite/api/cxx_api.cc | 4 ++ paddle/fluid/lite/api/cxx_api_test.cc | 1 + paddle/fluid/lite/api/light_api.h | 2 + paddle/fluid/lite/core/CMakeLists.txt | 2 - paddle/fluid/lite/core/context.h | 1 + paddle/fluid/lite/core/kernel.cc | 3 +- paddle/fluid/lite/core/kernel.h | 1 + paddle/fluid/lite/core/kernel_executor.cc | 19 ------- paddle/fluid/lite/core/kernel_executor.h | 50 ------------------- paddle/fluid/lite/core/lite_tensor.h | 2 +- .../core/mir/argument_type_display_pass.cc | 2 +- paddle/fluid/lite/core/mir/demo_pass.cc | 2 +- .../lite/core/mir/generate_program_pass.cc | 5 +- .../lite/core/mir/generate_program_pass.h | 2 +- .../lite/core/mir/graph_visualize_pass.cc | 4 +- .../lite/core/mir/graph_visualize_pass.h | 2 +- .../lite/core/mir/io_copy_kernel_pick_pass.cc | 2 +- paddle/fluid/lite/core/mir/node.h | 1 + paddle/fluid/lite/core/mir/pass.h | 6 ++- paddle/fluid/lite/core/mir/pass_manager.h | 2 +- .../core/mir/runtime_context_assign_pass.cc | 2 +- paddle/fluid/lite/core/mir/ssa_graph.cc | 4 ++ .../lite/core/mir/static_kernel_pick_pass.cc | 2 +- .../lite/core/mir/static_kernel_pick_pass.h | 2 +- .../core/mir/type_target_transform_pass.cc | 4 +- .../core/mir/type_target_transform_pass.h | 2 +- .../core/mir/variable_place_inference_pass.cc | 3 +- .../core/mir/variable_place_inference_pass.h | 3 +- paddle/fluid/lite/core/op_lite.cc | 5 +- paddle/fluid/lite/core/op_registry.cc | 4 +- paddle/fluid/lite/core/op_registry.h | 4 +- paddle/fluid/lite/core/optimizer.h | 1 + paddle/fluid/lite/core/optimizer_test.cc | 2 + paddle/fluid/lite/core/program.h | 5 +- paddle/fluid/lite/core/program_fake_utils.h | 4 ++ paddle/fluid/lite/core/target_wrapper.cc | 3 +- paddle/fluid/lite/core/target_wrapper.h | 4 +- paddle/fluid/lite/core/variable.h | 2 + paddle/fluid/lite/cuda/target_wrapper.h | 1 + paddle/fluid/lite/kernels/host/relu_compute.h | 1 + .../fluid/lite/model_parser/model_parser.cc | 6 ++- paddle/fluid/lite/model_parser/model_parser.h | 1 + .../fluid/lite/model_parser/pb/block_desc.cc | 2 + paddle/fluid/lite/model_parser/pb/op_desc.h | 10 ++-- .../lite/model_parser/pb/program_desc.cc | 2 + .../fluid/lite/model_parser/pb/program_desc.h | 2 + paddle/fluid/lite/model_parser/pb/var_desc.cc | 2 +- paddle/fluid/lite/model_parser/pb/var_desc.h | 2 +- paddle/fluid/lite/model_parser/runtime.h | 5 +- paddle/fluid/lite/operators/relu_op.h | 3 +- paddle/fluid/lite/utils/cp_logging.h | 1 + paddle/fluid/lite/utils/factory.h | 4 +- paddle/fluid/lite/utils/logging.h | 1 + paddle/fluid/lite/utils/varient.h | 2 + paddle/fluid/lite/x86/target_wrapper.cc | 1 + 55 files changed, 106 insertions(+), 109 deletions(-) delete mode 100644 paddle/fluid/lite/core/kernel_executor.cc delete mode 100644 paddle/fluid/lite/core/kernel_executor.h diff --git a/paddle/fluid/lite/api/cxx_api.cc b/paddle/fluid/lite/api/cxx_api.cc index 14a526fe1a4..07a216b6373 100644 --- a/paddle/fluid/lite/api/cxx_api.cc +++ b/paddle/fluid/lite/api/cxx_api.cc @@ -13,6 +13,10 @@ // limitations under the License. #include "paddle/fluid/lite/api/cxx_api.h" +#include +#include +#include +#include #ifndef LITE_WITH_LIGHT_WEIGHT_FRAMEWORK #include "paddle/fluid/platform/port.h" #endif diff --git a/paddle/fluid/lite/api/cxx_api_test.cc b/paddle/fluid/lite/api/cxx_api_test.cc index 373cd070407..3d929ffb38a 100644 --- a/paddle/fluid/lite/api/cxx_api_test.cc +++ b/paddle/fluid/lite/api/cxx_api_test.cc @@ -15,6 +15,7 @@ #include "paddle/fluid/lite/api/cxx_api.h" #include #include +#include #include "paddle/fluid/lite/core/mir/passes.h" #include "paddle/fluid/lite/core/op_registry.h" diff --git a/paddle/fluid/lite/api/light_api.h b/paddle/fluid/lite/api/light_api.h index 484af4d339b..9cd9f62a0b0 100644 --- a/paddle/fluid/lite/api/light_api.h +++ b/paddle/fluid/lite/api/light_api.h @@ -18,7 +18,9 @@ */ #pragma once +#include #include +#include #include #include "paddle/fluid/lite/core/program.h" #include "paddle/fluid/lite/core/types.h" diff --git a/paddle/fluid/lite/core/CMakeLists.txt b/paddle/fluid/lite/core/CMakeLists.txt index f6c30068446..bf40d198dee 100644 --- a/paddle/fluid/lite/core/CMakeLists.txt +++ b/paddle/fluid/lite/core/CMakeLists.txt @@ -1,7 +1,6 @@ cc_library(lite_gtest_main SRCS lite_gtest_main.cc DEPS gtest) cc_library(memory_lite SRCS memory.cc DEPS target_wrapper_lite target_wrapper_host) cc_library(target_wrapper_lite SRCS target_wrapper.cc) - cc_library(lite_tensor SRCS lite_tensor.cc DEPS memory_lite target_wrapper_lite) if (NOT LITE_WITH_LIGHT_WEIGHT_FRAMEWORK) cc_library(hvy_tensor SRCS hvy_tensor.cc DEPS lod_tensor) @@ -24,7 +23,6 @@ cc_library(op_lite SRCS op_lite.cc DEPS scope_lite op_registry_lite compatible_p cc_library(types_lite SRCS types.cc) cc_library(type_system SRCS type_system.cc DEPS ${tensor_lite} target_wrapper_lite) -#cc_library(kernel_executor_lite SRCS kernel_executor.cc DEPS mir_ssa_graph kernel_lite) cc_library(program_lite SRCS program.cc DEPS op_lite kernel_lite) cc_library(optimizer_lite SRCS optimizer.cc DEPS mir_pass_manager model_parser_lite program_lite) diff --git a/paddle/fluid/lite/core/context.h b/paddle/fluid/lite/core/context.h index 3e40588b73e..d255645c72c 100644 --- a/paddle/fluid/lite/core/context.h +++ b/paddle/fluid/lite/core/context.h @@ -20,6 +20,7 @@ #include "paddle/fluid/lite/cuda/cuda_utils.h" #endif #include +#include #include #include "paddle/fluid/lite/core/target_wrapper.h" diff --git a/paddle/fluid/lite/core/kernel.cc b/paddle/fluid/lite/core/kernel.cc index c86e38b3801..44b00f53d01 100644 --- a/paddle/fluid/lite/core/kernel.cc +++ b/paddle/fluid/lite/core/kernel.cc @@ -62,5 +62,6 @@ std::ostream &operator<<(std::ostream &os, << other.place.DebugString(); return os; } + } // namespace lite -} // namespace paddle \ No newline at end of file +} // namespace paddle diff --git a/paddle/fluid/lite/core/kernel.h b/paddle/fluid/lite/core/kernel.h index c86194c4783..6846dbb920d 100644 --- a/paddle/fluid/lite/core/kernel.h +++ b/paddle/fluid/lite/core/kernel.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "paddle/fluid/lite/core/context.h" #include "paddle/fluid/lite/core/target_wrapper.h" diff --git a/paddle/fluid/lite/core/kernel_executor.cc b/paddle/fluid/lite/core/kernel_executor.cc deleted file mode 100644 index 4ca0d20d465..00000000000 --- a/paddle/fluid/lite/core/kernel_executor.cc +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "paddle/fluid/lite/core/kernel_executor.h" - -namespace paddle { -namespace lite {} // namespace lite -} // namespace paddle \ No newline at end of file diff --git a/paddle/fluid/lite/core/kernel_executor.h b/paddle/fluid/lite/core/kernel_executor.h deleted file mode 100644 index b933c13bfc1..00000000000 --- a/paddle/fluid/lite/core/kernel_executor.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once -#include "paddle/fluid/lite/core/mir/ssa_graph.h" - -namespace paddle { -namespace lite { - -/* - * KernelExecutor executes a list of kernels. - */ -class KernelExecutorBase { - public: - KernelExecutorBase(std::unique_ptr&& program); - - // Prepare runtime context. - void PrepareWorkspace(); - - void Run(); - - private: - lite::Scope* scope_{}; - lite::Scope* exec_scope_{}; -}; - -/* - * KernelExecutor executes the kernels without concurrency, works in X86 place. - */ -class SerialKernelExecutor : public KernelExecutorBase {}; - -/* - * KernelExecutor executes the kernels with CUDA like stream parallel support, - * works in CUDA like devices. - */ -class StreamKernelExecutor : public KernelExecutorBase {}; - -} // namespace lite -} // namespace paddle diff --git a/paddle/fluid/lite/core/lite_tensor.h b/paddle/fluid/lite/core/lite_tensor.h index ea31b3f9aa5..3fe29cc3331 100644 --- a/paddle/fluid/lite/core/lite_tensor.h +++ b/paddle/fluid/lite/core/lite_tensor.h @@ -29,7 +29,7 @@ class DDimLite : public DDimBase { public: DDimLite() = default; - DDimLite(const std::vector &x) : DDimBase() { + explicit DDimLite(const std::vector &x) : DDimBase() { ConstructFrom(x); } diff --git a/paddle/fluid/lite/core/mir/argument_type_display_pass.cc b/paddle/fluid/lite/core/mir/argument_type_display_pass.cc index e4db847d127..69b9c5fa5a0 100644 --- a/paddle/fluid/lite/core/mir/argument_type_display_pass.cc +++ b/paddle/fluid/lite/core/mir/argument_type_display_pass.cc @@ -21,7 +21,7 @@ namespace mir { class ArgumentTypeDisplayPass : public DebugPass { public: - void Apply(std::unique_ptr& graph) override { + void Apply(const std::unique_ptr& graph) override { LOG(INFO) << "== Argument types =="; for (auto& node : graph->mutable_nodes()) { if (!node.IsArg()) continue; diff --git a/paddle/fluid/lite/core/mir/demo_pass.cc b/paddle/fluid/lite/core/mir/demo_pass.cc index 36542dcafa5..d9e05adc6d3 100644 --- a/paddle/fluid/lite/core/mir/demo_pass.cc +++ b/paddle/fluid/lite/core/mir/demo_pass.cc @@ -21,7 +21,7 @@ namespace mir { class DemoPass : public mir::DebugPass { public: - void Apply(std::unique_ptr& graph) override {} + void Apply(const std::unique_ptr &graph) override {} }; /* diff --git a/paddle/fluid/lite/core/mir/generate_program_pass.cc b/paddle/fluid/lite/core/mir/generate_program_pass.cc index ec671d7bbfa..3751b6f1f84 100644 --- a/paddle/fluid/lite/core/mir/generate_program_pass.cc +++ b/paddle/fluid/lite/core/mir/generate_program_pass.cc @@ -13,6 +13,9 @@ // limitations under the License. #include "paddle/fluid/lite/core/mir/generate_program_pass.h" +#include +#include +#include #include "paddle/fluid/lite/core/mir/graph_visualize_pass.h" #include "paddle/fluid/lite/core/mir/pass_registry.h" @@ -20,7 +23,7 @@ namespace paddle { namespace lite { namespace mir { -void GenerateProgramPass::Apply(std::unique_ptr& graph) { +void GenerateProgramPass::Apply(const std::unique_ptr& graph) { LOG(INFO) << "final program \n" << Visualize(graph.get()); for (auto& item : graph->StmtTopologicalOrder()) { if (item->IsStmt()) { diff --git a/paddle/fluid/lite/core/mir/generate_program_pass.h b/paddle/fluid/lite/core/mir/generate_program_pass.h index cd0e70b2c82..0ef358ec233 100644 --- a/paddle/fluid/lite/core/mir/generate_program_pass.h +++ b/paddle/fluid/lite/core/mir/generate_program_pass.h @@ -28,7 +28,7 @@ namespace mir { */ class GenerateProgramPass : public ProgramPass { public: - void Apply(std::unique_ptr& graph) override; + void Apply(const std::unique_ptr &graph) override; std::unique_ptr GenProgram() { LOG(INFO) << "insts.size " << insts_.size(); diff --git a/paddle/fluid/lite/core/mir/graph_visualize_pass.cc b/paddle/fluid/lite/core/mir/graph_visualize_pass.cc index 440dfd785be..6a13bafd67c 100644 --- a/paddle/fluid/lite/core/mir/graph_visualize_pass.cc +++ b/paddle/fluid/lite/core/mir/graph_visualize_pass.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/lite/core/mir/graph_visualize_pass.h" +#include #include +#include #include "paddle/fluid/lite/core/mir/pass_registry.h" namespace paddle { @@ -22,7 +24,7 @@ namespace mir { using inference::analysis::Dot; -void GraphVisualizePass::Apply(std::unique_ptr& graph) { +void GraphVisualizePass::Apply(const std::unique_ptr& graph) { Visualize(graph.get()); } diff --git a/paddle/fluid/lite/core/mir/graph_visualize_pass.h b/paddle/fluid/lite/core/mir/graph_visualize_pass.h index 79dbd4080b6..f11cfaabf4a 100644 --- a/paddle/fluid/lite/core/mir/graph_visualize_pass.h +++ b/paddle/fluid/lite/core/mir/graph_visualize_pass.h @@ -27,7 +27,7 @@ namespace mir { */ class GraphVisualizePass : public DebugPass { public: - void Apply(std::unique_ptr& graph) override; + void Apply(const std::unique_ptr& graph) override; }; std::string Visualize(mir::SSAGraph* graph); diff --git a/paddle/fluid/lite/core/mir/io_copy_kernel_pick_pass.cc b/paddle/fluid/lite/core/mir/io_copy_kernel_pick_pass.cc index 1978f50db1a..ebf9e5a57bf 100644 --- a/paddle/fluid/lite/core/mir/io_copy_kernel_pick_pass.cc +++ b/paddle/fluid/lite/core/mir/io_copy_kernel_pick_pass.cc @@ -21,7 +21,7 @@ namespace mir { class IoCopyKernelPickPass : public StmtPass { public: - void Apply(std::unique_ptr& graph) override { + void Apply(const std::unique_ptr& graph) override { for (auto& node : graph->mutable_nodes()) { if (!node.IsStmt()) continue; auto& inst = node.AsStmt(); diff --git a/paddle/fluid/lite/core/mir/node.h b/paddle/fluid/lite/core/mir/node.h index d827a021108..e10472c5885 100644 --- a/paddle/fluid/lite/core/mir/node.h +++ b/paddle/fluid/lite/core/mir/node.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "paddle/fluid/lite/core/kernel.h" #include "paddle/fluid/lite/core/op_lite.h" diff --git a/paddle/fluid/lite/core/mir/pass.h b/paddle/fluid/lite/core/mir/pass.h index 0f14f6defb6..6935ec462eb 100644 --- a/paddle/fluid/lite/core/mir/pass.h +++ b/paddle/fluid/lite/core/mir/pass.h @@ -13,6 +13,8 @@ // limitations under the License. #pragma once +#include +#include #include "paddle/fluid/lite/core/mir/node.h" #include "paddle/fluid/lite/core/mir/ssa_graph.h" @@ -32,9 +34,9 @@ class Pass { kDebug, }; - Pass(Kind kind) : kind_(kind) {} + explicit Pass(Kind kind) : kind_(kind) {} - virtual void Apply(std::unique_ptr& graph) = 0; + virtual void Apply(const std::unique_ptr& graph) = 0; void set_name(const std::string& name) { name_ = name; } const std::string& name() const { return name_; } diff --git a/paddle/fluid/lite/core/mir/pass_manager.h b/paddle/fluid/lite/core/mir/pass_manager.h index ba3fad4d9f2..901702285ac 100644 --- a/paddle/fluid/lite/core/mir/pass_manager.h +++ b/paddle/fluid/lite/core/mir/pass_manager.h @@ -32,7 +32,7 @@ class PassManager { PassManager(); - void Run(std::unique_ptr& graph) { + void Run(const std::unique_ptr& graph) { for (auto& pass : passes_) { LOG(INFO) << "Running MIR pass " << pass->name(); pass->Apply(graph); diff --git a/paddle/fluid/lite/core/mir/runtime_context_assign_pass.cc b/paddle/fluid/lite/core/mir/runtime_context_assign_pass.cc index 8e89d922e0b..3d2012306b9 100644 --- a/paddle/fluid/lite/core/mir/runtime_context_assign_pass.cc +++ b/paddle/fluid/lite/core/mir/runtime_context_assign_pass.cc @@ -27,7 +27,7 @@ class RuntimeContextAssignPass : public StmtPass { #endif } - void Apply(std::unique_ptr& graph) override { + void Apply(const std::unique_ptr& graph) override { for (auto& node : graph->mutable_nodes()) { if (!node.IsStmt()) continue; diff --git a/paddle/fluid/lite/core/mir/ssa_graph.cc b/paddle/fluid/lite/core/mir/ssa_graph.cc index 10bd01ef601..b565b6fd3ec 100644 --- a/paddle/fluid/lite/core/mir/ssa_graph.cc +++ b/paddle/fluid/lite/core/mir/ssa_graph.cc @@ -13,6 +13,10 @@ // limitations under the License. #include "paddle/fluid/lite/core/mir/ssa_graph.h" +#include +#include +#include +#include namespace paddle { namespace lite { diff --git a/paddle/fluid/lite/core/mir/static_kernel_pick_pass.cc b/paddle/fluid/lite/core/mir/static_kernel_pick_pass.cc index 4dfc15e3e19..3709094ed29 100644 --- a/paddle/fluid/lite/core/mir/static_kernel_pick_pass.cc +++ b/paddle/fluid/lite/core/mir/static_kernel_pick_pass.cc @@ -27,7 +27,7 @@ bool KernelScoreCmp(const std::pair>& a, return a.first > b.first; } -void StaticKernelPickPass::Apply(std::unique_ptr& graph) { +void StaticKernelPickPass::Apply(const std::unique_ptr& graph) { CHECK(kernel_pick_factors_.AnyFactorConsidered()) << "kernel_pick_factors should be specified first"; CHECK(graph) << "graph not valid"; diff --git a/paddle/fluid/lite/core/mir/static_kernel_pick_pass.h b/paddle/fluid/lite/core/mir/static_kernel_pick_pass.h index 5c48ba9ca02..52d5dd08d26 100644 --- a/paddle/fluid/lite/core/mir/static_kernel_pick_pass.h +++ b/paddle/fluid/lite/core/mir/static_kernel_pick_pass.h @@ -35,7 +35,7 @@ namespace mir { */ class StaticKernelPickPass : public mir::StmtPass { public: - void Apply(std::unique_ptr& graph) override; + void Apply(const std::unique_ptr& graph) override; void SetPreferPlace(const Place& place) { place_ = place; } const Place& place() const { return place_; } diff --git a/paddle/fluid/lite/core/mir/type_target_transform_pass.cc b/paddle/fluid/lite/core/mir/type_target_transform_pass.cc index 9ac80b552e7..ddd07970166 100644 --- a/paddle/fluid/lite/core/mir/type_target_transform_pass.cc +++ b/paddle/fluid/lite/core/mir/type_target_transform_pass.cc @@ -14,7 +14,9 @@ #include "paddle/fluid/lite/core/mir/type_target_transform_pass.h" #include +#include #include +#include #include #include "paddle/fluid/lite/core/mir/graph_visualize_pass.h" #include "paddle/fluid/lite/core/mir/pass_registry.h" @@ -23,7 +25,7 @@ namespace paddle { namespace lite { namespace mir { -void TypeTargetTransformPass::Apply(std::unique_ptr& graph) { +void TypeTargetTransformPass::Apply(const std::unique_ptr& graph) { // Start from inputs of the graph, those should have place set. std::list nodes; for (auto& node : graph->mutable_nodes()) { diff --git a/paddle/fluid/lite/core/mir/type_target_transform_pass.h b/paddle/fluid/lite/core/mir/type_target_transform_pass.h index 4f3f0c1c148..411090219fb 100644 --- a/paddle/fluid/lite/core/mir/type_target_transform_pass.h +++ b/paddle/fluid/lite/core/mir/type_target_transform_pass.h @@ -40,7 +40,7 @@ static void UpdateInputTo(framework::proto::OpDesc* desc, */ class TypeTargetTransformPass : public ProgramPass { public: - void Apply(std::unique_ptr& graph) override; + void Apply(const std::unique_ptr& graph) override; void ComplementInputs(SSAGraph* graph, Node* inst_node, Node* in); diff --git a/paddle/fluid/lite/core/mir/variable_place_inference_pass.cc b/paddle/fluid/lite/core/mir/variable_place_inference_pass.cc index 6d4b2ce2462..8ee0fb24ba2 100644 --- a/paddle/fluid/lite/core/mir/variable_place_inference_pass.cc +++ b/paddle/fluid/lite/core/mir/variable_place_inference_pass.cc @@ -13,13 +13,14 @@ // limitations under the License. #include "paddle/fluid/lite/core/mir/variable_place_inference_pass.h" +#include #include "paddle/fluid/lite/core/mir/pass_registry.h" namespace paddle { namespace lite { namespace mir { -void VariablePlaceInferencePass::Apply(std::unique_ptr& graph) { +void VariablePlaceInferencePass::Apply(const std::unique_ptr &graph) { MarkInputPlace(graph.get()); InferenceArgumentPlace(graph.get()); CheckAllArgumentTypeDetermined(graph.get()); diff --git a/paddle/fluid/lite/core/mir/variable_place_inference_pass.h b/paddle/fluid/lite/core/mir/variable_place_inference_pass.h index ff129600ea6..79c977b331f 100644 --- a/paddle/fluid/lite/core/mir/variable_place_inference_pass.h +++ b/paddle/fluid/lite/core/mir/variable_place_inference_pass.h @@ -13,6 +13,7 @@ // limitations under the License. #pragma once +#include #include "paddle/fluid/lite/core/mir/pass.h" #include "paddle/fluid/lite/core/target_wrapper.h" @@ -26,7 +27,7 @@ namespace mir { */ class VariablePlaceInferencePass : public DebugPass { public: - void Apply(std::unique_ptr& graph) override; + void Apply(const std::unique_ptr& graph) override; private: // Mark the place of input arguments. diff --git a/paddle/fluid/lite/core/op_lite.cc b/paddle/fluid/lite/core/op_lite.cc index dd159becc78..47e0c441e75 100644 --- a/paddle/fluid/lite/core/op_lite.cc +++ b/paddle/fluid/lite/core/op_lite.cc @@ -13,7 +13,10 @@ // limitations under the License. #include "paddle/fluid/lite/core/op_lite.h" -#include "op_lite.h" +#include +#include +#include +#include #include "paddle/fluid/lite/core/op_registry.h" namespace paddle { diff --git a/paddle/fluid/lite/core/op_registry.cc b/paddle/fluid/lite/core/op_registry.cc index 4ac233ad2e6..681cbdafcde 100644 --- a/paddle/fluid/lite/core/op_registry.cc +++ b/paddle/fluid/lite/core/op_registry.cc @@ -13,6 +13,8 @@ // limitations under the License. #include "paddle/fluid/lite/core/op_registry.h" +#include +#include namespace paddle { namespace lite { @@ -90,4 +92,4 @@ KernelRegistry &KernelRegistry::Global() { } } // namespace lite -} // namespace paddle \ No newline at end of file +} // namespace paddle diff --git a/paddle/fluid/lite/core/op_registry.h b/paddle/fluid/lite/core/op_registry.h index 1a66ed89443..2321e3a250e 100644 --- a/paddle/fluid/lite/core/op_registry.h +++ b/paddle/fluid/lite/core/op_registry.h @@ -14,8 +14,10 @@ #pragma once #include +#include #include #include +#include #include "paddle/fluid/lite/core/kernel.h" #include "paddle/fluid/lite/core/op_lite.h" #include "paddle/fluid/lite/core/target_wrapper.h" @@ -43,7 +45,7 @@ class LiteOpRegistry final : public Factory> { template class OpLiteRegistor : public Registor { public: - OpLiteRegistor(const std::string &op_type) + explicit OpLiteRegistor(const std::string &op_type) : Registor([&] { LiteOpRegistry::Global().Register( op_type, [op_type]() -> std::unique_ptr { diff --git a/paddle/fluid/lite/core/optimizer.h b/paddle/fluid/lite/core/optimizer.h index 34272f570d0..f585224a07f 100644 --- a/paddle/fluid/lite/core/optimizer.h +++ b/paddle/fluid/lite/core/optimizer.h @@ -13,6 +13,7 @@ // limitations under the License. #pragma once +#include #include #include #include "paddle/fluid/lite/core/mir/generate_program_pass.h" diff --git a/paddle/fluid/lite/core/optimizer_test.cc b/paddle/fluid/lite/core/optimizer_test.cc index ab9a9cd0240..ae543dc1b19 100644 --- a/paddle/fluid/lite/core/optimizer_test.cc +++ b/paddle/fluid/lite/core/optimizer_test.cc @@ -14,6 +14,8 @@ #include "paddle/fluid/lite/core/optimizer.h" #include +#include +#include #include "paddle/fluid/lite/core/mir/generate_program_pass.h" #include "paddle/fluid/lite/core/mir/pass_manager.h" #include "paddle/fluid/lite/core/mir/passes.h" diff --git a/paddle/fluid/lite/core/program.h b/paddle/fluid/lite/core/program.h index c38bf0630f5..33f2f2a7789 100644 --- a/paddle/fluid/lite/core/program.h +++ b/paddle/fluid/lite/core/program.h @@ -14,10 +14,11 @@ #pragma once #include +#include #include +#include #include #include "paddle/fluid/lite/core/kernel.h" -#include "paddle/fluid/lite/core/kernel.h" #include "paddle/fluid/lite/core/mir/node.h" #include "paddle/fluid/lite/core/op_lite.h" #include "paddle/fluid/lite/core/op_registry.h" @@ -25,7 +26,7 @@ namespace paddle { namespace lite { -static const std::string kKernelTypeAttr = "__@kernel_type_attr@__"; +static const char kKernelTypeAttr[] = "__@kernel_type_attr@__"; // A program is used to represent a code program, in Paddle, a code program // contains: diff --git a/paddle/fluid/lite/core/program_fake_utils.h b/paddle/fluid/lite/core/program_fake_utils.h index 7d01c5a467e..6d24897ca6f 100644 --- a/paddle/fluid/lite/core/program_fake_utils.h +++ b/paddle/fluid/lite/core/program_fake_utils.h @@ -13,7 +13,11 @@ // limitations under the License. #pragma once +#include +#include #include +#include +#include #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/lite/core/mir/ssa_graph.h" #include "paddle/fluid/lite/core/op_registry.h" diff --git a/paddle/fluid/lite/core/target_wrapper.cc b/paddle/fluid/lite/core/target_wrapper.cc index 4978f622f97..5ce5f3942d8 100644 --- a/paddle/fluid/lite/core/target_wrapper.cc +++ b/paddle/fluid/lite/core/target_wrapper.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/lite/core/target_wrapper.h" +#include #include "paddle/fluid/lite/utils/all.h" namespace paddle { @@ -43,4 +44,4 @@ std::string Place::DebugString() const { } } // namespace lite -} // namespace paddle \ No newline at end of file +} // namespace paddle diff --git a/paddle/fluid/lite/core/target_wrapper.h b/paddle/fluid/lite/core/target_wrapper.h index 7afd6e1926d..cf0632d3879 100644 --- a/paddle/fluid/lite/core/target_wrapper.h +++ b/paddle/fluid/lite/core/target_wrapper.h @@ -82,11 +82,11 @@ struct Place { TargetType target{TARGET(kUnk)}; PrecisionType precision{PRECISION(kUnk)}; DataLayoutType layout{DATALAYOUT(kUnk)}; - short device{0}; // device ID + int16_t device{0}; // device ID Place() = default; Place(TargetType target, PrecisionType precision, - DataLayoutType layout = DATALAYOUT(kNCHW), short device = 0) + DataLayoutType layout = DATALAYOUT(kNCHW), int16_t device = 0) : target(target), precision(precision), layout(layout), device(device) {} bool is_valid() const { diff --git a/paddle/fluid/lite/core/variable.h b/paddle/fluid/lite/core/variable.h index dc0a211d60b..c83871446d2 100644 --- a/paddle/fluid/lite/core/variable.h +++ b/paddle/fluid/lite/core/variable.h @@ -13,6 +13,8 @@ // limitations under the License. #pragma once +#include +#include #include "paddle/fluid/lite/core/compatible_tensor.h" #include "paddle/fluid/lite/utils/all.h" diff --git a/paddle/fluid/lite/cuda/target_wrapper.h b/paddle/fluid/lite/cuda/target_wrapper.h index 6040f444f02..4567db3e216 100644 --- a/paddle/fluid/lite/cuda/target_wrapper.h +++ b/paddle/fluid/lite/cuda/target_wrapper.h @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#pragma once #include #include #include "paddle/fluid/lite/core/target_wrapper.h" diff --git a/paddle/fluid/lite/kernels/host/relu_compute.h b/paddle/fluid/lite/kernels/host/relu_compute.h index 5a1fd41c172..aae9e161aab 100644 --- a/paddle/fluid/lite/kernels/host/relu_compute.h +++ b/paddle/fluid/lite/kernels/host/relu_compute.h @@ -13,6 +13,7 @@ // limitations under the License. #pragma once +#include #include "paddle/fluid/lite/core/kernel.h" #include "paddle/fluid/lite/core/op_registry.h" diff --git a/paddle/fluid/lite/model_parser/model_parser.cc b/paddle/fluid/lite/model_parser/model_parser.cc index 54e99cfb1a8..2addf5ff911 100644 --- a/paddle/fluid/lite/model_parser/model_parser.cc +++ b/paddle/fluid/lite/model_parser/model_parser.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/lite/model_parser/model_parser.h" +#include #include +#include #include "paddle/fluid/lite/core/compatible_tensor.h" #include "paddle/fluid/lite/core/scope.h" #include "paddle/fluid/lite/core/variable.h" @@ -218,8 +220,8 @@ void TensorToStream(std::ostream &os, const lite::Tensor &tensor) { tensor.data_size(), IoDirection::DtoH); os.write(static_cast(tmp_buffer.get()), static_cast(size)); - } else -#endif // LITE_WITH_CUDA + } else // NOLINT +#endif // LITE_WITH_CUDA { os.write(static_cast(tensor.data()), static_cast(size)); diff --git a/paddle/fluid/lite/model_parser/model_parser.h b/paddle/fluid/lite/model_parser/model_parser.h index 8cea4df2c86..de40c82ab7d 100644 --- a/paddle/fluid/lite/model_parser/model_parser.h +++ b/paddle/fluid/lite/model_parser/model_parser.h @@ -15,6 +15,7 @@ // This file contains model format related operations, such as load a model, // parse an operator definitions and so on. +#pragma once #include #include #include diff --git a/paddle/fluid/lite/model_parser/pb/block_desc.cc b/paddle/fluid/lite/model_parser/pb/block_desc.cc index ce71e4de2b8..2b9c2314cf0 100644 --- a/paddle/fluid/lite/model_parser/pb/block_desc.cc +++ b/paddle/fluid/lite/model_parser/pb/block_desc.cc @@ -11,3 +11,5 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + +#include "paddle/fluid/lite/model_parser/pb/block_desc.h" diff --git a/paddle/fluid/lite/model_parser/pb/op_desc.h b/paddle/fluid/lite/model_parser/pb/op_desc.h index fd1613f78f0..b1fbce54d86 100644 --- a/paddle/fluid/lite/model_parser/pb/op_desc.h +++ b/paddle/fluid/lite/model_parser/pb/op_desc.h @@ -21,6 +21,8 @@ */ #include +#include +#include #include #include #include @@ -44,7 +46,7 @@ class OpDesc { public: OpDesc() {} - OpDesc(const framework::proto::OpDesc &desc) : desc_(desc) {} + explicit OpDesc(const framework::proto::OpDesc &desc) : desc_(desc) {} void CopyFrom(const OpDesc &op_desc) { desc_ = op_desc.ReadonlyProto(); } @@ -127,13 +129,13 @@ class OpDesc { } size_t hash = typeid(T).hash_code(); - if (hash == typeid(int).hash_code()) { + if (hash == typeid(int).hash_code()) { // NOLINT it->set_type(framework::proto::INT); it->set_i(v); - } else if (hash == typeid(float).hash_code()) { + } else if (hash == typeid(float).hash_code()) { // NOLINT it->set_type(framework::proto::FLOAT); it->set_f(v); - } else if (hash == typeid(bool).hash_code()) { + } else if (hash == typeid(bool).hash_code()) { // NOLINT it->set_type(framework::proto::BOOLEAN); it->set_b(v); } else { diff --git a/paddle/fluid/lite/model_parser/pb/program_desc.cc b/paddle/fluid/lite/model_parser/pb/program_desc.cc index ce71e4de2b8..744db6b53e8 100644 --- a/paddle/fluid/lite/model_parser/pb/program_desc.cc +++ b/paddle/fluid/lite/model_parser/pb/program_desc.cc @@ -11,3 +11,5 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + +#include "paddle/fluid/lite/model_parser/pb/program_desc.h" diff --git a/paddle/fluid/lite/model_parser/pb/program_desc.h b/paddle/fluid/lite/model_parser/pb/program_desc.h index ce71e4de2b8..c718a48c891 100644 --- a/paddle/fluid/lite/model_parser/pb/program_desc.h +++ b/paddle/fluid/lite/model_parser/pb/program_desc.h @@ -11,3 +11,5 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + +#pragma once diff --git a/paddle/fluid/lite/model_parser/pb/var_desc.cc b/paddle/fluid/lite/model_parser/pb/var_desc.cc index 2aaf5ee14d0..ac19f323b73 100644 --- a/paddle/fluid/lite/model_parser/pb/var_desc.cc +++ b/paddle/fluid/lite/model_parser/pb/var_desc.cc @@ -18,7 +18,7 @@ namespace paddle { namespace lite { namespace pb { -using namespace framework; +using namespace framework; // NOLINT proto::VarType::Type VarDesc::GetType() const { return desc_.type().type(); } diff --git a/paddle/fluid/lite/model_parser/pb/var_desc.h b/paddle/fluid/lite/model_parser/pb/var_desc.h index a29bd223928..55b756c4a05 100644 --- a/paddle/fluid/lite/model_parser/pb/var_desc.h +++ b/paddle/fluid/lite/model_parser/pb/var_desc.h @@ -119,5 +119,5 @@ class VarDesc { }; } // namespace pb -} // namespace framework +} // namespace lite } // namespace paddle diff --git a/paddle/fluid/lite/model_parser/runtime.h b/paddle/fluid/lite/model_parser/runtime.h index 38f710c9414..22beeb41abd 100644 --- a/paddle/fluid/lite/model_parser/runtime.h +++ b/paddle/fluid/lite/model_parser/runtime.h @@ -13,6 +13,9 @@ // limitations under the License. #pragma once +#include +#include +#include #include "paddle/fluid/framework/framework.pb.h" #include "paddle/fluid/lite/utils/all.h" @@ -44,7 +47,7 @@ class LoDTensorDesc { TensorDesc tensor; int lod_level{-1}; - LoDTensorDesc(const framework::proto::VarType_LoDTensorDesc& proto) { + explicit LoDTensorDesc(const framework::proto::VarType_LoDTensorDesc& proto) { Parse(proto); } diff --git a/paddle/fluid/lite/operators/relu_op.h b/paddle/fluid/lite/operators/relu_op.h index 66929cef199..a6204a107d8 100644 --- a/paddle/fluid/lite/operators/relu_op.h +++ b/paddle/fluid/lite/operators/relu_op.h @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#pragma once #include #include #include "paddle/fluid/lite/core/op_lite.h" @@ -25,7 +26,7 @@ namespace operators { class ReluOp : public OpLite { public: ReluOp() {} - ReluOp(const std::string &op_type) : OpLite(op_type) {} + explicit ReluOp(const std::string &op_type) : OpLite(op_type) {} bool CheckShape() const override; diff --git a/paddle/fluid/lite/utils/cp_logging.h b/paddle/fluid/lite/utils/cp_logging.h index 3fac352c1b2..d356b337abd 100644 --- a/paddle/fluid/lite/utils/cp_logging.h +++ b/paddle/fluid/lite/utils/cp_logging.h @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#pragma once #ifdef LITE_WITH_LIGHT_WEIGHT_FRAMEWORK #include "paddle/fluid/lite/utils/logging.h" #else // LITE_WITH_LIGHT_WEIGHT_FRAMEWORK diff --git a/paddle/fluid/lite/utils/factory.h b/paddle/fluid/lite/utils/factory.h index 97abce93747..3f86df842f1 100644 --- a/paddle/fluid/lite/utils/factory.h +++ b/paddle/fluid/lite/utils/factory.h @@ -17,7 +17,9 @@ #include #include #include +#include #include +#include #include "paddle/fluid/lite/utils/cp_logging.h" namespace paddle { @@ -83,7 +85,7 @@ class Factory { template class Registor { public: - Registor(std::function&& functor) { functor(); } + explicit Registor(std::function&& functor) { functor(); } // Touch will do nothing. int Touch() { return 0; } diff --git a/paddle/fluid/lite/utils/logging.h b/paddle/fluid/lite/utils/logging.h index 37294969920..9c2b6903e49 100644 --- a/paddle/fluid/lite/utils/logging.h +++ b/paddle/fluid/lite/utils/logging.h @@ -34,6 +34,7 @@ #define VLOG(level) LOG_INFO.stream() // CHECK() +// NOLINT #define CHECK(x) \ if (!(x)) \ paddle::lite::LogMessageFatal(__FILE__, __LINE__).stream() \ diff --git a/paddle/fluid/lite/utils/varient.h b/paddle/fluid/lite/utils/varient.h index 4a9eacabfdf..49714eea7f4 100644 --- a/paddle/fluid/lite/utils/varient.h +++ b/paddle/fluid/lite/utils/varient.h @@ -13,10 +13,12 @@ // limitations under the License. #pragma once +#include #include #include #include #include +#include #include "paddle/fluid/lite/utils/cp_logging.h" // This is an equivalent implementation of boost::any. We implement this to diff --git a/paddle/fluid/lite/x86/target_wrapper.cc b/paddle/fluid/lite/x86/target_wrapper.cc index 8fd941591ac..76a108c6d1d 100644 --- a/paddle/fluid/lite/x86/target_wrapper.cc +++ b/paddle/fluid/lite/x86/target_wrapper.cc @@ -15,6 +15,7 @@ #include "paddle/fluid/lite/core/target_wrapper.h" #include #include "paddle/fluid/lite/utils/all.h" +#include "paddle/fluid/lite/x86/target_wrapper.h" namespace paddle { namespace lite { -- GitLab