Skip to content

Commit

Permalink
part 4
Browse files Browse the repository at this point in the history
  • Loading branch information
walkalone20 committed May 30, 2024
1 parent a338cea commit 6af06cd
Show file tree
Hide file tree
Showing 47 changed files with 108 additions and 258 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t>& shape,
const TensorDistAttr& dist_attr) {
Expand Down Expand Up @@ -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
6 changes: 2 additions & 4 deletions paddle/fluid/distributed/fleet_executor/fleet_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -290,5 +289,4 @@ void FleetExecutor::Run(const std::string& carrier_id) {
carrier->Start();
}

} // namespace distributed
} // namespace paddle
} // namespace paddle::distributed
6 changes: 2 additions & 4 deletions paddle/fluid/distributed/fleet_executor/task_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -186,5 +185,4 @@ void TaskNode::SetSendDownPerSteps(int64_t value) {
send_down_per_steps_ = value;
}

} // namespace distributed
} // namespace paddle
} // namespace paddle::distributed
6 changes: 2 additions & 4 deletions paddle/fluid/framework/attribute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -319,5 +318,4 @@ void CanonicalizeScalarAttrs(const proto::OpProto& op_proto,
}
}
}
} // namespace framework
} // namespace paddle
} // namespace paddle::framework
8 changes: 2 additions & 6 deletions paddle/fluid/framework/ir/attention_lstm_fuse_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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);
14 changes: 4 additions & 10 deletions paddle/fluid/framework/ir/fuse_pass_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -77,6 +73,4 @@ FuseOptions FusePassBase::FindFuseOption(const Node& node1,
#endif
}

} // namespace ir
} // namespace framework
} // namespace paddle
} // namespace paddle::framework::ir
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
8 changes: 2 additions & 6 deletions paddle/fluid/framework/ir/op_compat_sensible_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ std::unordered_set<std::string> 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 {
Expand Down Expand Up @@ -325,6 +323,4 @@ bool OpCompatSensiblePass::IsCompat(
return true;
}

} // namespace ir
} // namespace framework
} // namespace paddle
} // namespace paddle::framework::ir
12 changes: 4 additions & 8 deletions paddle/fluid/framework/ir/set_transformer_input_convert_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> lookup_table_ops{"lookup_table",
Expand Down Expand Up @@ -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<bool>("with_dynamic_shape");
Expand Down Expand Up @@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
#include "paddle/fluid/platform/onednn_helper.h"
#endif

namespace paddle {
namespace framework {
namespace paddle::framework {

WhileInstruction::WhileInstruction(
size_t id,
Expand Down Expand Up @@ -237,5 +236,4 @@ void WhileInstruction::Run() {
VLOG(6) << "while instruction run done";
}

} // namespace framework
} // namespace paddle
} // namespace paddle::framework
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -186,5 +185,4 @@ void PhiKernelInstruction::Run() {
VLOG(6) << "End run op " << phi_op_name_ << " kernel.";
}

} // namespace framework
} // namespace paddle
} // namespace paddle::framework
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ std::set<std::string> 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;

Expand Down Expand Up @@ -991,6 +989,4 @@ void FakeInitializeOutputsForStructureKernel(
}
}

} // namespace interpreter
} // namespace framework
} // namespace paddle
} // namespace paddle::framework::interpreter
6 changes: 2 additions & 4 deletions paddle/fluid/framework/trainer_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ limitations under the License. */

#include "glog/logging.h"

namespace paddle {
namespace framework {
namespace paddle::framework {

class TrainerBase;

Expand Down Expand Up @@ -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
6 changes: 2 additions & 4 deletions paddle/fluid/framework/var_desc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_),
Expand Down Expand Up @@ -459,5 +458,4 @@ bool operator==(const VarDesc &left, const VarDesc &right) {
right.Proto()->SerializeAsString();
}

} // namespace framework
} // namespace paddle
} // namespace paddle::framework
6 changes: 2 additions & 4 deletions paddle/fluid/imperative/tracer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -650,5 +649,4 @@ phi::KernelSignature Tracer::GetExpectedKernelSignature(
}
}

} // namespace imperative
} // namespace paddle
} // namespace paddle::imperative
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -47,6 +45,4 @@ std::string InferenceOpReplacePass::repr() const {
return "inference_op_replace_pass";
}

} // namespace analysis
} // namespace inference
} // namespace paddle
} // namespace paddle::inference::analysis
8 changes: 2 additions & 6 deletions paddle/fluid/inference/tensorrt/convert/arg_max_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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);
Loading

0 comments on commit 6af06cd

Please sign in to comment.