From b2df4c765a1165e3cdaec3cb8557273b703b8678 Mon Sep 17 00:00:00 2001 From: Sing_chan <51314274+betterpig@users.noreply.github.com> Date: Tue, 21 Jun 2022 11:55:54 +0800 Subject: [PATCH] remove .clang-format in paddle/fluid to use the same config (#43678) --- .clang-format | 2 + paddle/fluid/.clang-format | 5 --- .../paddle2cinn/cinn_graph_symbolization.cc | 43 +++++++++++-------- .../paddle2cinn/cinn_graph_symbolization.h | 5 +-- .../framework/paddle2cinn/transform_desc.h | 3 -- .../infrt/dialect/infrt/ir/infrt_dialect.cc | 2 - paddle/infrt/tests/models/test_abs.cc | 2 - paddle/phi/kernels/gpu/gelu_grad_kernel.cu | 2 - 8 files changed, 30 insertions(+), 34 deletions(-) delete mode 100644 paddle/fluid/.clang-format diff --git a/.clang-format b/.clang-format index 8b58306273..04f2bbaf85 100644 --- a/.clang-format +++ b/.clang-format @@ -24,4 +24,6 @@ Standard: Cpp11 AllowAllParametersOfDeclarationOnNextLine: true BinPackParameters: false BinPackArguments: false +IncludeBlocks: Preserve +IncludeIsMainSourceRegex: (\.cu)$ ... diff --git a/paddle/fluid/.clang-format b/paddle/fluid/.clang-format deleted file mode 100644 index 29282dc87e..0000000000 --- a/paddle/fluid/.clang-format +++ /dev/null @@ -1,5 +0,0 @@ ---- -Language: Cpp -BasedOnStyle: Google -Standard: Cpp11 -... diff --git a/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.cc b/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.cc index 4e362057c9..0e1a75ebe6 100644 --- a/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.cc +++ b/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.cc @@ -12,7 +12,6 @@ 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. */ -// clang-format off #include "paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.h" #include @@ -31,7 +30,6 @@ limitations under the License. */ #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/errors.h" -// clang-format on namespace paddle { namespace framework { @@ -79,7 +77,8 @@ FeedInfoMap CinnGraphSymbolization::GetFeedInfoMapFromInput() const { for (auto& feed_pair : input_tensors_) { const auto& feed_name = feed_pair.first; const auto* tensor = feed_pair.second; - PADDLE_ENFORCE_NE(tensor, nullptr, + PADDLE_ENFORCE_NE(tensor, + nullptr, platform::errors::PreconditionNotMet( "The input variable %s's tensor cannot be NULL," "we need the variable's dtype and shape from tensor.", @@ -96,7 +95,8 @@ FeedInfoMap CinnGraphSymbolization::GetFeedInfoMapFromInput() const { } PADDLE_ENFORCE_NE( - feed_map[feed_name].shape.size(), 0UL, + feed_map[feed_name].shape.size(), + 0UL, platform::errors::PreconditionNotMet( "The input variable %s's tensor shape cannot be empty," "we need the variable's dtype and shape from tensor.", @@ -136,7 +136,8 @@ CinnGraphSymbolization::CreateCinnScope(const FeedInfoMap& feed_map) { for (const auto& param_name : parameter_names) { PADDLE_ENFORCE_GT( - feed_map.count(param_name), 0UL, + feed_map.count(param_name), + 0UL, platform::errors::NotFound("Cannot find parameter %s from input list," "please add the tensor into input.", param_name.c_str())); @@ -162,12 +163,12 @@ CinnGraphSymbolization::CreateCinnScope(const FeedInfoMap& feed_map) { std::vector CinnGraphSymbolization::TopologicalSort() const { std::unordered_set op_nodes; - std::for_each(graph_.Nodes().begin(), graph_.Nodes().end(), - [&op_nodes](Node* n) { - if (n->IsOp()) { - op_nodes.emplace(n); - } - }); + std::for_each( + graph_.Nodes().begin(), graph_.Nodes().end(), [&op_nodes](Node* n) { + if (n->IsOp()) { + op_nodes.emplace(n); + } + }); std::unordered_map> adj_list; std::unordered_map in_degrees; @@ -210,7 +211,8 @@ std::vector CinnGraphSymbolization::TopologicalSort() const { } } - PADDLE_ENFORCE_EQ(sorted_ops.size(), op_nodes.size(), + PADDLE_ENFORCE_EQ(sorted_ops.size(), + op_nodes.size(), platform::errors::PreconditionNotMet( "The sorting graph contains cycles.")); return sorted_ops; @@ -234,7 +236,8 @@ void CinnGraphSymbolization::RunOp(const CinnOpDesc& op_desc, const OpMapperContext& ctx) const { const auto& op_type = op_desc.Type(); auto* kernel = ::cinn::frontend::OpMapperRegistry::Global()->Find(op_type); - PADDLE_ENFORCE_NE(kernel, nullptr, + PADDLE_ENFORCE_NE(kernel, + nullptr, platform::errors::NotFound( "Op %s is Not Supported by CINN, please register" " this op in the CINN repo.", @@ -256,10 +259,12 @@ std::unordered_set CinnGraphSymbolization::GetFetchIds() const { std::unordered_set fetch_names; fetch_names.reserve(fetch_var_names_.size()); std::for_each( - fetch_var_names_.begin(), fetch_var_names_.end(), + fetch_var_names_.begin(), + fetch_var_names_.end(), [this, &fetch_names](const std::string& name) { PADDLE_ENFORCE_EQ( - var_model_to_program_map_.count(name), 1, + var_model_to_program_map_.count(name), + 1, platform::errors::PreconditionNotMet( "Cannot find %s in var_model_to_program_map_", name.c_str())); fetch_names.insert(var_model_to_program_map_.at(name)); @@ -276,8 +281,12 @@ std::unordered_set CinnGraphSymbolization::GetFetchIds() const { auto feed_map = GetFeedInfoMapFromInput(); auto cinn_scope = CreateCinnScope(feed_map); - OpMapperContext ctx(*cinn_scope, target_, &builder, &var_map_, - &var_model_to_program_map_, &fetch_var_names_); + OpMapperContext ctx(*cinn_scope, + target_, + &builder, + &var_map_, + &var_model_to_program_map_, + &fetch_var_names_); // add all tensor's feed info into context for (auto& feed_pair : feed_map) { ctx.AddFeedInfo(feed_pair.first, feed_pair.second); diff --git a/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.h b/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.h index 4155147da4..0061aa5489 100644 --- a/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.h +++ b/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.h @@ -14,7 +14,6 @@ limitations under the License. */ #pragma once -// clang-format off #include #include #include @@ -27,7 +26,6 @@ limitations under the License. */ #include "cinn/frontend/net_builder.h" #include "cinn/frontend/op_mapper_registry.h" -// clang-format on namespace paddle { namespace framework { @@ -65,7 +63,8 @@ namespace paddle2cinn { class CinnGraphSymbolization { public: CinnGraphSymbolization( - int64_t graph_id, const ir::Graph& graph, + int64_t graph_id, + const ir::Graph& graph, const ::cinn::common::Target& target, const std::map& input_tensors) : graph_id_(graph_id), diff --git a/paddle/fluid/framework/paddle2cinn/transform_desc.h b/paddle/fluid/framework/paddle2cinn/transform_desc.h index 6f0931b6d0..76a4f81273 100644 --- a/paddle/fluid/framework/paddle2cinn/transform_desc.h +++ b/paddle/fluid/framework/paddle2cinn/transform_desc.h @@ -14,8 +14,6 @@ #pragma once -// The headers cant be sorted by clang-format or compilint error occurs. -// clang-format off #include "paddle/fluid/framework/block_desc.h" #include "paddle/fluid/framework/op_desc.h" #include "paddle/fluid/framework/program_desc.h" @@ -26,7 +24,6 @@ #include "cinn/frontend/paddle/cpp/op_desc.h" #include "cinn/frontend/paddle/cpp/program_desc.h" #include "cinn/frontend/paddle/cpp/var_desc.h" -// clang-format on namespace paddle { namespace framework { diff --git a/paddle/infrt/dialect/infrt/ir/infrt_dialect.cc b/paddle/infrt/dialect/infrt/ir/infrt_dialect.cc index 0e3a10270c..c4f20cb4d3 100644 --- a/paddle/infrt/dialect/infrt/ir/infrt_dialect.cc +++ b/paddle/infrt/dialect/infrt/ir/infrt_dialect.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// clang-format off #include "paddle/infrt/dialect/infrt/ir/infrt_dialect.h" #include @@ -61,7 +60,6 @@ void InfrtDialect::initialize() { #include "paddle/infrt/dialect/infrt/ir/test_kernels.cpp.inc" >(); } -// clang-format on /// Parse a type registered to this dialect. mlir::Type InfrtDialect::parseType(::mlir::DialectAsmParser &parser) const { diff --git a/paddle/infrt/tests/models/test_abs.cc b/paddle/infrt/tests/models/test_abs.cc index aa5a2c6945..89bbe78ffe 100644 --- a/paddle/infrt/tests/models/test_abs.cc +++ b/paddle/infrt/tests/models/test_abs.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// clang-format off #include #include #include @@ -50,7 +49,6 @@ #include "paddle/infrt/dialect/phi/ir/infrt_phi_tensor.h" #include "paddle/infrt/dialect/phi/ir/phi_base.h" #include "paddle/infrt/dialect/phi/ir/phi_kernels.h" -// clang-format on static llvm::cl::list cl_shared_libs( // NOLINT "shared_libs", diff --git a/paddle/phi/kernels/gpu/gelu_grad_kernel.cu b/paddle/phi/kernels/gpu/gelu_grad_kernel.cu index 7ed2b6b71f..1f33d5c901 100644 --- a/paddle/phi/kernels/gpu/gelu_grad_kernel.cu +++ b/paddle/phi/kernels/gpu/gelu_grad_kernel.cu @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// clang-format off #include "paddle/phi/kernels/gelu_kernel.h" #include "paddle/phi/backends/gpu/gpu_context.h" @@ -21,7 +20,6 @@ #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/broadcast_function.h" #include "paddle/phi/kernels/gpu/gelu_funcs.h" -// clang-format on DECLARE_bool(use_fast_math); -- GitLab