forked from mindspore-Ecosystem/mindspore
!31354 Codecheck clearing for r1.7 parallel module.
Merge pull request !31354 from liuluobin/clear_waring
This commit is contained in:
commit
3f201d766f
|
@ -167,7 +167,7 @@ void AllreduceGraph::PrintArnodeSet() const {
|
|||
void AllreduceGraph::SortArnode() {
|
||||
arnode_vec_.clear();
|
||||
for (auto &node : arnode_set_) {
|
||||
arnode_vec_.emplace_back(*node);
|
||||
(void)arnode_vec_.emplace_back(*node);
|
||||
}
|
||||
std::sort(arnode_vec_.begin(), arnode_vec_.end(), std::greater<>());
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ Status AllreduceNode::AddNext(const AllreduceNodePtr &next_node) {
|
|||
MS_LOG(ERROR) << "next_node is nullptr!";
|
||||
return FAILED;
|
||||
}
|
||||
next_.emplace_back(next_node);
|
||||
(void)next_.emplace_back(next_node);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ Status AllreduceNode::AddPrev(const AllreduceNodePtr &prev_node, double dist, do
|
|||
MS_LOG(ERROR) << "dist must be positive! dist: " << dist;
|
||||
return FAILED;
|
||||
}
|
||||
prev_.emplace_back(prev_node);
|
||||
(void)prev_.emplace_back(prev_node);
|
||||
double add_dist = prev_node->depend_feat_size() + dist;
|
||||
depend_feat_size_ += add_dist;
|
||||
if (depend_feat_size_ > *max) {
|
||||
|
|
|
@ -50,7 +50,7 @@ void SimplifyForDecreasingCommunicationForward(CostPtrList *clist_ptrs) {
|
|||
for (size_t i = 0; i < clist_ptrs->size(); ++i) {
|
||||
if ((ret.size() == size_t(0)) ||
|
||||
(clist_ptrs->at(id[i])->communication_forward_ < ret.back()->communication_forward_)) {
|
||||
ret.emplace_back(std::move(clist_ptrs->at(id[i])));
|
||||
(void)ret.emplace_back(std::move(clist_ptrs->at(id[i])));
|
||||
}
|
||||
}
|
||||
*clist_ptrs = std::move(ret);
|
||||
|
@ -73,7 +73,7 @@ void SimplifyForDecreasingCommunicationWithPartialPara(CostPtrList *clist_ptrs)
|
|||
for (size_t i = 0; i < clist_ptrs->size(); ++i) {
|
||||
if ((ret.size() == size_t(0)) ||
|
||||
(clist_ptrs->at(id[i])->communication_with_partial_para_ < ret.back()->communication_with_partial_para_)) {
|
||||
ret.emplace_back(std::move(clist_ptrs->at(id[i])));
|
||||
(void)ret.emplace_back(std::move(clist_ptrs->at(id[i])));
|
||||
}
|
||||
}
|
||||
*clist_ptrs = std::move(ret);
|
||||
|
|
|
@ -125,6 +125,7 @@ struct OpEliminationDecision : public Decision {
|
|||
right_cost_(std::move(r_cost)) {
|
||||
type_ = DecisionType::OP_ELIMINATION;
|
||||
}
|
||||
~OpEliminationDecision() override = default;
|
||||
|
||||
StrategyPtr op_strategy_;
|
||||
CostPtr left_cost_;
|
||||
|
@ -144,6 +145,7 @@ struct EdgeEliminationDecision : public Decision {
|
|||
explicit EdgeEliminationDecision(CostPtrList cost_list) : edges_cost_list_(std::move(cost_list)) {
|
||||
type_ = DecisionType::EDGE_ELIMINATION;
|
||||
}
|
||||
~EdgeEliminationDecision() override = default;
|
||||
|
||||
CostPtrList edges_cost_list_;
|
||||
MS_DECLARE_PARENT(EdgeEliminationDecision, Decision);
|
||||
|
@ -167,6 +169,7 @@ struct MergeEliminationDecision : public Decision {
|
|||
target_op_cost_(std::move(target_op_c)) {
|
||||
type_ = DecisionType::MERGE_ELIMINATION;
|
||||
}
|
||||
~MergeEliminationDecision() override = default;
|
||||
|
||||
StrategyPtr merged_op_strategy_;
|
||||
CostPtr merged_op_cost_;
|
||||
|
@ -194,6 +197,7 @@ struct ContractEliminationDecision : public Decision {
|
|||
target_cost_(std::move(tar_cost)) {
|
||||
type_ = DecisionType::CONTRACT_ELIMINATION;
|
||||
}
|
||||
~ContractEliminationDecision() override = default;
|
||||
|
||||
StrategyPtr contracted_op_strategy_;
|
||||
CostPtr contracted_op_cost_;
|
||||
|
@ -228,6 +232,8 @@ struct SourceEliminationDecision : public Decision {
|
|||
op2_cost_(std::move(op2_c)) {
|
||||
type_ = DecisionType::SOURCE_ELIMINATION;
|
||||
}
|
||||
~SourceEliminationDecision() override = default;
|
||||
|
||||
StrategyPtr op1_strategy_;
|
||||
CostPtr op1_cost_;
|
||||
StrategyPtr op2_strategy_;
|
||||
|
@ -258,6 +264,7 @@ struct TriangleEliminationDecision : public Decision {
|
|||
right_node_cost_(std::move(r_node_cost)) {
|
||||
type_ = DecisionType::TRIANGLE_ELIMINATION;
|
||||
}
|
||||
~TriangleEliminationDecision() override = default;
|
||||
|
||||
StrategyPtr eliminated_op_strategy_;
|
||||
CostPtr eliminated_op_cost_;
|
||||
|
@ -288,6 +295,7 @@ struct StarEliminationDecision : public Decision {
|
|||
succ_ops_cost_list_(std::move(succ_ops_clist)) {
|
||||
type_ = DecisionType::STAR_ELIMINATION;
|
||||
}
|
||||
~StarEliminationDecision() override = default;
|
||||
|
||||
StrategyPtr eliminated_op_strategy_;
|
||||
CostPtr eliminated_op_cost_;
|
||||
|
@ -308,6 +316,7 @@ struct FinalDecision : public Decision {
|
|||
right_cost_(std::move(r_cost)) {
|
||||
type_ = DecisionType::FINAL_TYPE;
|
||||
}
|
||||
~FinalDecision() override = default;
|
||||
|
||||
StrategyPtr u_strategy_;
|
||||
StrategyPtr v_strategy_;
|
||||
|
@ -323,6 +332,7 @@ struct FinalSingleDecision : public Decision {
|
|||
FinalSingleDecision(StrategyPtr u_stra, CostPtr u_cost) : u_strategy_(std::move(u_stra)), u_cost_(std::move(u_cost)) {
|
||||
type_ = DecisionType::FINAL_SINGLE;
|
||||
}
|
||||
~FinalSingleDecision() override = default;
|
||||
|
||||
StrategyPtr u_strategy_;
|
||||
CostPtr u_cost_;
|
||||
|
|
|
@ -44,6 +44,7 @@ namespace parallel {
|
|||
struct Elimination : public Base {
|
||||
enum EliminationType { OPERA, EDGE, MERGE, CONTRACT, SOURCE, TRIANGLE, STAR };
|
||||
Elimination(EdgePtr n_edge, EliminationType ty) : new_edge_(std::move(n_edge)), type_(ty) {}
|
||||
~Elimination() override = default;
|
||||
|
||||
EdgePtr new_edge_;
|
||||
EliminationType type_;
|
||||
|
@ -56,6 +57,7 @@ struct OpElimination : public Elimination {
|
|||
left_edge_(std::move(l_edge)),
|
||||
op_(std::move(op_info)),
|
||||
right_edge_(std::move(r_edge)) {}
|
||||
~OpElimination() override = default;
|
||||
|
||||
EdgePtr left_edge_;
|
||||
OperatorInfoPtr op_;
|
||||
|
@ -67,6 +69,7 @@ struct OpElimination : public Elimination {
|
|||
struct EdgeElimination : public Elimination {
|
||||
EdgeElimination(const EdgePtr &n_edge, std::vector<EdgePtr> eds)
|
||||
: Elimination(n_edge, Elimination::EliminationType::EDGE), edges_(std::move(eds)) {}
|
||||
~EdgeElimination() override = default;
|
||||
|
||||
std::vector<EdgePtr> edges_;
|
||||
MS_DECLARE_PARENT(EdgeElimination, Elimination);
|
||||
|
@ -79,6 +82,7 @@ struct MergeElimination : public Elimination {
|
|||
merged_node_(std::move(u_info)),
|
||||
dir_edge_(std::move(merged_target_edge)),
|
||||
target_node_(std::move(v_info)) {}
|
||||
~MergeElimination() override = default;
|
||||
|
||||
OperatorInfoPtr merged_node_;
|
||||
EdgePtr dir_edge_;
|
||||
|
@ -93,6 +97,7 @@ struct ContractElimination : public Elimination {
|
|||
contracted_node_(std::move(con_info)),
|
||||
dir_edge_(std::move(tar_con_edge)),
|
||||
target_node_(std::move(tar_info)) {}
|
||||
~ContractElimination() override = default;
|
||||
|
||||
OperatorInfoPtr contracted_node_;
|
||||
EdgePtr dir_edge_;
|
||||
|
@ -111,6 +116,8 @@ struct SourceElimination : public Elimination {
|
|||
secondary_source_(std::move(s_source)),
|
||||
secondary_succ_edges_(std::move(s_succ_edges)),
|
||||
secondary_new_succ_edges_(std::move(s_new_succ_edges)) {}
|
||||
~SourceElimination() override = default;
|
||||
|
||||
OperatorInfoPtr primary_source_;
|
||||
std::vector<EdgePtr> primary_succ_edges_;
|
||||
std::vector<EdgePtr> primary_new_succ_edges_;
|
||||
|
@ -130,6 +137,7 @@ struct TriangleElimination : public Elimination {
|
|||
left_node_(std::move(l_node)),
|
||||
right_edge_(std::move(r_edge)),
|
||||
right_node_(std::move(r_node)) {}
|
||||
~TriangleElimination() override = default;
|
||||
|
||||
OperatorInfoPtr eliminated_node_;
|
||||
EdgePtr left_edge_;
|
||||
|
@ -146,6 +154,7 @@ struct StarElimination : public Elimination {
|
|||
eliminated_node_(std::move(elimi_node)),
|
||||
succ_edges_(std::move(s_edges)),
|
||||
succ_ops_(std::move(s_ops)) {}
|
||||
~StarElimination() override = default;
|
||||
|
||||
OperatorInfoPtr eliminated_node_;
|
||||
std::vector<EdgePtr> succ_edges_;
|
||||
|
|
|
@ -35,11 +35,11 @@ Status Edge::InitEdgeCost() {
|
|||
|
||||
for (auto &swc : prev_op_->GetStrategyCost()) {
|
||||
MS_EXCEPTION_IF_NULL(swc);
|
||||
pre_op_output_.emplace_back(std::make_pair(swc->strategy_ptr, swc->outputs_ptr));
|
||||
(void)pre_op_output_.emplace_back(std::make_pair(swc->strategy_ptr, swc->outputs_ptr));
|
||||
}
|
||||
for (auto &swc : next_op_->GetStrategyCost()) {
|
||||
MS_EXCEPTION_IF_NULL(swc);
|
||||
next_op_input_.emplace_back(std::make_pair(swc->strategy_ptr, swc->inputs_ptr));
|
||||
(void)next_op_input_.emplace_back(std::make_pair(swc->strategy_ptr, swc->inputs_ptr));
|
||||
}
|
||||
if (is_identity_edge) {
|
||||
for (auto &target_output : pre_op_output_) {
|
||||
|
@ -256,7 +256,7 @@ void Edge::CreateOpEliminationSubCostList(StrategyPtr op_strategy, const CostPtr
|
|||
communication_without_para + gamma * (communication - communication_without_para);
|
||||
cost->memory_with_reuse_ = memory_cost;
|
||||
cost->communication_forward_ = communication_forward;
|
||||
ret_cost_list->emplace_back(std::move(cost));
|
||||
(void)ret_cost_list->emplace_back(std::move(cost));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -565,15 +565,15 @@ bool Edge::CheckStrategyConsistency(StrategyPtr prev_stra, StrategyPtr next_stra
|
|||
return true;
|
||||
}
|
||||
|
||||
void Edge::SetCostMapAndInputOutput(std::map<CostPtrKey, CostPtrList> &cost_map) {
|
||||
void Edge::SetCostMapAndInputOutput(const std::map<CostPtrKey, CostPtrList> &cost_map) {
|
||||
cost_map_ = cost_map;
|
||||
pre_op_output_.clear();
|
||||
next_op_input_.clear();
|
||||
|
||||
for (auto &key_value : cost_map_) {
|
||||
auto &key_pair = key_value.first;
|
||||
pre_op_output_.emplace_back(std::pair<StrategyPtr, std::vector<TensorInfo>>(key_pair.first, {}));
|
||||
next_op_input_.emplace_back(std::pair<StrategyPtr, std::vector<TensorInfo>>(key_pair.second, {}));
|
||||
(void)pre_op_output_.emplace_back(std::pair<StrategyPtr, std::vector<TensorInfo>>(key_pair.first, {}));
|
||||
(void)next_op_input_.emplace_back(std::pair<StrategyPtr, std::vector<TensorInfo>>(key_pair.second, {}));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ class Edge {
|
|||
StrategyPtr GetNextOpStrategyByReshapeSWCIndex(int64_t swc_index);
|
||||
bool CheckStrategyConsistency(StrategyPtr, StrategyPtr);
|
||||
|
||||
void SetCostMapAndInputOutput(std::map<CostPtrKey, CostPtrList> &);
|
||||
void SetCostMapAndInputOutput(const std::map<CostPtrKey, CostPtrList> &);
|
||||
// For two operators u--->v, given the output tensor layout of u,
|
||||
// and the input tensor layout of v, return the redistribution cost,
|
||||
// and the op_list to carry out the redistribution.
|
||||
|
@ -185,7 +185,7 @@ class Edge {
|
|||
int64_t is_output_critical_ = 0;
|
||||
|
||||
// Returns whether two double variable are equal.
|
||||
bool IsDoubleEqual(double x, double y) { return std::abs(x - y) < EPS; }
|
||||
bool IsDoubleEqual(double x, double y) const { return std::abs(x - y) < EPS; }
|
||||
};
|
||||
} // namespace parallel
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -57,8 +57,8 @@ class CostGraph {
|
|||
std::map<OperatorInfoPtr, bool> *);
|
||||
// the edge is in the form: u --> v
|
||||
void AddEdge(OperatorInfoPtr u_node, OperatorInfoPtr v_node, const EdgePtr &edge);
|
||||
std::vector<std::shared_ptr<Edge>> GetOriginalPrevEdges(OperatorInfoPtr v_node) { return in_edges_[v_node]; }
|
||||
std::vector<std::shared_ptr<Edge>> GetOriginalNextEdges(OperatorInfoPtr u_node) { return out_edges_[u_node]; }
|
||||
std::vector<std::shared_ptr<Edge>> GetOriginalPrevEdges(const OperatorInfoPtr &v_node) { return in_edges_[v_node]; }
|
||||
std::vector<std::shared_ptr<Edge>> GetOriginalNextEdges(const OperatorInfoPtr &u_node) { return out_edges_[u_node]; }
|
||||
// An edge is uniquely identified by its name, and its output index and input index.
|
||||
bool IsEdgeInCostGraph(const std::string &, size_t, size_t);
|
||||
|
||||
|
|
|
@ -1802,7 +1802,7 @@ void MatmulDDSCost::CalculateInputsInMemory(const std::map<size_t, bool> &) {
|
|||
}
|
||||
|
||||
double CropAndResizeCost::GetForwardCommCost(const std::vector<TensorInfo> &inputs,
|
||||
const std::vector<TensorInfo> &outputs, int64_t stage_id) const {
|
||||
const std::vector<TensorInfo> &outputs, int64_t) const {
|
||||
double result = 0.0;
|
||||
if (outputs_type_lengths_.size() != outputs.size()) {
|
||||
MS_LOG(EXCEPTION) << "Invalid inputs type size " << inputs_type_lengths_.size() << " for CropAndResize cost.";
|
||||
|
@ -1821,8 +1821,8 @@ double CropAndResizeCost::GetForwardCommCost(const std::vector<TensorInfo> &inpu
|
|||
return result;
|
||||
}
|
||||
|
||||
double CropAndResizeCost::GetBackwardCommCost(const std::vector<TensorInfo> &inputs,
|
||||
const std::vector<TensorInfo> &outputs, int64_t stage_id) const {
|
||||
double CropAndResizeCost::GetBackwardCommCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &,
|
||||
int64_t stage_id) const {
|
||||
double result = 0.0;
|
||||
CheckGlobalDeviceManager();
|
||||
MS_EXCEPTION_IF_NULL(g_device_manager);
|
||||
|
@ -1847,7 +1847,7 @@ double CropAndResizeCost::GetBackwardCommCost(const std::vector<TensorInfo> &inp
|
|||
}
|
||||
|
||||
double CropAndResizeCost::GetForwardComputationCost(const std::vector<TensorInfo> &inputs,
|
||||
const std::vector<TensorInfo> &outputs, int64_t stage_id) const {
|
||||
const std::vector<TensorInfo> &, int64_t) const {
|
||||
if (inputs_type_lengths_.size() != inputs.size()) {
|
||||
MS_LOG(EXCEPTION) << "Invalid inputs type size " << inputs_type_lengths_.size() << " for CropAndResize cost.";
|
||||
}
|
||||
|
@ -1872,8 +1872,8 @@ double CropAndResizeCost::GetForwardComputationCost(const std::vector<TensorInfo
|
|||
return result;
|
||||
}
|
||||
|
||||
double CropAndResizeCost::GetBackwardComputationCost(const std::vector<TensorInfo> &inputs,
|
||||
const std::vector<TensorInfo> &outputs, int64_t stage_id) const {
|
||||
double CropAndResizeCost::GetBackwardComputationCost(const std::vector<TensorInfo> &,
|
||||
const std::vector<TensorInfo> &outputs, int64_t) const {
|
||||
Shape output0_slice_shape = outputs[0].slice_shape();
|
||||
double result = 0.0;
|
||||
// don't split batch
|
||||
|
@ -1910,7 +1910,7 @@ void CropAndResizeCost::CalculateInputsInMemory(const std::map<size_t, bool> &pr
|
|||
}
|
||||
|
||||
double ROIAlignCost::GetForwardCommCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
int64_t stage_id) const {
|
||||
int64_t) const {
|
||||
double result = 0.0;
|
||||
if (outputs_type_lengths_.size() != outputs.size()) {
|
||||
MS_LOG(EXCEPTION) << "Invalid inputs type size " << inputs_type_lengths_.size() << " for CropAndResize cost.";
|
||||
|
@ -1929,8 +1929,8 @@ double ROIAlignCost::GetForwardCommCost(const std::vector<TensorInfo> &inputs, c
|
|||
return result;
|
||||
}
|
||||
|
||||
double ROIAlignCost::GetForwardComputationCost(const std::vector<TensorInfo> &inputs,
|
||||
const std::vector<TensorInfo> &outputs, int64_t stage_id) const {
|
||||
double ROIAlignCost::GetForwardComputationCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &,
|
||||
int64_t) const {
|
||||
if (inputs_type_lengths_.size() != inputs.size()) {
|
||||
MS_LOG(EXCEPTION) << "Invalid inputs type size " << inputs_type_lengths_.size() << " for CropAndResize cost.";
|
||||
}
|
||||
|
@ -1951,8 +1951,8 @@ double ROIAlignCost::GetForwardComputationCost(const std::vector<TensorInfo> &in
|
|||
return result;
|
||||
}
|
||||
|
||||
double ROIAlignCost::GetBackwardComputationCost(const std::vector<TensorInfo> &inputs,
|
||||
const std::vector<TensorInfo> &outputs, int64_t stage_id) const {
|
||||
double ROIAlignCost::GetBackwardComputationCost(const std::vector<TensorInfo> &, const std::vector<TensorInfo> &outputs,
|
||||
int64_t) const {
|
||||
Shape output0_slice_shape = outputs[0].slice_shape();
|
||||
double result = 0.0;
|
||||
// don't split batch
|
||||
|
|
|
@ -114,7 +114,6 @@ class OperatorCost {
|
|||
// in the inference phase.
|
||||
int64_t is_outputs_critical_ = -1;
|
||||
};
|
||||
using OperatorCostPtr = std::shared_ptr<OperatorCost>;
|
||||
|
||||
class MatMulCost : public OperatorCost {
|
||||
public:
|
||||
|
@ -1040,13 +1039,11 @@ class UniformCandidateSamplerCost : public OperatorCost {
|
|||
int64_t stage_id) const override {
|
||||
return GetForwardCommCost(inputs, outputs, stage_id) + GetBackwardCommCost(inputs, outputs, stage_id);
|
||||
}
|
||||
double GetForwardCommCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
int64_t stage_id) const override {
|
||||
return 0;
|
||||
double GetForwardCommCost(const std::vector<TensorInfo> &, const std::vector<TensorInfo> &, int64_t) const override {
|
||||
return 0.0;
|
||||
}
|
||||
double GetBackwardCommCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
int64_t stage_id) const override {
|
||||
return 0;
|
||||
double GetBackwardCommCost(const std::vector<TensorInfo> &, const std::vector<TensorInfo> &, int64_t) const override {
|
||||
return 0.0;
|
||||
}
|
||||
double GetComputationCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
int64_t stage_id) const override {
|
||||
|
@ -1054,7 +1051,7 @@ class UniformCandidateSamplerCost : public OperatorCost {
|
|||
}
|
||||
double GetForwardComputationCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
int64_t stage_id) const override;
|
||||
double GetBackwardComputationCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
double GetBackwardComputationCost(const std::vector<TensorInfo> &, const std::vector<TensorInfo> &,
|
||||
int64_t) const override {
|
||||
return 0.0;
|
||||
}
|
||||
|
@ -1130,12 +1127,10 @@ class MatmulDDSCost : public OperatorCost {
|
|||
int64_t stage_id) const override {
|
||||
return GetForwardCommCost(inputs, outputs, stage_id) + GetBackwardCommCost(inputs, outputs, stage_id);
|
||||
}
|
||||
double GetForwardCommCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
int64_t stage_id) const override {
|
||||
double GetForwardCommCost(const std::vector<TensorInfo> &, const std::vector<TensorInfo> &, int64_t) const override {
|
||||
return 0.0;
|
||||
};
|
||||
double GetBackwardCommCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
int64_t stage_id) const override {
|
||||
double GetBackwardCommCost(const std::vector<TensorInfo> &, const std::vector<TensorInfo> &, int64_t) const override {
|
||||
return 0.0;
|
||||
};
|
||||
|
||||
|
@ -1146,8 +1141,8 @@ class MatmulDDSCost : public OperatorCost {
|
|||
}
|
||||
double GetForwardComputationCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
int64_t stage_id) const override;
|
||||
double GetBackwardComputationCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
int64_t stage_id) const override {
|
||||
double GetBackwardComputationCost(const std::vector<TensorInfo> &, const std::vector<TensorInfo> &,
|
||||
int64_t) const override {
|
||||
return 0.0;
|
||||
};
|
||||
// Not taking account of output
|
||||
|
@ -1167,17 +1162,17 @@ class CropAndResizeCost : public OperatorCost {
|
|||
return GetForwardCommCost(inputs, outputs, stage_id) + GetBackwardCommCost(inputs, outputs, stage_id);
|
||||
}
|
||||
double GetForwardCommCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
int64_t stage_id) const override;
|
||||
int64_t) const override;
|
||||
double GetBackwardCommCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
int64_t stage_id) const override;
|
||||
double GetComputationCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
int64_t stage_id) const override {
|
||||
return GetForwardComputationCost(inputs, outputs, stage_id) + GetBackwardComputationCost(inputs, outputs, stage_id);
|
||||
}
|
||||
double GetForwardComputationCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
int64_t stage_id) const override;
|
||||
double GetBackwardComputationCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
int64_t stage_id) const override;
|
||||
double GetForwardComputationCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &,
|
||||
int64_t) const override;
|
||||
double GetBackwardComputationCost(const std::vector<TensorInfo> &, const std::vector<TensorInfo> &,
|
||||
int64_t) const override;
|
||||
// Taking account for input
|
||||
void CalculateInputsInMemory(const std::map<size_t, bool> &prev_output_in_mem) override;
|
||||
// Not taking account of output
|
||||
|
@ -1203,17 +1198,17 @@ class ROIAlignCost : public CropAndResizeCost {
|
|||
~ROIAlignCost() override = default;
|
||||
|
||||
double GetForwardCommCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
int64_t stage_id) const override;
|
||||
double GetForwardComputationCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
int64_t stage_id) const override;
|
||||
double GetBackwardComputationCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &outputs,
|
||||
int64_t stage_id) const override;
|
||||
int64_t) const override;
|
||||
double GetForwardComputationCost(const std::vector<TensorInfo> &inputs, const std::vector<TensorInfo> &,
|
||||
int64_t) const override;
|
||||
double GetBackwardComputationCost(const std::vector<TensorInfo> &, const std::vector<TensorInfo> &outputs,
|
||||
int64_t) const override;
|
||||
// Taking account for input
|
||||
void CalculateInputsInMemory(const std::map<size_t, bool> &prev_output_in_mem) override;
|
||||
// Taking account of output
|
||||
void CalculateOutputInMemory() override;
|
||||
|
||||
void set_pooled_shape(Shape pooled_shape) { pooled_shape_ = pooled_shape; }
|
||||
void set_pooled_shape(const Shape &pooled_shape) { pooled_shape_ = pooled_shape; }
|
||||
|
||||
protected:
|
||||
Shape pooled_shape_;
|
||||
|
|
|
@ -140,30 +140,26 @@ StrategyRec CostMatMul::GetOptimalStr(const Graph::NodeType &node,
|
|||
static_cast<int64_t>(node.apply.arguments[0].tensor_shape.shape_w * node.apply.arguments[0].tensor_str.str_w);
|
||||
|
||||
std::vector<double> cost_op;
|
||||
std::vector<std::vector<float>> mode;
|
||||
|
||||
if (edge_i < 2 || edge_i % 2 != 0) {
|
||||
cost_op.push_back(DOUBLE_MAX);
|
||||
} else {
|
||||
cost_op.push_back(StrConcatDimI(edge_j, edge_k) + CostRedis(node, node_name_to_strategy,
|
||||
mode = {{1, 1, 0.5, 1}, {1, 1, 1, 1}, {1, 1, 0.5, 1}},
|
||||
graph));
|
||||
std::vector<std::vector<float>> mode = {{1, 1, 0.5, 1}, {1, 1, 1, 1}, {1, 1, 0.5, 1}};
|
||||
cost_op.push_back(StrConcatDimI(edge_j, edge_k) + CostRedis(node, node_name_to_strategy, mode, graph));
|
||||
}
|
||||
|
||||
if (edge_j < 2 || edge_j % 2 != 0) {
|
||||
cost_op.push_back(DOUBLE_MAX);
|
||||
} else {
|
||||
cost_op.push_back(StrConcatDimJ(edge_i, edge_k) + CostRedis(node, node_name_to_strategy,
|
||||
mode = {{1, 1, 1, 1}, {1, 1, 1, 0.5}, {1, 1, 1, 0.5}},
|
||||
graph));
|
||||
std::vector<std::vector<float>> mode = {{1, 1, 1, 1}, {1, 1, 1, 0.5}, {1, 1, 1, 0.5}};
|
||||
cost_op.push_back(StrConcatDimJ(edge_i, edge_k) + CostRedis(node, node_name_to_strategy, mode, graph));
|
||||
}
|
||||
|
||||
if (edge_k < 2 || edge_k % 2 != 0) {
|
||||
cost_op.push_back(DOUBLE_MAX);
|
||||
} else {
|
||||
cost_op.push_back(StrReduceDimK(edge_i, edge_j) + CostRedis(node, node_name_to_strategy,
|
||||
mode = {{1, 1, 1, 0.5}, {1, 1, 0.5, 1}, {1, 1, 1, 1}},
|
||||
graph));
|
||||
std::vector<std::vector<float>> mode = {{1, 1, 1, 0.5}, {1, 1, 0.5, 1}, {1, 1, 1, 1}};
|
||||
cost_op.push_back(StrReduceDimK(edge_i, edge_j) + CostRedis(node, node_name_to_strategy, mode, graph));
|
||||
}
|
||||
|
||||
return ChoseStr(cost_op, node.apply.str);
|
||||
|
@ -260,13 +256,12 @@ StrategyRec CostConvolution::GetOptimalStr(
|
|||
|
||||
std::vector<double> cost_op;
|
||||
cost_op.reserve(7);
|
||||
std::vector<std::vector<float>> mode;
|
||||
|
||||
if (input_tensor_n < 2 || input_tensor_n % 2 != 0) {
|
||||
cost_op.push_back(DOUBLE_MAX);
|
||||
} else {
|
||||
cost_op.push_back(StrDimB(tensor_filter) + CostRedis(node, node_name_to_strategy,
|
||||
mode = {{0.5, 1, 1, 1}, {1, 1, 1, 1}, {0.5, 1, 1, 1}}, graph));
|
||||
std::vector<std::vector<float>> mode = {{0.5, 1, 1, 1}, {1, 1, 1, 1}, {0.5, 1, 1, 1}};
|
||||
cost_op.push_back(StrDimB(tensor_filter) + CostRedis(node, node_name_to_strategy, mode, graph));
|
||||
}
|
||||
|
||||
cost_op.push_back(DOUBLE_MAX);
|
||||
|
@ -275,8 +270,8 @@ StrategyRec CostConvolution::GetOptimalStr(
|
|||
if (channel_partition == false || tensor_filter < 2 || tensor_filter % 2 != 0) {
|
||||
cost_op.push_back(DOUBLE_MAX);
|
||||
} else {
|
||||
cost_op.push_back(StrDimK(tensor_in) + CostRedis(node, node_name_to_strategy,
|
||||
mode = {{1, 1, 1, 1}, {0.5, 1, 1, 1}, {1, 0.5, 1, 1}}, graph));
|
||||
std::vector<std::vector<float>> mode = {{1, 1, 1, 1}, {0.5, 1, 1, 1}, {1, 0.5, 1, 1}};
|
||||
cost_op.push_back(StrDimK(tensor_in) + CostRedis(node, node_name_to_strategy, mode, graph));
|
||||
}
|
||||
|
||||
cost_op.push_back(DOUBLE_MAX);
|
||||
|
@ -285,8 +280,8 @@ StrategyRec CostConvolution::GetOptimalStr(
|
|||
if (channel_partition == false || tensor_filter_c < 2 || tensor_filter_c % 2 != 0) {
|
||||
cost_op.push_back(DOUBLE_MAX);
|
||||
} else {
|
||||
cost_op.push_back(StrDimQ(tensor_out) + CostRedis(node, node_name_to_strategy,
|
||||
mode = {{1, 0.5, 1, 1}, {1, 0.5, 1, 1}, {1, 1, 1, 1}}, graph));
|
||||
std::vector<std::vector<float>> mode = {{1, 0.5, 1, 1}, {1, 0.5, 1, 1}, {1, 1, 1, 1}};
|
||||
cost_op.push_back(StrDimQ(tensor_out) + CostRedis(node, node_name_to_strategy, mode, graph));
|
||||
}
|
||||
|
||||
return ChoseStr(cost_op, node.apply.str);
|
||||
|
@ -391,20 +386,19 @@ StrategyRec CostPooling::GetOptimalStr(const Graph::NodeType &node,
|
|||
int64_t tensor_c = static_cast<int64_t>(node.tensor_parm.tensor_shape.shape_c * node.tensor_parm.tensor_str.str_c);
|
||||
|
||||
std::vector<double> cost_op;
|
||||
std::vector<std::vector<float>> mode;
|
||||
|
||||
if (tensor_n < 2 || tensor_n % 2 != 0) {
|
||||
cost_op.push_back(DOUBLE_MAX);
|
||||
} else {
|
||||
cost_op.push_back(cost_in_ + CostRedis(node, node_name_to_strategy,
|
||||
mode = {{0.5, 1, 1, 1}, {0.5, 1, 1, 1}, {0.5, 1, 1, 1}}, graph));
|
||||
std::vector<std::vector<float>> mode = {{0.5, 1, 1, 1}, {0.5, 1, 1, 1}, {0.5, 1, 1, 1}};
|
||||
cost_op.push_back(cost_in_ + CostRedis(node, node_name_to_strategy, mode, graph));
|
||||
}
|
||||
|
||||
if (tensor_c < 2 || tensor_c % 2 != 0) {
|
||||
cost_op.push_back(DOUBLE_MAX);
|
||||
} else {
|
||||
cost_op.push_back(cost_in_ + CostRedis(node, node_name_to_strategy,
|
||||
mode = {{1, 0.5, 1, 1}, {1, 0.5, 1, 1}, {1, 0.5, 1, 1}}, graph));
|
||||
std::vector<std::vector<float>> mode = {{1, 0.5, 1, 1}, {1, 0.5, 1, 1}, {1, 0.5, 1, 1}};
|
||||
cost_op.push_back(cost_in_ + CostRedis(node, node_name_to_strategy, mode, graph));
|
||||
}
|
||||
|
||||
cost_op.push_back(DOUBLE_MAX);
|
||||
|
@ -560,34 +554,33 @@ StrategyRec CostCommon::GetOptimalStr(const Graph::NodeType &node,
|
|||
int64_t tensor_w = static_cast<int64_t>(op.arguments[0].tensor_shape.shape_w * op.arguments[0].tensor_str.str_w);
|
||||
|
||||
std::vector<double> cost_op;
|
||||
std::vector<std::vector<float>> mode;
|
||||
|
||||
if (tensor_n < 2 || tensor_n % 2 != 0) {
|
||||
cost_op.push_back(DOUBLE_MAX);
|
||||
} else {
|
||||
cost_op.push_back(cost_in_ + CostRedis(node, node_name_to_strategy,
|
||||
mode = {{0.5, 1, 1, 1}, {0.5, 1, 1, 1}, {0.5, 1, 1, 1}}, graph));
|
||||
std::vector<std::vector<float>> mode = {{0.5, 1, 1, 1}, {0.5, 1, 1, 1}, {0.5, 1, 1, 1}};
|
||||
cost_op.push_back(cost_in_ + CostRedis(node, node_name_to_strategy, mode, graph));
|
||||
}
|
||||
|
||||
if (tensor_c < 2 || tensor_c % 2 != 0) {
|
||||
cost_op.push_back(DOUBLE_MAX);
|
||||
} else {
|
||||
cost_op.push_back(cost_in_ + CostRedis(node, node_name_to_strategy,
|
||||
mode = {{1, 0.5, 1, 1}, {1, 0.5, 1, 1}, {1, 0.5, 1, 1}}, graph));
|
||||
std::vector<std::vector<float>> mode = {{1, 0.5, 1, 1}, {1, 0.5, 1, 1}, {1, 0.5, 1, 1}};
|
||||
cost_op.push_back(cost_in_ + CostRedis(node, node_name_to_strategy, mode, graph));
|
||||
}
|
||||
|
||||
if (tensor_h < 2 || tensor_h % 2 != 0) {
|
||||
cost_op.push_back(DOUBLE_MAX);
|
||||
} else {
|
||||
cost_op.push_back(cost_in_ + CostRedis(node, node_name_to_strategy,
|
||||
mode = {{1, 1, 0.5, 1}, {1, 1, 0.5, 1}, {1, 1, 0.5, 1}}, graph));
|
||||
std::vector<std::vector<float>> mode = {{1, 1, 0.5, 1}, {1, 1, 0.5, 1}, {1, 1, 0.5, 1}};
|
||||
cost_op.push_back(cost_in_ + CostRedis(node, node_name_to_strategy, mode, graph));
|
||||
}
|
||||
|
||||
if (tensor_w < 2 || tensor_w % 2 != 0) {
|
||||
cost_op.push_back(DOUBLE_MAX);
|
||||
} else {
|
||||
cost_op.push_back(cost_in_ + CostRedis(node, node_name_to_strategy,
|
||||
mode = {{1, 1, 1, 0.5}, {1, 1, 1, 0.5}, {1, 1, 1, 0.5}}, graph));
|
||||
std::vector<std::vector<float>> mode = {{1, 1, 1, 0.5}, {1, 1, 1, 0.5}, {1, 1, 1, 0.5}};
|
||||
cost_op.push_back(cost_in_ + CostRedis(node, node_name_to_strategy, mode, graph));
|
||||
}
|
||||
|
||||
return ChoseStr(cost_op, node.apply.str);
|
||||
|
|
|
@ -175,6 +175,8 @@ class CostReshape {
|
|||
// class CostCommon is used to compute the cost of an element-wise operator
|
||||
class CostCommon {
|
||||
public:
|
||||
virtual ~CostCommon() = default;
|
||||
|
||||
virtual StrategyRec GetOptimalStr(const Graph::NodeType &node,
|
||||
const std::vector<std::pair<std::string, StrategyRec>> &node_name_to_strategy,
|
||||
const Graph &graph);
|
||||
|
@ -189,11 +191,14 @@ class CostCommon {
|
|||
|
||||
// class CostBiasAdd is used to compute the cost of the addition between a tensor and a bias
|
||||
class CostBiasAdd : public CostCommon {
|
||||
StrategyRec ChoseStr(const std::vector<double> &cost_op, StrategyRec str);
|
||||
protected:
|
||||
StrategyRec ChoseStr(const std::vector<double> &cost_op, StrategyRec str) override;
|
||||
};
|
||||
|
||||
// class CostAdd is used to compute the cost of Add operator.
|
||||
class CostTensorAdd : public CostCommon {
|
||||
StrategyRec ChoseStr(const std::vector<double> &cost_op, StrategyRec str);
|
||||
protected:
|
||||
StrategyRec ChoseStr(const std::vector<double> &cost_op, StrategyRec str) override;
|
||||
};
|
||||
|
||||
// all the following operation are element-wise and have the same cost
|
||||
|
@ -210,6 +215,8 @@ class CostCast : public CostCommon {};
|
|||
// class BatchParallel is used to compute the cost of BatchParallel operator.
|
||||
class CostBatchParallel {
|
||||
public:
|
||||
virtual ~CostBatchParallel() = default;
|
||||
|
||||
virtual StrategyRec GetOptimalStr(const Graph::NodeType &node);
|
||||
|
||||
virtual double GetMaxCostIn() const { return DOUBLE_MAX; }
|
||||
|
@ -226,7 +233,8 @@ class CostPRelu : public CostBatchParallel {};
|
|||
class CostSoftmax : public CostBatchParallel {};
|
||||
|
||||
class CostSoftmaxCrossEntropyWithLogits : public CostBatchParallel {
|
||||
StrategyRec ChoseStr(const std::vector<double> &cost_op, StrategyRec str);
|
||||
protected:
|
||||
StrategyRec ChoseStr(const std::vector<double> &cost_op, StrategyRec str) override;
|
||||
};
|
||||
} // namespace parallel
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -196,7 +196,8 @@ void Eliminate_Aux(const size_t node_index, const std::shared_ptr<Graph> &graph,
|
|||
auto it = find(incoming_outputs->begin(), incoming_outputs->end(), node_index);
|
||||
if (it != incoming_outputs->end()) {
|
||||
it = incoming_outputs->erase(it);
|
||||
incoming_outputs->insert(it, graph->nodes[node_index].node_out.begin(), graph->nodes[node_index].node_out.end());
|
||||
(void)incoming_outputs->insert(it, graph->nodes[node_index].node_out.begin(),
|
||||
graph->nodes[node_index].node_out.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,8 +206,8 @@ void Eliminate_Aux(const size_t node_index, const std::shared_ptr<Graph> &graph,
|
|||
auto it = find(aux_incoming_outputs->begin(), aux_incoming_outputs->end(), node_index);
|
||||
if (it != aux_incoming_outputs->end()) {
|
||||
it = aux_incoming_outputs->erase(it);
|
||||
aux_incoming_outputs->insert(it, graph->nodes[node_index].node_out.begin(),
|
||||
graph->nodes[node_index].node_out.end());
|
||||
(void)aux_incoming_outputs->insert(it, graph->nodes[node_index].node_out.begin(),
|
||||
graph->nodes[node_index].node_out.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,7 +226,7 @@ void Eliminate_Aux(const size_t node_index, const std::shared_ptr<Graph> &graph,
|
|||
graph->nodes[node_index].node_in_aux[j]);
|
||||
}
|
||||
} else {
|
||||
outgoing_inputs->erase(it);
|
||||
(void)outgoing_inputs->erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,9 +261,8 @@ Status PartitionForAllDevices(const size_t num_device, const double device_memor
|
|||
|
||||
if (DevicesMemoryControl(num_device, device_memory, graph) != SUCCESS) {
|
||||
return FAILED;
|
||||
} else {
|
||||
return SUCCESS;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// Apply OP Strategy to Tensor Strategy
|
||||
|
@ -294,7 +293,7 @@ Status DevicesMemoryControl(const size_t num_device, const double device_memory,
|
|||
double used_memory = 0.0;
|
||||
|
||||
for (uint64_t i_node = 0; i_node < iter_nodes; i_node++) {
|
||||
if (graph->nodes[i_node].info == 0) {
|
||||
if (graph->nodes[i_node].info == InfoType::kApplication) {
|
||||
Graph::NodeType &Node = graph->nodes[i_node];
|
||||
for (int64_t index = 0; index < 2; index++) {
|
||||
used_memory += Node.apply.arguments[index].tensor_str.str_n * Node.apply.arguments[index].tensor_shape.shape_n *
|
||||
|
@ -308,7 +307,6 @@ Status DevicesMemoryControl(const size_t num_device, const double device_memory,
|
|||
|
||||
if (device_memory < (used_memory / num_device)) {
|
||||
MS_LOG(EXCEPTION) << "Failure: Out of memory!";
|
||||
return FAILED;
|
||||
} else {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ std::string HashInstanceName(const std::string &name);
|
|||
|
||||
class GenerateGraph {
|
||||
public:
|
||||
explicit GenerateGraph(mindspore::HashMap<std::string, ValuePtr> origin_attrs)
|
||||
explicit GenerateGraph(const mindspore::HashMap<std::string, ValuePtr> &origin_attrs)
|
||||
: name_idx_(0), origin_attrs_(origin_attrs) {}
|
||||
Status Init(const CNodePtr &cnode);
|
||||
~GenerateGraph() = default;
|
||||
|
|
|
@ -72,7 +72,7 @@ void GraphSplitter::DyeGraph() {
|
|||
MS_EXCEPTION_IF_NULL(func_graph_);
|
||||
|
||||
std::vector<AnfNodePtr> all_nodes = DeepScopedGraphSearch(func_graph_->get_return());
|
||||
(void)std::for_each(all_nodes.begin(), all_nodes.end(), [this](AnfNodePtr &node) {
|
||||
(void)std::for_each(all_nodes.begin(), all_nodes.end(), [this](const AnfNodePtr &node) {
|
||||
MS_EXCEPTION_IF_NULL(node);
|
||||
// Mark all nodes with original label at the beginning.
|
||||
node_labels_[node] = default_label_;
|
||||
|
@ -320,8 +320,8 @@ CNodePtr GraphSplitter::GenerateRecvNode(const AnfNodePtr &input, const AnfNodeP
|
|||
if (input->isa<CNode>() && common::AnfAlgo::HasNodeAttr(kAttrUpdateParameter, input->cast<CNodePtr>()) &&
|
||||
common::AnfAlgo::HasNodeAttr(kAttrParameterInputIndex, input->cast<CNodePtr>())) {
|
||||
int64_t parameter_index = common::AnfAlgo::GetNodeAttr<int64_t>(input, kAttrParameterInputIndex);
|
||||
auto kernel_with_index =
|
||||
common::AnfAlgo::VisitKernel(common::AnfAlgo::GetInputNode(input->cast<CNodePtr>(), parameter_index), 0);
|
||||
auto kernel_with_index = common::AnfAlgo::VisitKernel(
|
||||
common::AnfAlgo::GetInputNode(input->cast<CNodePtr>(), LongToSize(parameter_index)), 0);
|
||||
auto param_node = kernel_with_index.first;
|
||||
recv_inputs.push_back(param_node);
|
||||
recv_node_abs = param_node->abstract();
|
||||
|
|
|
@ -567,7 +567,9 @@ Status SqueezeInfo::GetAttrs() {
|
|||
MS_EXCEPTION_IF_NULL(iter->second);
|
||||
auto value_tuple = iter->second->cast<ValueTuplePtr>();
|
||||
MS_EXCEPTION_IF_NULL(value_tuple);
|
||||
InferAxis(value_tuple);
|
||||
if (InferAxis(value_tuple) != SUCCESS) {
|
||||
return FAILED;
|
||||
}
|
||||
attrs_[AXIS] = axis_;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace parallel {
|
|||
class ActivationBase : public OperatorInfo {
|
||||
public:
|
||||
ActivationBase(const std::string &operator_name, const Shapes &inputs_shape, const Shapes &outputs_shape,
|
||||
const PrimitiveAttrs &attrs, OperatorCostPtr cost)
|
||||
const PrimitiveAttrs &attrs, const OperatorCostPtr &cost)
|
||||
: OperatorInfo(operator_name, inputs_shape, outputs_shape, attrs, cost) {}
|
||||
~ActivationBase() override = default;
|
||||
|
||||
|
@ -46,7 +46,7 @@ class ActivationBase : public OperatorInfo {
|
|||
class Activation : public ActivationBase {
|
||||
public:
|
||||
Activation(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
|
||||
const PrimitiveAttrs &attrs, OperatorCostPtr cost)
|
||||
const PrimitiveAttrs &attrs, const OperatorCostPtr &cost)
|
||||
: ActivationBase(name, inputs_shape, outputs_shape, attrs, cost) {}
|
||||
~Activation() override = default;
|
||||
std::vector<StrategyPtr> GenerateOpStrategies(int64_t stage_id) override;
|
||||
|
@ -70,7 +70,7 @@ class ActivationInfo : public Activation {
|
|||
class ActivationOther : public Activation {
|
||||
public:
|
||||
ActivationOther(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
|
||||
const PrimitiveAttrs &attrs, OperatorCostPtr cost)
|
||||
const PrimitiveAttrs &attrs, const OperatorCostPtr &cost)
|
||||
: Activation(name, inputs_shape, outputs_shape, attrs, cost) {}
|
||||
~ActivationOther() override = default;
|
||||
|
||||
|
@ -310,8 +310,8 @@ class DropoutInfo : public ActivationOther {
|
|||
private:
|
||||
int64_t seed0_ = 0;
|
||||
int64_t seed1_ = 0;
|
||||
int64_t get_seed() {
|
||||
static int64_t SEED_NUM;
|
||||
int64_t get_seed() const {
|
||||
static int64_t SEED_NUM = 0;
|
||||
return ++SEED_NUM;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace parallel {
|
|||
class ArithmeticBase : public OperatorInfo {
|
||||
public:
|
||||
ArithmeticBase(const std::string &operator_name, const Shapes &inputs_shape, const Shapes &outputs_shape,
|
||||
const PrimitiveAttrs &attrs, OperatorCostPtr cost)
|
||||
const PrimitiveAttrs &attrs, const OperatorCostPtr &cost)
|
||||
: OperatorInfo(operator_name, inputs_shape, outputs_shape, attrs, cost) {}
|
||||
~ArithmeticBase() override = default;
|
||||
std::vector<StrategyPtr> GenerateOpStrategies(int64_t) override;
|
||||
|
|
|
@ -59,9 +59,9 @@ Status BoundingBoxEncodeInfo::InferTensorMap() {
|
|||
inputs_tensor_map_.clear();
|
||||
outputs_tensor_map_.clear();
|
||||
|
||||
inputs_tensor_map_.emplace_back(TensorMap({0, -1}));
|
||||
inputs_tensor_map_.emplace_back(TensorMap({0, -1}));
|
||||
outputs_tensor_map_.emplace_back(TensorMap({0, -1}));
|
||||
(void)inputs_tensor_map_.emplace_back(TensorMap({0, -1}));
|
||||
(void)inputs_tensor_map_.emplace_back(TensorMap({0, -1}));
|
||||
(void)outputs_tensor_map_.emplace_back(TensorMap({0, -1}));
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,8 +57,9 @@ Status CropAndResizeInfo::CheckStrategy(const StrategyPtr &strategy) {
|
|||
Status CropAndResizeInfo::InferDevMatrixShape() {
|
||||
dev_matrix_shape_.clear();
|
||||
|
||||
auto x_strategy = strategy_->GetInputDim().at(0);
|
||||
auto boxes_strategy = strategy_->GetInputDim().at(1);
|
||||
auto strategies = strategy_->GetInputDim();
|
||||
auto x_strategy = strategies.at(0);
|
||||
auto boxes_strategy = strategies.at(1);
|
||||
dev_matrix_shape_ = {x_strategy[0], x_strategy[3], boxes_strategy[0]};
|
||||
return SUCCESS;
|
||||
}
|
||||
|
@ -83,7 +84,8 @@ Status CropAndResizeInfo::InferBias() {
|
|||
CheckGlobalDeviceManager();
|
||||
|
||||
int64_t rank = g_device_manager->rank_index_in_stage();
|
||||
auto x_strategy = strategy_->GetInputDim().at(0);
|
||||
auto strategies = strategy_->GetInputDim();
|
||||
auto x_strategy = strategies.at(0);
|
||||
Shape x_shape = inputs_shape_.at(0);
|
||||
if (x_shape[0] % x_strategy[0] != 0) {
|
||||
return FAILED;
|
||||
|
@ -181,7 +183,8 @@ Status CropAndResizeInfo::InitForCostModel(const StrategyPtr &strategy, const St
|
|||
|
||||
constexpr size_t CROP_SIZE_INDEX = 3;
|
||||
auto crop_size = GetValue<std::vector<int64_t>>(input_value_[CROP_SIZE_INDEX]);
|
||||
auto x_strategy = strategy_->GetInputDim().at(0);
|
||||
auto strategies = strategy_->GetInputDim();
|
||||
auto x_strategy = strategies.at(0);
|
||||
auto crop_and_resize_cost = std::dynamic_pointer_cast<CropAndResizeCost>(operator_cost());
|
||||
crop_and_resize_cost->set_crop_size(crop_size);
|
||||
crop_and_resize_cost->set_strategy(x_strategy);
|
||||
|
@ -190,7 +193,8 @@ Status CropAndResizeInfo::InitForCostModel(const StrategyPtr &strategy, const St
|
|||
}
|
||||
|
||||
ReplaceGraphPtr CropAndResizeInfo::replace_graph(const CNodePtr &cnode) {
|
||||
auto x_strategy = strategy_->GetInputDim().at(0);
|
||||
auto strategies = strategy_->GetInputDim();
|
||||
auto x_strategy = strategies.at(0);
|
||||
if (x_strategy[0] != 1 && ComputeReplaceGraph(cnode) != SUCCESS) {
|
||||
MS_LOG(EXCEPTION) << name_ << ": ComputeReplaceGraph failed.";
|
||||
}
|
||||
|
|
|
@ -52,8 +52,8 @@ class CropAndResizeInfo : public OperatorInfo {
|
|||
Status InferGroup();
|
||||
Status ComputeReplaceGraph(const CNodePtr &cnode);
|
||||
|
||||
int64_t slice_size_;
|
||||
int64_t bias_;
|
||||
int64_t slice_size_ = 0;
|
||||
int64_t bias_ = 0;
|
||||
Group group_;
|
||||
};
|
||||
} // namespace parallel
|
||||
|
|
|
@ -40,8 +40,7 @@ Status IOUInfo::InferDevMatrixShape() {
|
|||
int64_t dev0 = strategise[1][0];
|
||||
|
||||
dev_matrix_shape_.clear();
|
||||
dev_matrix_shape_.push_back(dev1);
|
||||
dev_matrix_shape_.push_back(dev0);
|
||||
dev_matrix_shape_ = {dev1, dev0};
|
||||
MS_LOG(INFO) << name_ << ": The dev matrix is " << ShapeToString(dev_matrix_shape_);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
@ -50,9 +49,9 @@ Status IOUInfo::InferTensorMap() {
|
|||
inputs_tensor_map_.clear();
|
||||
outputs_tensor_map_.clear();
|
||||
|
||||
inputs_tensor_map_.emplace_back(TensorMap({1, -1}));
|
||||
inputs_tensor_map_.emplace_back(TensorMap({0, -1}));
|
||||
outputs_tensor_map_.emplace_back(TensorMap({0, 1}));
|
||||
(void)inputs_tensor_map_.emplace_back(TensorMap({1, -1}));
|
||||
(void)inputs_tensor_map_.emplace_back(TensorMap({0, -1}));
|
||||
(void)outputs_tensor_map_.emplace_back(TensorMap({0, 1}));
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -449,7 +449,8 @@ Status MatMulBase::GenerateStrategiesBase(int64_t stage_id, size_t dev_num, cons
|
|||
};
|
||||
recursive(0, dev_num);
|
||||
if (sp_vector->empty()) {
|
||||
MS_LOG(EXCEPTION) << name_ << " : No available strategy.";
|
||||
MS_LOG(ERROR) << name_ << " : No available strategy.";
|
||||
return FAILED;
|
||||
}
|
||||
return Status::SUCCESS;
|
||||
}
|
||||
|
@ -472,9 +473,10 @@ Status MatMulBase::GenerateStrategiesNotPower2(int64_t stage_id, size_t dev_num_
|
|||
continue;
|
||||
}
|
||||
auto new_stra_arrays{stra_arrays};
|
||||
new_stra_arrays[i][j] = new_stra_arrays[i][j] * dev_num_not_2_power;
|
||||
new_stra_arrays[i][j] = new_stra_arrays[i][j] * SizeToLong(dev_num_not_2_power);
|
||||
if (i == 0 && j == related_dim_left) {
|
||||
new_stra_arrays[1][related_dim_right] = new_stra_arrays[1][related_dim_right] * dev_num_not_2_power;
|
||||
new_stra_arrays[1][related_dim_right] =
|
||||
new_stra_arrays[1][related_dim_right] * SizeToLong(dev_num_not_2_power);
|
||||
}
|
||||
StrategyPtr new_stra = std::make_shared<Strategy>(stage_id, new_stra_arrays);
|
||||
sp_vector.push_back(new_stra);
|
||||
|
@ -517,6 +519,7 @@ Status MatMulBase::GenerateStrategies(int64_t stage_id) {
|
|||
std::vector<StrategyPtr> sp_vector_2_power_part;
|
||||
if (dev_num_2_power == 0) {
|
||||
if (GenerateStrategiesBase(stage_id, dev_num, input0_shape, input1_shape, &sp_vector_2_power_part) != SUCCESS) {
|
||||
MS_LOG(ERROR) << "No available strategy.";
|
||||
return FAILED;
|
||||
}
|
||||
strategy_cost_.clear();
|
||||
|
@ -660,7 +663,7 @@ Status MatMulBase::CheckForTensorSliceValid() const {
|
|||
|
||||
std::shared_ptr<Strategys> BatchMatMulInfo::GenerateBatchStrategies() {
|
||||
Dimensions batch_strategy(inputs_shape_[1].size() - 1, 1);
|
||||
batch_strategy.insert(batch_strategy.begin(), stage_device_size_);
|
||||
(void)batch_strategy.insert(batch_strategy.begin(), stage_device_size_);
|
||||
Strategys strategy_v = {batch_strategy, batch_strategy};
|
||||
return std::make_shared<Strategys>(strategy_v);
|
||||
}
|
||||
|
@ -706,7 +709,7 @@ Status MatMulBase::SetCostUnderStrategy(const mindspore::parallel::StrategyPtr &
|
|||
std::shared_ptr<StrategyWithCost> swc =
|
||||
std::make_shared<StrategyWithCost>(strategy, inputs_tensor_info_, outputs_tensor_info_);
|
||||
swc->cost_list.push_back(result);
|
||||
strategy_cost_.emplace_back(swc);
|
||||
(void)strategy_cost_.emplace_back(swc);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,8 @@ Status OneHotInfo::CheckStrategy(const StrategyPtr &strategy) {
|
|||
if (CheckStrategyValue(strategy, {outputs_shape_.at(0), inputs_shape_.at(1), inputs_shape_.at(2)}) != SUCCESS) {
|
||||
return FAILED;
|
||||
}
|
||||
auto stra = strategy->GetInputDim().at(0);
|
||||
auto strategies = strategy->GetInputDim();
|
||||
auto stra = strategies.at(0);
|
||||
bool invalid = false;
|
||||
for (size_t i = 1; i < stra.size(); ++i) {
|
||||
if (stra.at(i) != 1) {
|
||||
|
|
|
@ -395,7 +395,7 @@ void AddCommOpFusionType(const CNodePtr &comm_node, const AnfNodePtr ¶m_node
|
|||
}
|
||||
int32_t fusion_type = param_info->comm_fusion();
|
||||
attrs[FUSION] = MakeValue<int64_t>(fusion_type);
|
||||
prim->SetAttrs(attrs);
|
||||
(void)prim->SetAttrs(attrs);
|
||||
bool parallel_optimizer_comm_recompute = param_info->parallel_optimizer_comm_recompute();
|
||||
std::string instance_name = prim->instance_name();
|
||||
if (instance_name == PARALLEL_OPTIMIZER_ALLGATHER_NOT_COMPUTE && parallel_optimizer_comm_recompute &&
|
||||
|
@ -413,7 +413,7 @@ void AddCommOpMeanFlag(const CNodePtr &comm_node) {
|
|||
MS_EXCEPTION_IF_NULL(ParallelContext::GetInstance());
|
||||
bool mean_flag = ParallelContext::GetInstance()->gradients_mean();
|
||||
attrs[MEAN_FLAG] = MakeValue<bool>(mean_flag);
|
||||
prim->SetAttrs(attrs);
|
||||
(void)prim->SetAttrs(attrs);
|
||||
}
|
||||
|
||||
void AddCommOpMirrorFlag(const CNodePtr &comm_node, bool do_mirror) {
|
||||
|
@ -422,7 +422,7 @@ void AddCommOpMirrorFlag(const CNodePtr &comm_node, bool do_mirror) {
|
|||
auto attrs = prim->attrs();
|
||||
MS_EXCEPTION_IF_NULL(ParallelContext::GetInstance());
|
||||
attrs[DO_MIRROR] = MakeValue<bool>(do_mirror);
|
||||
prim->SetAttrs(attrs);
|
||||
(void)prim->SetAttrs(attrs);
|
||||
}
|
||||
|
||||
void AddCommOpAddAccuFlag(const CNodePtr &comm_node, bool add_accu) {
|
||||
|
@ -431,7 +431,7 @@ void AddCommOpAddAccuFlag(const CNodePtr &comm_node, bool add_accu) {
|
|||
auto attrs = prim->attrs();
|
||||
MS_EXCEPTION_IF_NULL(ParallelContext::GetInstance());
|
||||
attrs[ADD_ACCU] = MakeValue<bool>(add_accu);
|
||||
prim->SetAttrs(attrs);
|
||||
(void)prim->SetAttrs(attrs);
|
||||
}
|
||||
|
||||
void AddCommOpParamFlag(const CNodePtr &comm_node) {
|
||||
|
@ -1407,7 +1407,7 @@ Status GenerateStrategiesForIndependentInputs(int64_t stage_id, const Shapes &in
|
|||
continue;
|
||||
}
|
||||
auto new_stra_arrays{stra_arrays};
|
||||
new_stra_arrays[i][j] = new_stra_arrays[i][j] * dev_num_not_2_power;
|
||||
new_stra_arrays[i][j] = new_stra_arrays[i][j] * UlongToLong(dev_num_not_2_power);
|
||||
StrategyPtr new_stra = std::make_shared<Strategy>(stage_id, new_stra_arrays);
|
||||
sp_vector->push_back(new_stra);
|
||||
}
|
||||
|
@ -1563,7 +1563,7 @@ Status OperatorInfo::SetCostUnderStrategyBase(const StrategyPtr &strategy) {
|
|||
std::shared_ptr<StrategyWithCost> swc =
|
||||
std::make_shared<StrategyWithCost>(strategy, inputs_tensor_info_, outputs_tensor_info_);
|
||||
swc->cost_list.push_back(result);
|
||||
strategy_cost_.emplace_back(swc);
|
||||
(void)strategy_cost_.emplace_back(swc);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
@ -1680,7 +1680,6 @@ void OperatorInfo::ExactStrategiesAndRelatedEdges() {
|
|||
ClearStrategyCost();
|
||||
if (GenerateStrategies(0) != SUCCESS) {
|
||||
MS_LOG(EXCEPTION) << "Strategy search for Operator " << name() << " failed.";
|
||||
return;
|
||||
}
|
||||
SetIsStrategyCostExactTrue();
|
||||
// re-init the previous edges
|
||||
|
@ -1736,7 +1735,7 @@ int64_t OperatorInfo::ComputeOpAndPrevEdgeParameterInvolved() {
|
|||
for (auto &p_edge : prev_edges) {
|
||||
auto input_index = p_edge->next_op_input_index();
|
||||
auto is_in_mem = p_edge->prev_operator()->operator_cost()->is_output_in_memory();
|
||||
input_in_memory.emplace(std::make_pair(input_index, is_in_mem));
|
||||
(void)input_in_memory.emplace(std::make_pair(input_index, is_in_mem));
|
||||
}
|
||||
operator_cost()->CalculateInputsInMemory(input_in_memory);
|
||||
|
||||
|
@ -1771,7 +1770,6 @@ Status OperatorInfo::CalculateMemoryCostForInference() {
|
|||
// First, set the 'is_outputs_critical_' flag into OperatorCost.
|
||||
if (is_output_critical_ == -1) {
|
||||
MS_LOG(EXCEPTION) << "The critical flag is not set.";
|
||||
return FAILED;
|
||||
}
|
||||
operator_cost()->set_output_critical(is_output_critical_);
|
||||
// Set the memory cost in the 'strategy_cost_'
|
||||
|
|
|
@ -54,7 +54,8 @@ class Edge;
|
|||
|
||||
class OperatorInfo {
|
||||
public:
|
||||
OperatorInfo(std::string name, Shapes inputs_shape, Shapes outputs_shape, PrimitiveAttrs attrs, OperatorCostPtr cost)
|
||||
OperatorInfo(std::string name, Shapes inputs_shape, Shapes outputs_shape, PrimitiveAttrs attrs,
|
||||
const OperatorCostPtr &cost)
|
||||
: name_(std::move(name)),
|
||||
inputs_shape_(std::move(inputs_shape)),
|
||||
outputs_shape_(std::move(outputs_shape)),
|
||||
|
@ -156,12 +157,12 @@ class OperatorInfo {
|
|||
bool IsTmpIdentity() const;
|
||||
|
||||
void set_swc_index(int64_t, int64_t);
|
||||
int64_t swc_index() { return swc_index_; }
|
||||
int64_t swc_index() const { return swc_index_; }
|
||||
// Approximate the list of available strategies
|
||||
void ApproximateStrategies();
|
||||
// Make the list of available strategies exact and re-init the related edges incident to this operator
|
||||
void ExactStrategiesAndRelatedEdges();
|
||||
bool is_strategy_cost_exact() { return is_strategy_cost_exact_; }
|
||||
bool is_strategy_cost_exact() const { return is_strategy_cost_exact_; }
|
||||
void SetIsStrategyCostExactTrue() { is_strategy_cost_exact_ = true; }
|
||||
void ClearStrategyCost() { strategy_cost_.clear(); }
|
||||
void CheckSelectedStrategy(const StrategyPtr &);
|
||||
|
@ -245,7 +246,7 @@ class OperatorInfo {
|
|||
float GetFloatAttr(const std::string &attr_name);
|
||||
std::string GetStringAttr(const std::string &attr_name);
|
||||
std::vector<int64_t> GetTupleIntAttr(const std::string &attr_name);
|
||||
void ReportError(const std::string &error_msg) {
|
||||
void ReportError(const std::string &error_msg) const {
|
||||
if (is_auto_parallel_) {
|
||||
MS_LOG(INFO) << error_msg;
|
||||
} else {
|
||||
|
|
|
@ -59,9 +59,9 @@ Status RandomChoiceWithMaskInfo::InferTensorMap() {
|
|||
Shape output1_shape = outputs_shape_.at(1);
|
||||
|
||||
inputs_tensor_map_.clear();
|
||||
inputs_tensor_map_.emplace_back(Shape(input0_shape.size(), -1));
|
||||
outputs_tensor_map_.emplace_back(Shape(output0_shape.size(), -1));
|
||||
outputs_tensor_map_.emplace_back(Shape(output1_shape.size(), -1));
|
||||
(void)inputs_tensor_map_.emplace_back(Shape(input0_shape.size(), -1));
|
||||
(void)outputs_tensor_map_.emplace_back(Shape(output0_shape.size(), -1));
|
||||
(void)outputs_tensor_map_.emplace_back(Shape(output1_shape.size(), -1));
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ std::vector<StrategyPtr> RandomChoiceWithMaskInfo::GenerateOpStrategies(int64_t
|
|||
Dimensions input_partitions(inputs_shape_[0].size(), 1);
|
||||
Strategys strategies = {input_partitions};
|
||||
std::vector<StrategyPtr> sp_vector;
|
||||
sp_vector.emplace_back(std::make_shared<Strategy>(stage_id, strategies));
|
||||
(void)sp_vector.emplace_back(std::make_shared<Strategy>(stage_id, strategies));
|
||||
return sp_vector;
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,8 @@ bool IsDataParallelStrategy(const Dimensions &strategy, int32_t stage_id) {
|
|||
}
|
||||
|
||||
Status ReduceMethod::InferForwardCommunication() {
|
||||
Dimensions stra = strategy_->GetInputDim().at(0);
|
||||
auto strategies = strategy_->GetInputDim();
|
||||
Dimensions stra = strategies.at(0);
|
||||
if (cross_batch_ && IsDataParallelStrategy(stra, stage_id_)) {
|
||||
MS_LOG(INFO) << name_ << ": cross_batch is True, don't need to InferForwardCommunication";
|
||||
return SUCCESS;
|
||||
|
@ -225,7 +226,8 @@ ForwardOp CreateReduceMeanForwardOp(const std::vector<Group> &forward_group, con
|
|||
}
|
||||
|
||||
Status ReduceMeanInfo::InferForwardCommunication() {
|
||||
Dimensions stra = strategy_->GetInputDim().at(0);
|
||||
auto strategies = strategy_->GetInputDim();
|
||||
Dimensions stra = strategies.at(0);
|
||||
if (cross_batch_ && IsDataParallelStrategy(stra, stage_id_)) {
|
||||
MS_LOG(INFO) << name_ << ": cross_batch is True, don't need to InferForwardCommunication";
|
||||
return SUCCESS;
|
||||
|
@ -281,7 +283,7 @@ Status ReduceMeanInfo::InferForwardCommunication() {
|
|||
return SUCCESS;
|
||||
}
|
||||
|
||||
ForwardOp ReduceAnyInfo::CreateForwardOp(const std::vector<Group> &forward_group) {
|
||||
ForwardOp ReduceAnyInfo::CreateForwardOp(const std::vector<Group> &forward_group) const {
|
||||
// Create Cast to Int32 op
|
||||
Operator op0 = CreateCastOp(kInt32);
|
||||
|
||||
|
@ -299,7 +301,8 @@ ForwardOp ReduceAnyInfo::CreateForwardOp(const std::vector<Group> &forward_group
|
|||
}
|
||||
|
||||
Status ReduceAnyInfo::InferForwardCommunication() {
|
||||
Dimensions stra = strategy_->GetInputDim().at(0);
|
||||
auto strategies = strategy_->GetInputDim();
|
||||
Dimensions stra = strategies.at(0);
|
||||
if (cross_batch_ && IsDataParallelStrategy(stra, stage_id_)) {
|
||||
MS_LOG(INFO) << name_ << ": cross_batch is True, don't need to InferForwardCommunication";
|
||||
return SUCCESS;
|
||||
|
@ -399,7 +402,8 @@ Status ArgMaxWithValueInfo::InferMirrorOps() {
|
|||
Dimensions ReduceMethod::InferOutputStrategy() {
|
||||
std::vector<int64_t> dim_list = reduce_dim();
|
||||
Dimensions output_strategy;
|
||||
Dimensions stra = strategy_->GetInputDim().at(0);
|
||||
auto strategies = strategy_->GetInputDim();
|
||||
Dimensions stra = strategies.at(0);
|
||||
// if keepdims_ is true,then output strategy is same with input.
|
||||
for (size_t i = 0; i < stra.size(); ++i) {
|
||||
if (find(dim_list.begin(), dim_list.end(), SizeToLong(i)) != dim_list.end()) {
|
||||
|
@ -786,7 +790,8 @@ Status SquareSumAllInfo::InferTensorInfo() {
|
|||
}
|
||||
|
||||
Status SquareSumAllInfo::InferGroup() {
|
||||
Dimensions stra = strategy_->GetInputDim().at(0);
|
||||
auto strategies = strategy_->GetInputDim();
|
||||
Dimensions stra = strategies.at(0);
|
||||
forward_op_.clear();
|
||||
std::vector<int64_t> dim_list = reduce_dim();
|
||||
size_t size = stra.size();
|
||||
|
@ -832,9 +837,11 @@ Status SquareSumAllInfo::ComputeReplaceGraph(const CNodePtr &cnode) {
|
|||
GenerateGraph gen_g = GenerateGraph(attrs_);
|
||||
if (gen_g.Init(cnode) != SUCCESS) {
|
||||
MS_LOG(ERROR) << name_ << ": GenerateGraph Init failed";
|
||||
return FAILED;
|
||||
}
|
||||
if (InferGroup() != SUCCESS) {
|
||||
MS_LOG(ERROR) << name_ << ": Infer Group failed";
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
MS_LOG(INFO) << name_ << ": The rank is " << g_device_manager->rank_index_in_stage();
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace parallel {
|
|||
class ReduceMethod : public OperatorInfo {
|
||||
public:
|
||||
ReduceMethod(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
|
||||
const PrimitiveAttrs &attrs, OperatorCostPtr cost)
|
||||
const PrimitiveAttrs &attrs, const OperatorCostPtr &cost)
|
||||
: OperatorInfo(name, inputs_shape, outputs_shape, attrs, cost) {}
|
||||
~ReduceMethod() override = default;
|
||||
|
||||
|
@ -130,7 +130,7 @@ class ReduceAnyInfo : public ReduceMethod {
|
|||
|
||||
protected:
|
||||
Status InferForwardCommunication() override;
|
||||
ForwardOp CreateForwardOp(const std::vector<Group> &forward_group);
|
||||
ForwardOp CreateForwardOp(const std::vector<Group> &forward_group) const;
|
||||
};
|
||||
|
||||
class ReduceMinInfo : public ReduceMethod {
|
||||
|
|
|
@ -30,7 +30,7 @@ Status ROIAlignInfo::GetAttrs() {
|
|||
MS_LOG(ERROR) << name_ << ": Get primitive attr \"" << attr_key << "\" failed.";
|
||||
return FAILED;
|
||||
}
|
||||
roi_align_attrs.emplace_back(std::make_pair(attr_key, attrs_[attr_key]));
|
||||
(void)roi_align_attrs.emplace_back(std::make_pair(attr_key, attrs_[attr_key]));
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
@ -61,8 +61,9 @@ Status ROIAlignInfo::CheckStrategy(const StrategyPtr &strategy) {
|
|||
Status ROIAlignInfo::InferDevMatrixShape() {
|
||||
dev_matrix_shape_.clear();
|
||||
|
||||
auto features_strategy = strategy_->GetInputDim().at(0);
|
||||
auto rois_strategy = strategy_->GetInputDim().at(1);
|
||||
auto strategies = strategy_->GetInputDim();
|
||||
auto features_strategy = strategies.at(0);
|
||||
auto rois_strategy = strategies.at(1);
|
||||
dev_matrix_shape_ = {features_strategy[0], features_strategy[1], rois_strategy[0]};
|
||||
return SUCCESS;
|
||||
}
|
||||
|
@ -85,9 +86,10 @@ Status ROIAlignInfo::InferBias() {
|
|||
CheckGlobalDeviceManager();
|
||||
|
||||
int64_t rank = g_device_manager->rank_index_in_stage();
|
||||
auto features_strategy = strategy_->GetInputDim().at(0);
|
||||
auto strategies = strategy_->GetInputDim();
|
||||
auto features_strategy = strategies.at(0);
|
||||
auto features_shape = inputs_shape_.at(0);
|
||||
auto rois_strategy = strategy_->GetInputDim().at(1);
|
||||
auto rois_strategy = strategies.at(1);
|
||||
auto rois_shape = inputs_shape_.at(1);
|
||||
if (features_shape[0] % features_strategy[0] != 0 || rois_shape[0] % rois_strategy[0] != 0) {
|
||||
return FAILED;
|
||||
|
@ -202,7 +204,8 @@ Status ROIAlignInfo::InitForCostModel(const StrategyPtr &strategy, const Strateg
|
|||
}
|
||||
return FAILED;
|
||||
}
|
||||
auto features_strategy = strategy_->GetInputDim().at(0);
|
||||
auto strategies = strategy_->GetInputDim();
|
||||
auto features_strategy = strategies.at(0);
|
||||
auto roi_align_cost = std::dynamic_pointer_cast<ROIAlignCost>(operator_cost());
|
||||
auto pooled_height = GetValue<int64_t>(attrs_[POOLED_HEIGHT]);
|
||||
auto pooled_width = GetValue<int64_t>(attrs_[POOLED_WIDTH]);
|
||||
|
@ -213,14 +216,15 @@ Status ROIAlignInfo::InitForCostModel(const StrategyPtr &strategy, const Strateg
|
|||
}
|
||||
|
||||
ReplaceGraphPtr ROIAlignInfo::replace_graph(const CNodePtr &cnode) {
|
||||
auto features_strategy = strategy_->GetInputDim().at(0);
|
||||
auto strategies = strategy_->GetInputDim();
|
||||
auto features_strategy = strategies.at(0);
|
||||
if (features_strategy[0] != 1 && ComputeReplaceGraph(cnode) != SUCCESS) {
|
||||
MS_LOG(EXCEPTION) << name_ << ": ComputeReplaceGraph failed.";
|
||||
}
|
||||
return replace_graph_;
|
||||
}
|
||||
|
||||
std::vector<int64_t> ROIAlignInfo::CreateRangeVector(int64_t upper_bound) {
|
||||
std::vector<int64_t> ROIAlignInfo::CreateRangeVector(int64_t upper_bound) const {
|
||||
std::vector<int64_t> range(upper_bound);
|
||||
for (int64_t i = 0; i < upper_bound; ++i) {
|
||||
range[LongToSize(i)] = i;
|
||||
|
|
|
@ -50,11 +50,11 @@ class ROIAlignInfo : public OperatorInfo {
|
|||
Status InferBias();
|
||||
Status InferGroup();
|
||||
Status ComputeReplaceGraph(const CNodePtr &cnode);
|
||||
std::vector<int64_t> CreateRangeVector(int64_t upper_bound);
|
||||
std::vector<int64_t> CreateRangeVector(int64_t upper_bound) const;
|
||||
|
||||
int64_t features_slice_size_;
|
||||
int64_t rois_slice_size_;
|
||||
int64_t bias_;
|
||||
int64_t features_slice_size_ = 0;
|
||||
int64_t rois_slice_size_ = 0;
|
||||
int64_t bias_ = 0;
|
||||
Group group_;
|
||||
OperatorAttrs roi_align_attrs;
|
||||
};
|
||||
|
|
|
@ -251,7 +251,7 @@ void TensorDotInfo::InferTensorMapAxesTuple(size_t size, const TensorMap &input_
|
|||
|
||||
if (!found) {
|
||||
input_b_tensor_map.push_back(tmp_b_map_index.front());
|
||||
tmp_b_map_index.erase(tmp_b_map_index.begin());
|
||||
(void)tmp_b_map_index.erase(tmp_b_map_index.begin());
|
||||
} else {
|
||||
input_b_tensor_map.push_back(input_a_tensor_map[relevant_a_index]);
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ class TensorDotInfo : public OperatorInfo {
|
|||
~TensorDotInfo() override = default;
|
||||
|
||||
std::vector<StrategyPtr> GenerateOpStrategies(int64_t stage_id) override;
|
||||
std::shared_ptr<Strategys> GenerateBatchStrategies() override;
|
||||
Status SetCostUnderStrategy(const StrategyPtr &strategy) override;
|
||||
Status PrepareStrategy(int32_t stage_id, size_t dev_num, Dimensions combined_partitions, size_t input0_shape_size,
|
||||
size_t input1_shape_size, StrategyPtr *sp);
|
||||
|
@ -55,7 +56,6 @@ class TensorDotInfo : public OperatorInfo {
|
|||
Status InferDevMatrixShape() override;
|
||||
Status InferTensorMap() override;
|
||||
Status GetAttrs() override;
|
||||
std::shared_ptr<Strategys> GenerateBatchStrategies() override;
|
||||
void InferTensorMapAxesInt(const TensorMap &tensor_map_index);
|
||||
void InferTensorMapAxesTuple(size_t size, const TensorMap &input_a_tensor_map, const TensorMap &tensor_map_index);
|
||||
void ShowAxes();
|
||||
|
|
|
@ -157,9 +157,9 @@ Status UnsortedSegmentOpInfo::InferTensorMap() {
|
|||
return FAILED;
|
||||
}
|
||||
|
||||
inputs_tensor_map_.emplace_back(std::move(tensor_map_in));
|
||||
inputs_tensor_map_.emplace_back(std::move(tensor_map_in_index));
|
||||
outputs_tensor_map_.emplace_back(std::move(tensor_map_out));
|
||||
(void)inputs_tensor_map_.emplace_back(std::move(tensor_map_in));
|
||||
(void)inputs_tensor_map_.emplace_back(std::move(tensor_map_in_index));
|
||||
(void)outputs_tensor_map_.emplace_back(std::move(tensor_map_out));
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,8 @@ std::shared_ptr<Strategys> UnsortedSegmentOpInfo::GenerateBatchStrategies() {
|
|||
// a special case is when the shape input equals the shape of ids, we regard it as column slice,
|
||||
// thus there is no need for repalce graphs
|
||||
ReplaceGraphPtr UnsortedSegmentMinInfo::replace_graph(const CNodePtr &cnode) {
|
||||
auto input_id_strategy = strategy_->GetInputDim().at(1);
|
||||
auto strategies = strategy_->GetInputDim();
|
||||
auto input_id_strategy = strategies.at(1);
|
||||
// 1. the two input shapes are same, and the strategy is not all ones
|
||||
if (std::any_of(input_id_strategy.begin(), input_id_strategy.end(), [](const int64_t &shard) { return shard > 1; })) {
|
||||
if (ComputeReplaceGraph(cnode) != SUCCESS) {
|
||||
|
@ -277,7 +278,8 @@ Status UnsortedSegmentMinInfo::ComputeReplaceGraph(const CNodePtr &cnode) {
|
|||
// The UnsortedSegmentMaxInfo is almost same with UnsortedSegmentMinInfo
|
||||
// Except the reduceMin op in the ComputeReplaceGraph is replaced with reduceMax op
|
||||
ReplaceGraphPtr UnsortedSegmentMaxInfo::replace_graph(const CNodePtr &cnode) {
|
||||
auto input_id_strategy = strategy_->GetInputDim().at(1);
|
||||
auto strategies = strategy_->GetInputDim();
|
||||
auto input_id_strategy = strategies.at(1);
|
||||
// 1. the two input shapes are same, and the strategy is not all ones
|
||||
if (std::any_of(input_id_strategy.begin(), input_id_strategy.end(), [](const int64_t &shard) { return shard > 1; })) {
|
||||
if (ComputeReplaceGraph(cnode) != SUCCESS) {
|
||||
|
|
|
@ -41,7 +41,7 @@ constexpr size_t UNSORTEDSEGMENTOP_OUTPUTS_SIZE = 1;
|
|||
class UnsortedSegmentOpInfo : public OperatorInfo {
|
||||
public:
|
||||
UnsortedSegmentOpInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
|
||||
const PrimitiveAttrs &attrs, OperatorCostPtr cost)
|
||||
const PrimitiveAttrs &attrs, const OperatorCostPtr &cost)
|
||||
: OperatorInfo(name, inputs_shape, outputs_shape, attrs, cost) {}
|
||||
~UnsortedSegmentOpInfo() override = default;
|
||||
|
||||
|
@ -57,9 +57,6 @@ class UnsortedSegmentOpInfo : public OperatorInfo {
|
|||
Status InferDevMatrixShape() override;
|
||||
Status InferTensorMap() override;
|
||||
Status GetAttrs() override;
|
||||
|
||||
private:
|
||||
Status ComputeReplaceGraph(const CNodePtr &cnode);
|
||||
};
|
||||
|
||||
class UnsortedSegmentSumInfo : public UnsortedSegmentOpInfo {
|
||||
|
@ -92,11 +89,12 @@ class UnsortedSegmentMinInfo : public UnsortedSegmentOpInfo {
|
|||
~UnsortedSegmentMinInfo() override = default;
|
||||
|
||||
ReplaceGraphPtr replace_graph(const CNodePtr &cnode) override;
|
||||
Status InferForwardCommunication() override { return SUCCESS; }
|
||||
|
||||
protected:
|
||||
Status ComputeReplaceGraph(const CNodePtr &cnode);
|
||||
Status InferForwardCommunication() override { return SUCCESS; }
|
||||
};
|
||||
|
||||
class UnsortedSegmentMaxInfo : public UnsortedSegmentOpInfo {
|
||||
public:
|
||||
UnsortedSegmentMaxInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
|
||||
|
@ -107,12 +105,11 @@ class UnsortedSegmentMaxInfo : public UnsortedSegmentOpInfo {
|
|||
~UnsortedSegmentMaxInfo() override = default;
|
||||
|
||||
ReplaceGraphPtr replace_graph(const CNodePtr &cnode) override;
|
||||
Status InferForwardCommunication() override { return SUCCESS; }
|
||||
|
||||
protected:
|
||||
Status ComputeReplaceGraph(const CNodePtr &cnode);
|
||||
Status InferForwardCommunication() override { return SUCCESS; }
|
||||
};
|
||||
|
||||
} // namespace parallel
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CCSRC_FRONTEND_PARALLEL_OPS_INFO_UNSORTEDSEGMENTOP_INFO_H_
|
||||
|
|
|
@ -148,7 +148,6 @@ class OptParamMgrImpl : public OptParamMgr {
|
|||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
FuncGraphPtr root_;
|
||||
int64_t DEFAULT_VAL = 64; // unit: KB
|
||||
int64_t DIVISOR_K = 1024;
|
||||
|
|
|
@ -27,7 +27,7 @@ class Executor;
|
|||
class ExecutorManager {
|
||||
public:
|
||||
static ExecutorManager &Instance() {
|
||||
static ExecutorManager instance;
|
||||
static ExecutorManager instance = ExecutorManager();
|
||||
return instance;
|
||||
}
|
||||
std::shared_ptr<Executor> GetExecutor(const std::string &device_name, uint32_t device_id);
|
||||
|
|
|
@ -27,8 +27,9 @@ class Executor {
|
|||
public:
|
||||
Executor(const std::string &device_name, uint32_t device_id) : device_name_(device_name), device_id_(device_id) {}
|
||||
~Executor() = default;
|
||||
bool CreateCommGroup(const std::string &group_name, std::vector<uint32_t> ranks) const { return true; }
|
||||
bool DestroyCommGroup(const std::string &group_name) const { return true; }
|
||||
|
||||
bool CreateCommGroup(const std::string &, const std::vector<uint32_t> &) const { return true; }
|
||||
bool DestroyCommGroup(const std::string &) const { return true; }
|
||||
|
||||
private:
|
||||
std::string device_name_;
|
||||
|
|
|
@ -425,7 +425,9 @@ TensorLayout TensorLayout::TransferRepeatLayout() const {
|
|||
Shape tensor_map(tensor_map_origin_.GetDimSize(), -1);
|
||||
Shape tensor_shape(tensor_shape_origin_.array());
|
||||
TensorLayout repeat;
|
||||
repeat.InitFromVector(dev_mat, tensor_map, tensor_shape);
|
||||
if (repeat.InitFromVector(dev_mat, tensor_map, tensor_shape) != SUCCESS) {
|
||||
MS_LOG(EXCEPTION) << "Init from vector failed.";
|
||||
}
|
||||
return repeat;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,15 +112,15 @@ class TensorLayout {
|
|||
|
||||
void set_opt_weight_shard_step(int32_t step) { opt_weight_shard_step_ = step; }
|
||||
|
||||
int32_t opt_weight_shard_step() { return opt_weight_shard_step_; }
|
||||
int32_t opt_weight_shard_step() const { return opt_weight_shard_step_; }
|
||||
|
||||
void set_opt_weight_shard_size(int32_t size) { opt_weight_shard_size_ = size; }
|
||||
|
||||
int32_t opt_weight_shard_size() { return opt_weight_shard_size_; }
|
||||
int32_t opt_weight_shard_size() const { return opt_weight_shard_size_; }
|
||||
|
||||
void set_is_shared_param(bool is_shared_param) { is_shared_param_ = is_shared_param; }
|
||||
|
||||
bool is_shared_param() { return is_shared_param_; }
|
||||
bool is_shared_param() const { return is_shared_param_; }
|
||||
|
||||
// Key for user data.
|
||||
constexpr static char key[] = "TLayout";
|
||||
|
@ -145,7 +145,7 @@ class TensorLayout {
|
|||
bool skip_redistribution_ = false;
|
||||
bool uniform_split_ = true;
|
||||
bool layout_transfer_ = false;
|
||||
int32_t field_size_ = 0;
|
||||
int64_t field_size_ = 0;
|
||||
Shape opt_shard_slice_shape_;
|
||||
std::string opt_shard_group_ = ""; // for allgather
|
||||
std::string opt_shard_mirror_group_ = ""; // for mirror ops
|
||||
|
|
|
@ -187,13 +187,13 @@ Status TensorRedistribution::InferRedistribution(const TensorLayout &from_layout
|
|||
return Status::FAILED;
|
||||
} else {
|
||||
for (auto op : operator_infer.operator_vector()) {
|
||||
operator_vector->insert(operator_vector->end(), op);
|
||||
(void)operator_vector->insert(operator_vector->end(), op);
|
||||
}
|
||||
for (auto info : operator_infer.output_info_vector()) {
|
||||
output_info_vector->insert(output_info_vector->end(), info);
|
||||
(void)output_info_vector->insert(output_info_vector->end(), info);
|
||||
}
|
||||
for (auto opc : operator_infer.operator_list()) {
|
||||
operator_list_.insert(operator_list_.end(), opc);
|
||||
(void)operator_list_.insert(operator_list_.end(), opc);
|
||||
}
|
||||
}
|
||||
return Status::SUCCESS;
|
||||
|
|
Loading…
Reference in New Issue