Skip to content

Commit

Permalink
part 6
Browse files Browse the repository at this point in the history
  • Loading branch information
walkalone20 committed May 30, 2024
1 parent a338cea commit 7c1d49c
Show file tree
Hide file tree
Showing 50 changed files with 117 additions and 267 deletions.
6 changes: 2 additions & 4 deletions paddle/fluid/distributed/collective/reducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
PD_DECLARE_bool(use_stream_safe_cuda_allocator);
COMMON_DECLARE_string(allocator_strategy);

namespace paddle {
namespace distributed {
namespace paddle::distributed {

static bool IsStreamSafeAllocator() {
return (FLAGS_allocator_strategy == "auto_growth" &&
Expand Down Expand Up @@ -1367,5 +1366,4 @@ std::ostream &operator<<(std::ostream &out, const EagerGroup &group) {
return out;
}

} // namespace distributed
} // namespace paddle
} // namespace paddle::distributed
6 changes: 2 additions & 4 deletions paddle/fluid/distributed/fleet_executor/message_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
#include "paddle/fluid/distributed/fleet_executor/global.h"
#include "paddle/fluid/distributed/fleet_executor/message_bus.h"

namespace paddle {
namespace distributed {
namespace paddle::distributed {

void MessageServiceImpl::ReceiveInterceptorMessage(
google::protobuf::RpcController* control_base,
Expand All @@ -46,6 +45,5 @@ void MessageServiceImpl::IncreaseBarrierCount(
response->set_rst(true);
}

} // namespace distributed
} // namespace paddle
} // namespace paddle::distributed
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ limitations under the License. */
#define LEARNING_RATE_DECAY_COUNTER "@LR_DECAY_COUNTER@"
#define STEP_COUNTER "@PS_STEP_COUNTER@"

namespace paddle {
namespace distributed {
namespace paddle::distributed {

using phi::SelectedRows;

Expand Down Expand Up @@ -1590,5 +1589,4 @@ void FLCommunicator::StartCoordinator(
new std::thread(&FLCommunicator::SendThreadAsync, this));
}

} // namespace distributed
} // namespace paddle
} // namespace paddle::distributed
6 changes: 2 additions & 4 deletions paddle/fluid/framework/fleet/metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
#include "paddle/fluid/framework/lod_tensor.h"

#if defined(PADDLE_WITH_PSLIB) || defined(PADDLE_WITH_PSCORE)
namespace paddle {
namespace framework {
namespace paddle::framework {

std::shared_ptr<Metric> Metric::s_instance_ = nullptr;

Expand Down Expand Up @@ -393,6 +392,5 @@ BasicAucCalculator::WuaucRocData BasicAucCalculator::computeSingleUserAuc(
return {tp, fp, auc};
}

} // namespace framework
} // namespace paddle
} // namespace paddle::framework
#endif
8 changes: 2 additions & 6 deletions paddle/fluid/framework/ir/embedding_fc_lstm_fuse_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
#include "paddle/fluid/framework/op_version_registry.h"
#include "paddle/phi/kernels/funcs/blas/blas.h"

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

static int BuildFusion(Graph* graph,
const std::string& name_scope,
Expand Down Expand Up @@ -288,9 +286,7 @@ void EmbeddingFCLSTMFusePass::ApplyImpl(ir::Graph* graph) const {
AddStatis(fusion_count);
}

} // namespace ir
} // namespace framework
} // namespace paddle
} // namespace paddle::framework::ir

REGISTER_PASS(embedding_fc_lstm_fuse_pass,
paddle::framework::ir::EmbeddingFCLSTMFusePass);
Expand Down
22 changes: 9 additions & 13 deletions paddle/fluid/framework/ir/fused_continuous_same_ops_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,16 @@

namespace phi {
class DenseTensor;
} // namespace phi
} // namespace phi

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 {

namespace patterns {
} // namespace paddle::framework::ir
namespace paddle::framework::ir::patterns {

struct ContinuousSameOpsPattern : public PatternBase {
ContinuousSameOpsPattern(PDPattern* pattern,
Expand Down Expand Up @@ -85,7 +82,8 @@ ContinuousSameOpsPattern::ContinuousSameOpsPattern(
.LinksTo({second_out_var_node});
}

} // namespace patterns
} // namespace paddle::framework::ir::patterns
namespace paddle::framework::ir {

/*
Fused continuous same ops into one.
Expand Down Expand Up @@ -221,9 +219,7 @@ void FusedContinuousSameOpsPass::ApplyImpl(ir::Graph* graph) const {
LOG(INFO) << "Total delete op counts: " << total_delete_op_count;
}

} // namespace ir
} // namespace framework
} // namespace paddle
} // namespace paddle::framework::ir

REGISTER_PASS(fused_continuous_same_ops_pass,
paddle::framework::ir::FusedContinuousSameOpsPass);
Expand Down
8 changes: 2 additions & 6 deletions paddle/fluid/framework/ir/fused_feedforward_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/platform/enforce.h"

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

void FusedFeedForwardPass::ApplyImpl(ir::Graph *graph) const {
FusePassBase::Init(scope_name, graph);
Expand Down Expand Up @@ -752,9 +750,7 @@ ir::Graph *FusedFeedForwardPass::FusedFeedForwardBwd(
return graph;
}

} // namespace ir
} // namespace framework
} // namespace paddle
} // namespace paddle::framework::ir

REGISTER_PASS(fused_feedforward_pass,
paddle::framework::ir::FusedFeedForwardPass);
10 changes: 2 additions & 8 deletions paddle/fluid/framework/ir/fusion_group/code_generator_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ limitations under the License. */

#include "paddle/fluid/framework/ir/fusion_group/operation.h"

namespace paddle {
namespace framework {
namespace ir {
namespace fusion_group {
namespace paddle::framework::ir::fusion_group {

template <typename T>
static T StringTo(const std::string& str) {
Expand Down Expand Up @@ -219,7 +216,4 @@ std::string OperationExpression::GetExpression(
return ret.str();
}

} // namespace fusion_group
} // namespace ir
} // namespace framework
} // namespace paddle
} // namespace paddle::framework::ir::fusion_group
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
#include "paddle/fluid/framework/ir/memory_optimize_pass/reference_count_pass_helper.h"
#include "paddle/fluid/framework/ir/pass.h"

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

class Graph;

Expand Down Expand Up @@ -362,9 +360,7 @@ void ReferenceCountPass::ApplyImpl(ir::Graph *graph) const {
}
}

} // namespace ir
} // namespace framework
} // namespace paddle
} // namespace paddle::framework::ir

REGISTER_PASS(reference_count_pass, paddle::framework::ir::ReferenceCountPass)
.RequirePassAttr(paddle::framework::ir::kMemOptVarInfoMapList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ limitations under the License. */
#include "paddle/fluid/platform/onednn_helper.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 @@ -111,9 +109,7 @@ int CPUBfloat16PlacementPass::RemoveUnsupportedOperators(
return detected_operators;
}

} // namespace ir
} // namespace framework
} // namespace paddle
} // namespace paddle::framework::ir

REGISTER_PASS(cpu_bfloat16_placement_pass,
paddle::framework::ir::CPUBfloat16PlacementPass)
Expand Down
14 changes: 4 additions & 10 deletions paddle/fluid/framework/ir/onednn/fc_onednn_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@
#include "paddle/phi/core/enforce.h"
#include "paddle/utils/string/pretty_log.h"

namespace paddle {
namespace framework {
namespace paddle::framework {
class OpDesc;
} // namespace framework
} // namespace paddle
} // namespace paddle::framework

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

class Graph;

Expand Down Expand Up @@ -85,8 +81,6 @@ void FCMKLDNNPass::ApplyImpl(ir::Graph* graph) const {
}
}

} // namespace ir
} // namespace framework
} // namespace paddle
} // namespace paddle::framework::ir

REGISTER_PASS(fc_onednn_pass, paddle::framework::ir::FCMKLDNNPass);
20 changes: 6 additions & 14 deletions paddle/fluid/framework/ir/preln_layernorm_x_fuse_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,11 @@ limitations under the License. */
#include "paddle/fluid/framework/ir/graph_pattern_detector.h"
#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 {

struct PrelnLayerNormX : public PatternBase {
PrelnLayerNormX(PDPattern *pattern, const std::string &name_scope)
Expand Down Expand Up @@ -86,7 +79,8 @@ void PrelnLayerNormX::operator()(PDNode *x,
.LinksTo({layer_norm_out_var});
}

} // namespace patterns
} // namespace paddle::framework::ir::patterns
namespace paddle::framework::ir {

int PrelnLayerNormXFusePass::ApplyLayerNormShiftPattern(
ir::Graph *graph) const {
Expand Down Expand Up @@ -253,9 +247,7 @@ void PrelnLayerNormXFusePass::ApplyImpl(ir::Graph *graph) const {
AddStatis(found_subgraph_count);
}

} // namespace ir
} // namespace framework
} // namespace paddle
} // namespace paddle::framework::ir

REGISTER_PASS(preln_layernorm_x_fuse_pass,
paddle::framework::ir::PrelnLayerNormXFusePass);
Expand Down
16 changes: 4 additions & 12 deletions paddle/fluid/framework/ir/seqpool_concat_fuse_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,13 @@

#include <string>

namespace paddle {
namespace framework {
namespace ir {
namespace paddle::framework::ir {
class Node;
} // namespace ir
} // namespace framework
} // namespace paddle
} // namespace paddle::framework::ir

#define MAX_CONCAT_INPUTS 200

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

PDNode* BuildSeqPoolConcatPattern(PDPattern* pattern,
const std::string& name_scope,
Expand Down Expand Up @@ -217,9 +211,7 @@ void SeqPoolConcatFusePass::ApplyImpl(ir::Graph* graph) const {
AddStatis(fusion_count);
}

} // namespace ir
} // namespace framework
} // namespace paddle
} // namespace paddle::framework::ir

REGISTER_PASS(seqpool_concat_fuse_pass,
paddle::framework::ir::SeqPoolConcatFusePass);
8 changes: 2 additions & 6 deletions paddle/fluid/framework/ir/sync_batch_norm_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ limitations under the License. */
#include "glog/logging.h"
#include "paddle/fluid/framework/ir/pass.h"

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

class Graph;

Expand All @@ -43,8 +41,6 @@ class SyncBatchNormPass : public Pass {
}
}
};
} // namespace ir
} // namespace framework
} // namespace paddle
} // namespace paddle::framework::ir

REGISTER_PASS(sync_batch_norm_pass, paddle::framework::ir::SyncBatchNormPass);
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

#include "paddle/fluid/framework/new_executor/garbage_collector/fast_garbage_collector.h"

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

void InterpreterCoreFastGarbageCollector::Add(Variable* var,
const Instruction&) {
Expand Down Expand Up @@ -102,5 +101,4 @@ void InterpreterCoreFastGarbageCollector::Add(Garbage garbage) {
}
}

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

#include "glog/logging.h"

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

std::unique_ptr<OperatorBase> OpRegistry::CreateOp(
const std::string& type,
Expand Down Expand Up @@ -140,5 +139,4 @@ std::unique_ptr<OperatorBase> OpRegistry::CreateOp(const OpDesc& op_desc) {
return op;
}

} // namespace framework
} // namespace paddle
} // namespace paddle::framework
Loading

0 comments on commit 7c1d49c

Please sign in to comment.