From 6af06cd87aa3582521f6d33e2e91176545fc0421 Mon Sep 17 00:00:00 2001 From: walk_alone <2390335608@qq.com> Date: Thu, 30 May 2024 20:15:33 +0800 Subject: [PATCH] part 4 --- .../spmd_rules/dist_tensor_spec.cc | 8 ++------ .../fleet_executor/fleet_executor.cc | 6 ++---- .../distributed/fleet_executor/task_node.cc | 6 ++---- paddle/fluid/framework/attribute.cc | 6 ++---- .../framework/ir/attention_lstm_fuse_pass.cc | 8 ++------ paddle/fluid/framework/ir/fuse_pass_base.cc | 14 ++++--------- .../operator_unsqueeze2_onednn_fuse_pass.cc | 8 ++------ .../framework/ir/op_compat_sensible_pass.cc | 8 ++------ .../ir/set_transformer_input_convert_pass.cc | 12 ++++------- ...t_embedding_eltwise_layernorm_fuse_pass.cc | 20 ++++++------------- .../control_flow/while_instruction.cc | 6 ++---- .../instruction/phi_kernel_instruction.cc | 6 ++---- .../new_executor/interpreter/static_build.cc | 8 ++------ paddle/fluid/framework/trainer_factory.cc | 6 ++---- paddle/fluid/framework/var_desc.cc | 6 ++---- paddle/fluid/imperative/tracer.cc | 6 ++---- .../passes/inference_op_replace_pass.cc | 8 ++------ .../inference/tensorrt/convert/arg_max_op.cc | 8 ++------ .../inference/tensorrt/convert/clip_op.cc | 8 ++------ .../inference/tensorrt/convert/cumsum_op.cc | 8 ++------ .../tensorrt/convert/deformable_conv_op.cc | 8 ++------ .../tensorrt/convert/dequantize_linear_op.cc | 8 ++------ .../tensorrt/convert/fill_any_like_op.cc | 8 ++------ .../tensorrt/convert/logsigmoid_op.cc | 8 ++------ .../inference/tensorrt/convert/one_hot_op.cc | 18 ++++++----------- .../memory/allocation/buffered_allocator.cc | 8 ++------ .../memory/allocation/retry_allocator.cc | 8 ++------ .../allocation/thread_local_allocator.cc | 8 ++------ paddle/fluid/memory/memcpy.cc | 6 ++---- .../operators/controlflow/while_op_helper.cc | 12 ++++------- .../operators/fused/fused_gemm_epilogue_op.cc | 6 ++---- .../pscore/distributed_push_sparse_op.cc | 6 ++---- .../operators/reader/create_py_reader_op.cc | 8 ++------ .../operators/reduce_ops/reduce_mean_op.cc | 6 ++---- paddle/fluid/platform/collective_helper.cc | 6 ++---- .../platform/device/gpu/gpu_resource_pool.cc | 6 ++---- paddle/fluid/primitive/utils/static_utils.cc | 6 ++---- paddle/fluid/pybind/communication.cc | 6 ++---- paddle/fluid/pybind/eager.cc | 6 ++---- paddle/phi/backends/gpu/cuda/cuda_info.cc | 8 ++------ .../distributed/auto_parallel/device_mesh.cc | 8 ++------ .../auto_parallel/placement_types.cc | 6 ++---- paddle/phi/infermeta/spmd_rules/dim_trans.cc | 6 ++---- paddle/phi/infermeta/spmd_rules/layer_norm.cc | 6 ++---- paddle/phi/infermeta/spmd_rules/scale.cc | 6 ++---- .../phi/kernels/selected_rows/scale_kernel.cc | 6 ++---- paddle/pir/src/core/op_operand_impl.cc | 6 ++---- 47 files changed, 108 insertions(+), 258 deletions(-) diff --git a/paddle/fluid/distributed/auto_parallel/spmd_rules/dist_tensor_spec.cc b/paddle/fluid/distributed/auto_parallel/spmd_rules/dist_tensor_spec.cc index 36b6322836b20..4652ebafbe312 100644 --- a/paddle/fluid/distributed/auto_parallel/spmd_rules/dist_tensor_spec.cc +++ b/paddle/fluid/distributed/auto_parallel/spmd_rules/dist_tensor_spec.cc @@ -16,9 +16,7 @@ limitations under the License. */ #include "paddle/phi/core/distributed/auto_parallel/utils.h" -namespace paddle { -namespace distributed { -namespace auto_parallel { +namespace paddle::distributed::auto_parallel { DistTensorSpec::DistTensorSpec(const std::vector& shape, const TensorDistAttr& dist_attr) { @@ -82,6 +80,4 @@ std::string DistTensorSpec::to_string() const { return spec_str; } -} // namespace auto_parallel -} // namespace distributed -} // namespace paddle +} // namespace paddle::distributed::auto_parallel diff --git a/paddle/fluid/distributed/fleet_executor/fleet_executor.cc b/paddle/fluid/distributed/fleet_executor/fleet_executor.cc index 91c24a19e6bbc..73f11b7281511 100644 --- a/paddle/fluid/distributed/fleet_executor/fleet_executor.cc +++ b/paddle/fluid/distributed/fleet_executor/fleet_executor.cc @@ -28,8 +28,7 @@ #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/variable.h" -namespace paddle { -namespace distributed { +namespace paddle::distributed { FleetExecutor::FleetExecutor(const std::string& exe_desc_str) : carrier_ids_() { bool parse_flag = exe_desc_.ParseFromString(exe_desc_str); @@ -290,5 +289,4 @@ void FleetExecutor::Run(const std::string& carrier_id) { carrier->Start(); } -} // namespace distributed -} // namespace paddle +} // namespace paddle::distributed diff --git a/paddle/fluid/distributed/fleet_executor/task_node.cc b/paddle/fluid/distributed/fleet_executor/task_node.cc index 5964f4c52f3fb..bbfd656cf94f9 100644 --- a/paddle/fluid/distributed/fleet_executor/task_node.cc +++ b/paddle/fluid/distributed/fleet_executor/task_node.cc @@ -18,8 +18,7 @@ #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" -namespace paddle { -namespace distributed { +namespace paddle::distributed { namespace { using OperatorBase = TaskNode::OperatorBase; } @@ -186,5 +185,4 @@ void TaskNode::SetSendDownPerSteps(int64_t value) { send_down_per_steps_ = value; } -} // namespace distributed -} // namespace paddle +} // namespace paddle::distributed diff --git a/paddle/fluid/framework/attribute.cc b/paddle/fluid/framework/attribute.cc index 483c6f17d9b30..affc269f27b2b 100644 --- a/paddle/fluid/framework/attribute.cc +++ b/paddle/fluid/framework/attribute.cc @@ -17,8 +17,7 @@ limitations under the License. */ #include "paddle/phi/common/scalar.h" #include "paddle/utils/blank.h" -namespace paddle { -namespace framework { +namespace paddle::framework { paddle::any GetAttrValue(const Attribute& attr) { switch (AttrTypeID(attr)) { @@ -319,5 +318,4 @@ void CanonicalizeScalarAttrs(const proto::OpProto& op_proto, } } } -} // namespace framework -} // namespace paddle +} // namespace paddle::framework diff --git a/paddle/fluid/framework/ir/attention_lstm_fuse_pass.cc b/paddle/fluid/framework/ir/attention_lstm_fuse_pass.cc index 5e82534ba6745..4e826f9e6bbb1 100644 --- a/paddle/fluid/framework/ir/attention_lstm_fuse_pass.cc +++ b/paddle/fluid/framework/ir/attention_lstm_fuse_pass.cc @@ -19,9 +19,7 @@ #include "paddle/fluid/framework/ir/graph_pattern_detector.h" #include "paddle/fluid/framework/ir/graph_viz_pass.h" -namespace paddle { -namespace framework { -namespace ir { +namespace paddle::framework::ir { AttentionLSTMFusePass::AttentionLSTMFusePass() { AddOpCompat(OpCompat("while")) @@ -377,9 +375,7 @@ void AttentionLSTMFusePass::ApplyImpl(ir::Graph* graph) const { FindWhileOp(graph); } -} // namespace ir -} // namespace framework -} // namespace paddle +} // namespace paddle::framework::ir REGISTER_PASS(attention_lstm_fuse_pass, paddle::framework::ir::AttentionLSTMFusePass); diff --git a/paddle/fluid/framework/ir/fuse_pass_base.cc b/paddle/fluid/framework/ir/fuse_pass_base.cc index 83d60ee4e9799..cb610606e65b4 100644 --- a/paddle/fluid/framework/ir/fuse_pass_base.cc +++ b/paddle/fluid/framework/ir/fuse_pass_base.cc @@ -16,15 +16,11 @@ #include "paddle/fluid/platform/enforce.h" -namespace paddle { -namespace framework { +namespace paddle::framework { class Scope; -} // namespace framework -} // namespace paddle +} // namespace paddle::framework -namespace paddle { -namespace framework { -namespace ir { +namespace paddle::framework::ir { class Graph; @@ -77,6 +73,4 @@ FuseOptions FusePassBase::FindFuseOption(const Node& node1, #endif } -} // namespace ir -} // namespace framework -} // namespace paddle +} // namespace paddle::framework::ir diff --git a/paddle/fluid/framework/ir/onednn/operator_unsqueeze2_onednn_fuse_pass.cc b/paddle/fluid/framework/ir/onednn/operator_unsqueeze2_onednn_fuse_pass.cc index 2aea55f473fd4..359c2bfdc1e0e 100644 --- a/paddle/fluid/framework/ir/onednn/operator_unsqueeze2_onednn_fuse_pass.cc +++ b/paddle/fluid/framework/ir/onednn/operator_unsqueeze2_onednn_fuse_pass.cc @@ -18,9 +18,7 @@ #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/utils/string/pretty_log.h" -namespace paddle { -namespace framework { -namespace ir { +namespace paddle::framework::ir { using string::PrettyLogDetail; @@ -109,9 +107,7 @@ void FuseOperatorUnsqueeze2OneDNNPass::FuseUnsqueeze2( op_type); } -} // namespace ir -} // namespace framework -} // namespace paddle +} // namespace paddle::framework::ir REGISTER_PASS(operator_unsqueeze2_onednn_fuse_pass, paddle::framework::ir::FuseOperatorUnsqueeze2OneDNNPass); diff --git a/paddle/fluid/framework/ir/op_compat_sensible_pass.cc b/paddle/fluid/framework/ir/op_compat_sensible_pass.cc index 895a4f88c3c44..da7febfc0cd8b 100644 --- a/paddle/fluid/framework/ir/op_compat_sensible_pass.cc +++ b/paddle/fluid/framework/ir/op_compat_sensible_pass.cc @@ -38,9 +38,7 @@ std::unordered_set global_extra_attrs = { "with_quant_attr"}; } // namespace -namespace paddle { -namespace framework { -namespace ir { +namespace paddle::framework::ir { AttrCompat& AttrCompat::IsStringEQ(const std::string& value) { conditions_.emplace_back([value](const Attribute& attr) -> bool { @@ -325,6 +323,4 @@ bool OpCompatSensiblePass::IsCompat( return true; } -} // namespace ir -} // namespace framework -} // namespace paddle +} // namespace paddle::framework::ir diff --git a/paddle/fluid/framework/ir/set_transformer_input_convert_pass.cc b/paddle/fluid/framework/ir/set_transformer_input_convert_pass.cc index 0ff7a6bc0ba2d..47cf59e329556 100644 --- a/paddle/fluid/framework/ir/set_transformer_input_convert_pass.cc +++ b/paddle/fluid/framework/ir/set_transformer_input_convert_pass.cc @@ -18,10 +18,7 @@ #include "paddle/fluid/framework/op_version_registry.h" -namespace paddle { -namespace framework { -namespace ir { -namespace patterns { +namespace paddle::framework::ir::patterns { void SetTransformerInputConvert::operator()(const std::string &pos_id) { std::unordered_set lookup_table_ops{"lookup_table", @@ -49,7 +46,8 @@ void MultiheadMatmulOP::operator()() { // links nodes. multihead_matmul_out->LinksFrom({multihead_matmul}); } -} // namespace patterns +} // namespace paddle::framework::ir::patterns +namespace paddle::framework::ir { void SetTransformerInputConvertPass::ApplyImpl(ir::Graph *graph) const { bool with_dynamic_shape = Get("with_dynamic_shape"); @@ -152,9 +150,7 @@ void SetTransformerInputConvertPass::ApplyImpl(ir::Graph *graph) const { AddStatis(found_subgraph_count); } -} // namespace ir -} // namespace framework -} // namespace paddle +} // namespace paddle::framework::ir REGISTER_PASS(set_transformer_input_convert_pass, paddle::framework::ir::SetTransformerInputConvertPass); diff --git a/paddle/fluid/framework/ir/trt_embedding_eltwise_layernorm_fuse_pass.cc b/paddle/fluid/framework/ir/trt_embedding_eltwise_layernorm_fuse_pass.cc index d7d73d1edd195..885e119b334bc 100644 --- a/paddle/fluid/framework/ir/trt_embedding_eltwise_layernorm_fuse_pass.cc +++ b/paddle/fluid/framework/ir/trt_embedding_eltwise_layernorm_fuse_pass.cc @@ -18,18 +18,11 @@ #include "paddle/fluid/framework/op_version_registry.h" -namespace paddle { -namespace framework { -namespace ir { +namespace paddle::framework::ir { class Node; -} // namespace ir -} // namespace framework -} // namespace paddle +} // namespace paddle::framework::ir -namespace paddle { -namespace framework { -namespace ir { -namespace patterns { +namespace paddle::framework::ir::patterns { static PDNode* create_emb_vars(PDPattern* pattern, const std::string& name, @@ -141,7 +134,8 @@ void TrtSkipLayerNorm::operator()() { .LinksTo({layer_norm_out, layer_norm_mean_var, layer_norm_variance_var}); } -} // namespace patterns +} // namespace paddle::framework::ir::patterns +namespace paddle::framework::ir { int TrtEmbeddingEltwiseLayerNormFusePass::BuildFusion( Graph* graph, const std::string& name_scope @@ -485,9 +479,7 @@ void TrtEmbeddingEltwiseLayerNormFusePass::ApplyImpl(Graph* graph) const { AddStatis(fusion_count); } -} // namespace ir -} // namespace framework -} // namespace paddle +} // namespace paddle::framework::ir REGISTER_PASS(trt_embedding_eltwise_layernorm_fuse_pass, paddle::framework::ir::TrtEmbeddingEltwiseLayerNormFusePass); diff --git a/paddle/fluid/framework/new_executor/instruction/control_flow/while_instruction.cc b/paddle/fluid/framework/new_executor/instruction/control_flow/while_instruction.cc index c7067ea5110a9..d3ae9b3e29a77 100644 --- a/paddle/fluid/framework/new_executor/instruction/control_flow/while_instruction.cc +++ b/paddle/fluid/framework/new_executor/instruction/control_flow/while_instruction.cc @@ -42,8 +42,7 @@ #include "paddle/fluid/platform/onednn_helper.h" #endif -namespace paddle { -namespace framework { +namespace paddle::framework { WhileInstruction::WhileInstruction( size_t id, @@ -237,5 +236,4 @@ void WhileInstruction::Run() { VLOG(6) << "while instruction run done"; } -} // namespace framework -} // namespace paddle +} // namespace paddle::framework diff --git a/paddle/fluid/framework/new_executor/instruction/phi_kernel_instruction.cc b/paddle/fluid/framework/new_executor/instruction/phi_kernel_instruction.cc index 504b3eaf48fc3..41f13cb261287 100644 --- a/paddle/fluid/framework/new_executor/instruction/phi_kernel_instruction.cc +++ b/paddle/fluid/framework/new_executor/instruction/phi_kernel_instruction.cc @@ -33,8 +33,7 @@ #include "paddle/pir/include/core/value.h" #include "paddle/fluid/framework/new_executor/instruction/instruction_util.h" -namespace paddle { -namespace framework { +namespace paddle::framework { PhiKernelInstruction::PhiKernelInstruction( size_t id, @@ -186,5 +185,4 @@ void PhiKernelInstruction::Run() { VLOG(6) << "End run op " << phi_op_name_ << " kernel."; } -} // namespace framework -} // namespace paddle +} // namespace paddle::framework diff --git a/paddle/fluid/framework/new_executor/interpreter/static_build.cc b/paddle/fluid/framework/new_executor/interpreter/static_build.cc index dc5b5ddfced49..557f91a3dfa1a 100644 --- a/paddle/fluid/framework/new_executor/interpreter/static_build.cc +++ b/paddle/fluid/framework/new_executor/interpreter/static_build.cc @@ -63,9 +63,7 @@ std::set StaticBuildBlackList = { "sparse_sparse_coo_tensor" /*: to handle sparse output*/, "distributed_fused_lamb_init"}; -namespace paddle { -namespace framework { -namespace interpreter { +namespace paddle::framework::interpreter { using InterpreterCore = framework::InterpreterCore; @@ -991,6 +989,4 @@ void FakeInitializeOutputsForStructureKernel( } } -} // namespace interpreter -} // namespace framework -} // namespace paddle +} // namespace paddle::framework::interpreter diff --git a/paddle/fluid/framework/trainer_factory.cc b/paddle/fluid/framework/trainer_factory.cc index 81b2df6efc723..61ba78c8147cd 100644 --- a/paddle/fluid/framework/trainer_factory.cc +++ b/paddle/fluid/framework/trainer_factory.cc @@ -21,8 +21,7 @@ limitations under the License. */ #include "glog/logging.h" -namespace paddle { -namespace framework { +namespace paddle::framework { class TrainerBase; @@ -85,5 +84,4 @@ REGISTER_TRAINER_CLASS(PSGPUTrainer); #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) REGISTER_TRAINER_CLASS(PipelineTrainer); #endif -} // namespace framework -} // namespace paddle +} // namespace paddle::framework diff --git a/paddle/fluid/framework/var_desc.cc b/paddle/fluid/framework/var_desc.cc index 960115a2541c9..9d6992f2c2f81 100644 --- a/paddle/fluid/framework/var_desc.cc +++ b/paddle/fluid/framework/var_desc.cc @@ -19,8 +19,7 @@ limitations under the License. */ #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/platform/enforce.h" -namespace paddle { -namespace framework { +namespace paddle::framework { VarDesc::VarDesc(const VarDesc &other) : desc_(other.desc_), @@ -459,5 +458,4 @@ bool operator==(const VarDesc &left, const VarDesc &right) { right.Proto()->SerializeAsString(); } -} // namespace framework -} // namespace paddle +} // namespace paddle::framework diff --git a/paddle/fluid/imperative/tracer.cc b/paddle/fluid/imperative/tracer.cc index 7aa4652ec0058..6c7cf3f34bb67 100644 --- a/paddle/fluid/imperative/tracer.cc +++ b/paddle/fluid/imperative/tracer.cc @@ -40,8 +40,7 @@ COMMON_DECLARE_string(tracer_onednn_ops_on); COMMON_DECLARE_string(tracer_onednn_ops_off); COMMON_DECLARE_bool(use_stride_kernel); -namespace paddle { -namespace imperative { +namespace paddle::imperative { thread_local std::string Tracer::python_stack_ = ""; thread_local bool Tracer::has_grad_ = true; @@ -650,5 +649,4 @@ phi::KernelSignature Tracer::GetExpectedKernelSignature( } } -} // namespace imperative -} // namespace paddle +} // namespace paddle::imperative diff --git a/paddle/fluid/inference/analysis/passes/inference_op_replace_pass.cc b/paddle/fluid/inference/analysis/passes/inference_op_replace_pass.cc index 993ab2e8618f4..85daf816db00b 100644 --- a/paddle/fluid/inference/analysis/passes/inference_op_replace_pass.cc +++ b/paddle/fluid/inference/analysis/passes/inference_op_replace_pass.cc @@ -16,9 +16,7 @@ #include "paddle/fluid/inference/analysis/argument.h" -namespace paddle { -namespace inference { -namespace analysis { +namespace paddle::inference::analysis { void InferenceOpReplacePass::RunImpl(Argument* argument) { if (argument->use_pir()) { @@ -47,6 +45,4 @@ std::string InferenceOpReplacePass::repr() const { return "inference_op_replace_pass"; } -} // namespace analysis -} // namespace inference -} // namespace paddle +} // namespace paddle::inference::analysis diff --git a/paddle/fluid/inference/tensorrt/convert/arg_max_op.cc b/paddle/fluid/inference/tensorrt/convert/arg_max_op.cc index 3b2301256cd05..8dfc7c5522a72 100644 --- a/paddle/fluid/inference/tensorrt/convert/arg_max_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/arg_max_op.cc @@ -14,9 +14,7 @@ limitations under the License. */ #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" -namespace paddle { -namespace inference { -namespace tensorrt { +namespace paddle::inference::tensorrt { class ArgMaxOpConverter : public OpConverter { public: @@ -61,8 +59,6 @@ class ArgMaxOpConverter : public OpConverter { } }; -} // namespace tensorrt -} // namespace inference -} // namespace paddle +} // namespace paddle::inference::tensorrt REGISTER_TRT_OP_CONVERTER(arg_max, ArgMaxOpConverter); diff --git a/paddle/fluid/inference/tensorrt/convert/clip_op.cc b/paddle/fluid/inference/tensorrt/convert/clip_op.cc index 5bd2a73c3fefb..9ed28cd27dc12 100644 --- a/paddle/fluid/inference/tensorrt/convert/clip_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/clip_op.cc @@ -14,9 +14,7 @@ limitations under the License. */ #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" -namespace paddle { -namespace inference { -namespace tensorrt { +namespace paddle::inference::tensorrt { /* * ClipOp @@ -48,8 +46,6 @@ class ClipOpConverter : public OpConverter { } }; -} // namespace tensorrt -} // namespace inference -} // namespace paddle +} // namespace paddle::inference::tensorrt REGISTER_TRT_OP_CONVERTER(clip, ClipOpConverter); diff --git a/paddle/fluid/inference/tensorrt/convert/cumsum_op.cc b/paddle/fluid/inference/tensorrt/convert/cumsum_op.cc index a18d16bd012fb..a6de4bce94a25 100644 --- a/paddle/fluid/inference/tensorrt/convert/cumsum_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/cumsum_op.cc @@ -14,9 +14,7 @@ limitations under the License. */ #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" -namespace paddle { -namespace inference { -namespace tensorrt { +namespace paddle::inference::tensorrt { /* * Cumsum Op @@ -169,8 +167,6 @@ class CumsumOpConverter : public OpConverter { } }; -} // namespace tensorrt -} // namespace inference -} // namespace paddle +} // namespace paddle::inference::tensorrt REGISTER_TRT_OP_CONVERTER(cumsum, CumsumOpConverter); diff --git a/paddle/fluid/inference/tensorrt/convert/deformable_conv_op.cc b/paddle/fluid/inference/tensorrt/convert/deformable_conv_op.cc index 3983363455650..a978bfe31e779 100644 --- a/paddle/fluid/inference/tensorrt/convert/deformable_conv_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/deformable_conv_op.cc @@ -18,9 +18,7 @@ limitations under the License. */ #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" #include "paddle/fluid/inference/tensorrt/plugin/deformable_conv_op_plugin.h" -namespace paddle { -namespace inference { -namespace tensorrt { +namespace paddle::inference::tensorrt { class DeformableConvOpConverter : public OpConverter { void operator()(const framework::proto::OpDesc& op, @@ -139,8 +137,6 @@ class DeformableConvOpConverter : public OpConverter { } }; -} // namespace tensorrt -} // namespace inference -} // namespace paddle +} // namespace paddle::inference::tensorrt REGISTER_TRT_OP_CONVERTER(deformable_conv, DeformableConvOpConverter); diff --git a/paddle/fluid/inference/tensorrt/convert/dequantize_linear_op.cc b/paddle/fluid/inference/tensorrt/convert/dequantize_linear_op.cc index 662769e7f24ec..39760253e2666 100644 --- a/paddle/fluid/inference/tensorrt/convert/dequantize_linear_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/dequantize_linear_op.cc @@ -11,9 +11,7 @@ limitations under the License. */ #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" -namespace paddle { -namespace inference { -namespace tensorrt { +namespace paddle::inference::tensorrt { class DequantizeLinearOpConverter : public OpConverter { public: @@ -59,8 +57,6 @@ class DequantizeLinearOpConverter : public OpConverter { } }; -} // namespace tensorrt -} // namespace inference -} // namespace paddle +} // namespace paddle::inference::tensorrt REGISTER_TRT_OP_CONVERTER(dequantize_linear, DequantizeLinearOpConverter); diff --git a/paddle/fluid/inference/tensorrt/convert/fill_any_like_op.cc b/paddle/fluid/inference/tensorrt/convert/fill_any_like_op.cc index 2b3efea9bd7bd..1295746e37586 100644 --- a/paddle/fluid/inference/tensorrt/convert/fill_any_like_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/fill_any_like_op.cc @@ -14,9 +14,7 @@ limitations under the License. */ #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" -namespace paddle { -namespace inference { -namespace tensorrt { +namespace paddle::inference::tensorrt { class FillAnyLikeOpConverter : public OpConverter { public: @@ -81,8 +79,6 @@ class FillAnyLikeOpConverter : public OpConverter { } }; -} // namespace tensorrt -} // namespace inference -} // namespace paddle +} // namespace paddle::inference::tensorrt REGISTER_TRT_OP_CONVERTER(fill_any_like, FillAnyLikeOpConverter); diff --git a/paddle/fluid/inference/tensorrt/convert/logsigmoid_op.cc b/paddle/fluid/inference/tensorrt/convert/logsigmoid_op.cc index 8838bac48f9aa..8223da57582c0 100644 --- a/paddle/fluid/inference/tensorrt/convert/logsigmoid_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/logsigmoid_op.cc @@ -14,9 +14,7 @@ limitations under the License. */ #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" -namespace paddle { -namespace inference { -namespace tensorrt { +namespace paddle::inference::tensorrt { class LogSigmoidOpConverter : public OpConverter { public: @@ -58,8 +56,6 @@ class LogSigmoidOpConverter : public OpConverter { } }; -} // namespace tensorrt -} // namespace inference -} // namespace paddle +} // namespace paddle::inference::tensorrt REGISTER_TRT_OP_CONVERTER(logsigmoid, LogSigmoidOpConverter); diff --git a/paddle/fluid/inference/tensorrt/convert/one_hot_op.cc b/paddle/fluid/inference/tensorrt/convert/one_hot_op.cc index 2ec44e229e8b6..963357282f5bf 100644 --- a/paddle/fluid/inference/tensorrt/convert/one_hot_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/one_hot_op.cc @@ -14,19 +14,15 @@ limitations under the License. */ #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" -namespace paddle { -namespace framework { +namespace paddle::framework { class Scope; -namespace proto { +} // namespace paddle::framework +namespace paddle::framework::proto { class OpDesc; -} // namespace proto -} // namespace framework -} // namespace paddle +} // namespace paddle::framework::proto -namespace paddle { -namespace inference { -namespace tensorrt { +namespace paddle::inference::tensorrt { /* * OneHot Op @@ -86,9 +82,7 @@ class OneHotOpConverter : public OpConverter { } }; -} // namespace tensorrt -} // namespace inference -} // namespace paddle +} // namespace paddle::inference::tensorrt REGISTER_TRT_OP_CONVERTER(one_hot, OneHotOpConverter); REGISTER_TRT_OP_CONVERTER(one_hot_v2, OneHotOpConverter); diff --git a/paddle/fluid/memory/allocation/buffered_allocator.cc b/paddle/fluid/memory/allocation/buffered_allocator.cc index cbc79078397ea..ac4d8de524478 100644 --- a/paddle/fluid/memory/allocation/buffered_allocator.cc +++ b/paddle/fluid/memory/allocation/buffered_allocator.cc @@ -18,9 +18,7 @@ REGISTER_FILE_SYMBOLS(buffered_allocator); -namespace paddle { -namespace memory { -namespace allocation { +namespace paddle::memory::allocation { BufferedAllocator::BufferedAllocator(std::shared_ptr allocator) : underlying_allocator_(std::move(allocator)) { @@ -75,6 +73,4 @@ phi::Allocation *BufferedAllocator::AllocateImpl(size_t size) { } } -} // namespace allocation -} // namespace memory -} // namespace paddle +} // namespace paddle::memory::allocation diff --git a/paddle/fluid/memory/allocation/retry_allocator.cc b/paddle/fluid/memory/allocation/retry_allocator.cc index 2914da4f6361c..84760c5789511 100644 --- a/paddle/fluid/memory/allocation/retry_allocator.cc +++ b/paddle/fluid/memory/allocation/retry_allocator.cc @@ -16,9 +16,7 @@ #include "glog/logging.h" -namespace paddle { -namespace memory { -namespace allocation { +namespace paddle::memory::allocation { class WaitedAllocateSizeGuard { public: @@ -97,6 +95,4 @@ phi::Allocation* RetryAllocator::AllocateImpl(size_t size) { } } -} // namespace allocation -} // namespace memory -} // namespace paddle +} // namespace paddle::memory::allocation diff --git a/paddle/fluid/memory/allocation/thread_local_allocator.cc b/paddle/fluid/memory/allocation/thread_local_allocator.cc index 942193380566d..c4185090f2625 100644 --- a/paddle/fluid/memory/allocation/thread_local_allocator.cc +++ b/paddle/fluid/memory/allocation/thread_local_allocator.cc @@ -14,9 +14,7 @@ #include "paddle/fluid/memory/allocation/thread_local_allocator.h" -namespace paddle { -namespace memory { -namespace allocation { +namespace paddle::memory::allocation { ThreadLocalAllocatorImpl::ThreadLocalAllocatorImpl(const platform::Place& p) : place_(p) { @@ -77,6 +75,4 @@ uint64_t ThreadLocalAllocatorImpl::ReleaseImpl() { return buddy_allocator_->Release(); } -} // namespace allocation -} // namespace memory -} // namespace paddle +} // namespace paddle::memory::allocation diff --git a/paddle/fluid/memory/memcpy.cc b/paddle/fluid/memory/memcpy.cc index 6ba7b4ac1d613..d04bcb954ca1e 100644 --- a/paddle/fluid/memory/memcpy.cc +++ b/paddle/fluid/memory/memcpy.cc @@ -24,8 +24,7 @@ limitations under the License. */ #include "paddle/fluid/platform/device/xpu/xpu_header.h" #endif -namespace paddle { -namespace memory { +namespace paddle::memory { #ifdef PADDLE_WITH_CUSTOM_DEVICE template <> @@ -893,5 +892,4 @@ TEST_API void Copy(phi::Place dst_place, } #endif -} // namespace memory -} // namespace paddle +} // namespace paddle::memory diff --git a/paddle/fluid/operators/controlflow/while_op_helper.cc b/paddle/fluid/operators/controlflow/while_op_helper.cc index 57b5997f5efbe..00baef38632e3 100644 --- a/paddle/fluid/operators/controlflow/while_op_helper.cc +++ b/paddle/fluid/operators/controlflow/while_op_helper.cc @@ -18,14 +18,11 @@ #include "paddle/utils/string/string_helper.h" -namespace paddle { -namespace framework { +namespace paddle::framework { class BlockDesc; -} // namespace framework -} // namespace paddle +} // namespace paddle::framework -namespace paddle { -namespace operators { +namespace paddle::operators { // Set skip variables of while_op and while_grad_op // These variables should be skipped when eager deletion enables. @@ -284,5 +281,4 @@ void TransferVariablePlace(const framework::Scope *scope, << " place: " << new_t->place(); } -} // namespace operators -} // namespace paddle +} // namespace paddle::operators diff --git a/paddle/fluid/operators/fused/fused_gemm_epilogue_op.cc b/paddle/fluid/operators/fused/fused_gemm_epilogue_op.cc index d15f649af131e..62bc07e17fe4c 100644 --- a/paddle/fluid/operators/fused/fused_gemm_epilogue_op.cc +++ b/paddle/fluid/operators/fused/fused_gemm_epilogue_op.cc @@ -20,8 +20,7 @@ limitations under the License. */ #include "paddle/phi/infermeta/fusion.h" #include "paddle/phi/kernels/funcs/fused_gemm_epilogue.h" -namespace paddle { -namespace operators { +namespace paddle::operators { class FusedGemmEpilogueOp : public framework::OperatorWithKernel { public: @@ -177,8 +176,7 @@ class FusedGemmEpilogueOpGradMaker : public framework::SingleGradOpMaker { } }; -} // namespace operators -} // namespace paddle +} // namespace paddle::operators namespace ops = paddle::operators; DECLARE_INFER_SHAPE_FUNCTOR(fused_gemm_epilogue, diff --git a/paddle/fluid/operators/pscore/distributed_push_sparse_op.cc b/paddle/fluid/operators/pscore/distributed_push_sparse_op.cc index cc9e0aeff1f01..060763798577c 100644 --- a/paddle/fluid/operators/pscore/distributed_push_sparse_op.cc +++ b/paddle/fluid/operators/pscore/distributed_push_sparse_op.cc @@ -17,8 +17,7 @@ limitations under the License. */ #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/math_function.h" -namespace paddle { -namespace operators { +namespace paddle::operators { constexpr int64_t kNoPadding = -1; @@ -125,8 +124,7 @@ random value and set the value into the table for the next looking up. )DOC"); } }; -} // namespace operators -} // namespace paddle +} // namespace paddle::operators namespace ops = paddle::operators; diff --git a/paddle/fluid/operators/reader/create_py_reader_op.cc b/paddle/fluid/operators/reader/create_py_reader_op.cc index f81d89c1876b8..7025b1a614904 100644 --- a/paddle/fluid/operators/reader/create_py_reader_op.cc +++ b/paddle/fluid/operators/reader/create_py_reader_op.cc @@ -16,9 +16,7 @@ #include "paddle/fluid/operators/reader/py_reader.h" #include "paddle/fluid/operators/reader/reader_op_registry.h" -namespace paddle { -namespace operators { -namespace reader { +namespace paddle::operators::reader { class CreatePyReaderOp : public framework::OperatorBase { public: @@ -114,9 +112,7 @@ class CreatePyReaderOpMaker : public FileReaderMakerBase { } }; -} // namespace reader -} // namespace operators -} // namespace paddle +} // namespace paddle::operators::reader namespace reader = ::paddle::operators::reader; diff --git a/paddle/fluid/operators/reduce_ops/reduce_mean_op.cc b/paddle/fluid/operators/reduce_ops/reduce_mean_op.cc index ba4f188274d18..e7020f8028161 100644 --- a/paddle/fluid/operators/reduce_ops/reduce_mean_op.cc +++ b/paddle/fluid/operators/reduce_ops/reduce_mean_op.cc @@ -23,8 +23,7 @@ #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/infermeta/unary.h" -namespace paddle { -namespace operators { +namespace paddle::operators { // NOTE(dengkaipeng): Input(Out) is unnecessary in reduce_mean_grad // calcualtion, but will incur a reduce_mean_grad op after @@ -89,8 +88,7 @@ class ReduceMeanDoubleGradOpBaseMaker : public imperative::GradOpBaseMakerBase { } }; DECLARE_NO_NEED_BUFFER_VARS_INFERER(ReduceMeanGradNoNeedBufferVarInferer, "X"); -} // namespace operators -} // namespace paddle +} // namespace paddle::operators class __reduce_meanMaker__ : public ops::ReduceBaseOpMaker { protected: diff --git a/paddle/fluid/platform/collective_helper.cc b/paddle/fluid/platform/collective_helper.cc index bffdcc570934f..cda654a547cad 100644 --- a/paddle/fluid/platform/collective_helper.cc +++ b/paddle/fluid/platform/collective_helper.cc @@ -21,8 +21,7 @@ #include "paddle/fluid/platform/device/device_wrapper.h" #include "paddle/fluid/platform/device/gpu/gpu_resource_pool.h" -namespace paddle { -namespace platform { +namespace paddle::platform { #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) class NCCLCommImpl : public NCCLComm { public: @@ -636,5 +635,4 @@ void XCCLCommContext::ReleaseXCCLComms() { } #endif -} // namespace platform -} // namespace paddle +} // namespace paddle::platform diff --git a/paddle/fluid/platform/device/gpu/gpu_resource_pool.cc b/paddle/fluid/platform/device/gpu/gpu_resource_pool.cc index 9f2168e1cdb8b..b8cbde6e613d6 100644 --- a/paddle/fluid/platform/device/gpu/gpu_resource_pool.cc +++ b/paddle/fluid/platform/device/gpu/gpu_resource_pool.cc @@ -17,8 +17,7 @@ #include "paddle/fluid/platform/device/gpu/gpu_info.h" -namespace paddle { -namespace platform { +namespace paddle::platform { CudaStreamResourcePool::CudaStreamResourcePool() { int dev_cnt = platform::GetGPUDeviceCount(); @@ -123,7 +122,6 @@ std::shared_ptr CudaEventResourcePool::New(int dev_idx) { return pool_[dev_idx]->New(); } -} // namespace platform -} // namespace paddle +} // namespace paddle::platform #endif diff --git a/paddle/fluid/primitive/utils/static_utils.cc b/paddle/fluid/primitive/utils/static_utils.cc index 222e51d91796b..90ab8898a54aa 100644 --- a/paddle/fluid/primitive/utils/static_utils.cc +++ b/paddle/fluid/primitive/utils/static_utils.cc @@ -15,8 +15,7 @@ #include "paddle/fluid/primitive/type/lazy_tensor.h" #include "paddle/fluid/primitive/utils/utils.h" -namespace paddle { -namespace primitive { +namespace paddle::primitive { template <> void set_output(const paddle::Tensor& x_tmp, paddle::Tensor* x) { x->set_impl(x_tmp.impl()); @@ -72,5 +71,4 @@ std::vector> ConstructVjpResultByStopGradients( return vjp_results; } -} // namespace primitive -} // namespace paddle +} // namespace paddle::primitive diff --git a/paddle/fluid/pybind/communication.cc b/paddle/fluid/pybind/communication.cc index 5e202a2b79d2e..12e1182ab5e45 100644 --- a/paddle/fluid/pybind/communication.cc +++ b/paddle/fluid/pybind/communication.cc @@ -34,8 +34,7 @@ limitations under the License. */ namespace py = pybind11; -namespace paddle { -namespace pybind { +namespace paddle::pybind { void BindCommContextManager(py::module *m) { auto P2POption = py::class_(*m, "P2POption") @@ -142,5 +141,4 @@ void BindTCPStore(py::module *m) { &phi::distributed::CreateOrGetGlobalTCPStore); } -} // namespace pybind -} // namespace paddle +} // namespace paddle::pybind diff --git a/paddle/fluid/pybind/eager.cc b/paddle/fluid/pybind/eager.cc index 00b6ba994233f..b93a597d0fbaf 100644 --- a/paddle/fluid/pybind/eager.cc +++ b/paddle/fluid/pybind/eager.cc @@ -52,8 +52,7 @@ using phi::distributed::Placements; using phi::distributed::ProcessMesh; using phi::distributed::TensorDistAttr; -namespace paddle { -namespace pybind { +namespace paddle::pybind { namespace py = ::pybind11; @@ -1487,5 +1486,4 @@ void BindEagerStringTensor(pybind11::module* module) { } } -} // namespace pybind -} // namespace paddle +} // namespace paddle::pybind diff --git a/paddle/phi/backends/gpu/cuda/cuda_info.cc b/paddle/phi/backends/gpu/cuda/cuda_info.cc index 7fc021af1e94f..68b03d11d4f34 100644 --- a/paddle/phi/backends/gpu/cuda/cuda_info.cc +++ b/paddle/phi/backends/gpu/cuda/cuda_info.cc @@ -22,9 +22,7 @@ static std::once_flag g_device_props_size_init_flag; static std::vector> g_device_props_init_flags; static std::vector g_device_props; -namespace phi { -namespace backends { -namespace gpu { +namespace phi::backends::gpu { int DnnVersion() { if (!dynload::HasCUDNN()) return -1; @@ -341,6 +339,4 @@ bool IsGPUManagedMemoryOversubscriptionSupported(int dev_id) { #endif } -} // namespace gpu -} // namespace backends -} // namespace phi +} // namespace phi::backends::gpu diff --git a/paddle/phi/core/distributed/auto_parallel/device_mesh.cc b/paddle/phi/core/distributed/auto_parallel/device_mesh.cc index 32030b05b55fd..03e234bb713ac 100644 --- a/paddle/phi/core/distributed/auto_parallel/device_mesh.cc +++ b/paddle/phi/core/distributed/auto_parallel/device_mesh.cc @@ -18,9 +18,7 @@ limitations under the License. */ #include "paddle/phi/core/distributed/auto_parallel/device_mesh.h" #include "paddle/phi/core/distributed/auto_parallel/proto_helper.h" #include "paddle/phi/core/distributed/auto_parallel/utils.h" -namespace phi { -namespace distributed { -namespace auto_parallel { +namespace phi::distributed::auto_parallel { std::string DeviceCapability::to_string() const { std::string str; @@ -385,6 +383,4 @@ bool operator==(const DeviceMesh &lhs, const DeviceMesh &rhs) { return true; } -} // namespace auto_parallel -} // namespace distributed -} // namespace phi +} // namespace phi::distributed::auto_parallel diff --git a/paddle/phi/core/distributed/auto_parallel/placement_types.cc b/paddle/phi/core/distributed/auto_parallel/placement_types.cc index 86e9dcc2704e2..e32718ce0e0e3 100644 --- a/paddle/phi/core/distributed/auto_parallel/placement_types.cc +++ b/paddle/phi/core/distributed/auto_parallel/placement_types.cc @@ -14,8 +14,7 @@ #include "paddle/phi/core/distributed/auto_parallel/placement_types.h" -namespace phi { -namespace distributed { +namespace phi::distributed { int64_t DistTensorMeta::num_shard() const { int64_t num_shard = 1; @@ -57,5 +56,4 @@ bool DistTensorMeta::is_replicated() const { [](const auto& p) { return p->is_replicated(); }); } -} // namespace distributed -} // namespace phi +} // namespace phi::distributed diff --git a/paddle/phi/infermeta/spmd_rules/dim_trans.cc b/paddle/phi/infermeta/spmd_rules/dim_trans.cc index 71c84476f9f1e..3076b9f0f14d5 100644 --- a/paddle/phi/infermeta/spmd_rules/dim_trans.cc +++ b/paddle/phi/infermeta/spmd_rules/dim_trans.cc @@ -20,8 +20,7 @@ limitations under the License. */ #include "paddle/phi/core/distributed/auto_parallel/dist_meta_tensor.h" #include "paddle/phi/core/enforce.h" -namespace phi { -namespace distributed { +namespace phi::distributed { DimTrans::DimTrans(Type type) : type_(type) {} @@ -376,5 +375,4 @@ std::vector> InferFromDimTrans( return {new_input_dims_mapping, out_dims_mapping}; } -} // namespace distributed -} // namespace phi +} // namespace phi::distributed diff --git a/paddle/phi/infermeta/spmd_rules/layer_norm.cc b/paddle/phi/infermeta/spmd_rules/layer_norm.cc index d575b4b75d179..ce0fb033367a5 100644 --- a/paddle/phi/infermeta/spmd_rules/layer_norm.cc +++ b/paddle/phi/infermeta/spmd_rules/layer_norm.cc @@ -21,8 +21,7 @@ limitations under the License. */ #include "paddle/phi/core/distributed/auto_parallel/utils.h" #include "paddle/phi/infermeta/spmd_rules/utils.h" -namespace phi { -namespace distributed { +namespace phi::distributed { using phi::distributed::auto_parallel::str_join; @@ -465,5 +464,4 @@ SpmdInfo LayerNormGradInferSpmd(const DistMetaTensor& x, {x_grad_dist_attr, scale_grad_dist_attr, bias_grad_dist_attr}); } -} // namespace distributed -} // namespace phi +} // namespace phi::distributed diff --git a/paddle/phi/infermeta/spmd_rules/scale.cc b/paddle/phi/infermeta/spmd_rules/scale.cc index 040e7979ddcfa..a945d56d508fb 100644 --- a/paddle/phi/infermeta/spmd_rules/scale.cc +++ b/paddle/phi/infermeta/spmd_rules/scale.cc @@ -12,13 +12,11 @@ limitations under the License. */ #include "paddle/phi/infermeta/spmd_rules/scale.h" #include "paddle/phi/infermeta/spmd_rules/elementwise.h" -namespace phi { -namespace distributed { +namespace phi::distributed { SpmdInfo ScaleInferSpmd(const DistMetaTensor& x, const Scalar& scale, const Scalar& bias, bool bias_after_scale) { return ElementwiseUnaryInferSpmd(x); } -} // namespace distributed -} // namespace phi +} // namespace phi::distributed diff --git a/paddle/phi/kernels/selected_rows/scale_kernel.cc b/paddle/phi/kernels/selected_rows/scale_kernel.cc index 6eded1219b283..5a226f0d19852 100644 --- a/paddle/phi/kernels/selected_rows/scale_kernel.cc +++ b/paddle/phi/kernels/selected_rows/scale_kernel.cc @@ -19,8 +19,7 @@ limitations under the License. */ #include "paddle/phi/common/bfloat16.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/scale_kernel.h" -namespace phi { -namespace sr { +namespace phi::sr { template void ScaleKernel(const Context& dev_ctx, @@ -38,8 +37,7 @@ void ScaleKernel(const Context& dev_ctx, dev_ctx, x.value(), scale, bias, bias_after_scale, out->mutable_value()); } -} // namespace sr -} // namespace phi +} // namespace phi::sr PD_REGISTER_KERNEL(scale_sr, CPU, diff --git a/paddle/pir/src/core/op_operand_impl.cc b/paddle/pir/src/core/op_operand_impl.cc index 35827ad1efa17..6977e1278df56 100644 --- a/paddle/pir/src/core/op_operand_impl.cc +++ b/paddle/pir/src/core/op_operand_impl.cc @@ -16,8 +16,7 @@ #include "paddle/pir/include/core/operation.h" #include "paddle/pir/src/core/value_impl.h" -namespace pir { -namespace detail { +namespace pir::detail { pir::Operation *OpOperandImpl::owner() const { return owner_; } @@ -79,5 +78,4 @@ void OpOperandImpl::RemoveFromUdChain() { OpOperandImpl::~OpOperandImpl() { RemoveFromUdChain(); } -} // namespace detail -} // namespace pir +} // namespace pir::detail