Browse Source

!16014 modify log for matmul info

From: @yangzhenzhang
Reviewed-by: @kisnwang,@stsuteng
Signed-off-by: @stsuteng
pull/16014/MERGE
mindspore-ci-bot Gitee 4 years ago
parent
commit
000bacafd6
3 changed files with 50 additions and 21 deletions
  1. +4
    -6
      mindspore/ccsrc/frontend/parallel/ops_info/matmul_info.cc
  2. +45
    -14
      mindspore/ccsrc/frontend/parallel/ops_info/operator_info.cc
  3. +1
    -1
      mindspore/ccsrc/frontend/parallel/ops_info/operator_info.h

+ 4
- 6
mindspore/ccsrc/frontend/parallel/ops_info/matmul_info.cc View File

@@ -170,15 +170,13 @@ Status MatMul::CheckStrategy(const StrategyPtr &strategy) {
// dev_matrix_shape:[2,4,8,16,32] (transpose_b is false) // dev_matrix_shape:[2,4,8,16,32] (transpose_b is false)
// [16] in the example above // [16] in the example above
if (!transpose_b_ && (mat_a_strategy.back() != mat_b_strategy.at(SECOND_FROM_END(mat_b_size)))) { if (!transpose_b_ && (mat_a_strategy.back() != mat_b_strategy.at(SECOND_FROM_END(mat_b_size)))) {
MS_LOG(ERROR) << name_ << " : Can not do this operator in the strategy: (" << ShapeToString(mat_a_strategy) << ", "
<< ShapeToString(mat_b_strategy)
<< "), the transpose_b is false, the shard num of first input's column is " << mat_a_strategy.back()
MS_LOG(ERROR) << name_ << " : Can not do this operator in the strategy: " << StrategyToString(stra)
<< ", the transpose_b is false, the shard num of first input's column is " << mat_a_strategy.back()
<< ", but the shard num of second input's row is " << mat_b_strategy.at(SECOND_FROM_END(mat_b_size)); << ", but the shard num of second input's row is " << mat_b_strategy.at(SECOND_FROM_END(mat_b_size));
return FAILED; return FAILED;
} else if (transpose_b_ && (mat_a_strategy.back() != mat_b_strategy.back())) { } else if (transpose_b_ && (mat_a_strategy.back() != mat_b_strategy.back())) {
MS_LOG(ERROR) << name_ << " : Can not do this operator in the strategy: (" << ShapeToString(mat_a_strategy) << ", "
<< ShapeToString(mat_b_strategy)
<< "), the transpose_b is true, the shard num of first input's column is " << mat_a_strategy.back()
MS_LOG(ERROR) << name_ << " : Can not do this operator in the strategy: " << StrategyToString(stra)
<< ", the transpose_b is true, the shard num of first input's column is " << mat_a_strategy.back()
<< ", but the shard num of second input's column is " << mat_b_strategy.back(); << ", but the shard num of second input's column is " << mat_b_strategy.back();
return FAILED; return FAILED;
} }


+ 45
- 14
mindspore/ccsrc/frontend/parallel/ops_info/operator_info.cc View File

@@ -33,6 +33,29 @@


namespace mindspore { namespace mindspore {
namespace parallel { namespace parallel {
std::string StrategyToString(const Strategys &strategy) {
std::string strategy_str = "";
strategy_str += "(";
for (size_t i = 0; i < strategy.size(); ++i) {
strategy_str += "(";
for (size_t j = 0; j < strategy[i].size(); ++j) {
strategy_str += std::to_string(strategy[i][j]);
if (j != strategy[i].size() - 1) {
strategy_str += ", ";
}
}
strategy_str += ")";
if (i != strategy.size() - 1) {
strategy_str += ", ";
}
}
if (strategy.size() == 1) {
strategy_str += ",";
}
strategy_str += ")";
return strategy_str;
}

Status OperatorInfo::CheckStrategyValue(const StrategyPtr &strategy, const Shapes &inputs_shape) { Status OperatorInfo::CheckStrategyValue(const StrategyPtr &strategy, const Shapes &inputs_shape) {
if (strategy == nullptr) { if (strategy == nullptr) {
MS_LOG(ERROR) << name_ << ": The strategy is null."; MS_LOG(ERROR) << name_ << ": The strategy is null.";
@@ -41,18 +64,18 @@ Status OperatorInfo::CheckStrategyValue(const StrategyPtr &strategy, const Shape


size_t strategy_size = strategy->GetInputNumber(); size_t strategy_size = strategy->GetInputNumber();
size_t inputs_shape_size = inputs_shape.size(); size_t inputs_shape_size = inputs_shape.size();
Strategys stra = strategy->GetInputDim();
if (strategy_size != inputs_shape_size) { if (strategy_size != inputs_shape_size) {
if (is_auto_parallel_) { if (is_auto_parallel_) {
MS_LOG(DEBUG) << name_ << ": Strategy size: " << strategy_size
MS_LOG(DEBUG) << name_ << ": The strategy is " << StrategyToString(stra) << ", strategy size: " << strategy_size
<< " is not equal to inputs size: " << inputs_shape_size; << " is not equal to inputs size: " << inputs_shape_size;
} else { } else {
MS_LOG(ERROR) << name_ << ": Strategy size: " << strategy_size
MS_LOG(ERROR) << name_ << ": The strategy is " << StrategyToString(stra) << ", strategy size: " << strategy_size
<< " is not equal to inputs size: " << inputs_shape_size; << " is not equal to inputs size: " << inputs_shape_size;
} }
return FAILED; return FAILED;
} }


Strategys stra = strategy->GetInputDim();
for (size_t i = 0; i < strategy_size; ++i) { for (size_t i = 0; i < strategy_size; ++i) {
Shape sub_strategy = stra.at(i); Shape sub_strategy = stra.at(i);
Shape sub_input_shape = inputs_shape.at(i); Shape sub_input_shape = inputs_shape.at(i);
@@ -60,11 +83,11 @@ Status OperatorInfo::CheckStrategyValue(const StrategyPtr &strategy, const Shape
size_t inputs_len = sub_input_shape.size(); size_t inputs_len = sub_input_shape.size();
if (strategy_len != inputs_len) { if (strategy_len != inputs_len) {
if (is_auto_parallel_) { if (is_auto_parallel_) {
MS_LOG(DEBUG) << name_ << ": Strategy len: " << strategy_len << " is not equal to inputs len: " << inputs_len
<< ", index: " << i;
MS_LOG(DEBUG) << name_ << ": The strategy is " << StrategyToString(stra) << ", strategy len: " << strategy_len
<< " is not equal to inputs len: " << inputs_len << ", index: " << i;
} else { } else {
MS_LOG(ERROR) << name_ << ": Strategy len: " << strategy_len << " is not equal to inputs len: " << inputs_len
<< ", index: " << i;
MS_LOG(ERROR) << name_ << ": The strategy is " << StrategyToString(stra) << ", strategy len: " << strategy_len
<< " is not equal to inputs len: " << inputs_len << ", index: " << i;
} }
return FAILED; return FAILED;
} }
@@ -73,18 +96,22 @@ Status OperatorInfo::CheckStrategyValue(const StrategyPtr &strategy, const Shape
int64_t strategy_value = sub_strategy.at(j); int64_t strategy_value = sub_strategy.at(j);
if (strategy_value < MIN_SLICE_NUM) { if (strategy_value < MIN_SLICE_NUM) {
if (is_auto_parallel_) { if (is_auto_parallel_) {
MS_LOG(DEBUG) << name_ << ": Invalid strategy value: " << strategy_value;
MS_LOG(DEBUG) << name_ << ": The strategy is " << StrategyToString(stra)
<< ", the value of strategy must be larger than 0, but get " << strategy_value;
} else { } else {
MS_LOG(ERROR) << name_ << ": Invalid strategy value: " << strategy_value;
MS_LOG(ERROR) << name_ << ": The strategy is " << StrategyToString(stra)
<< ", the value of strategy must be larger than 0, but get " << strategy_value;
} }
return FAILED; return FAILED;
} }


if ((LongToUlong(strategy_value) & LongToUlong(strategy_value - 1)) != 0) { if ((LongToUlong(strategy_value) & LongToUlong(strategy_value - 1)) != 0) {
if (is_auto_parallel_) { if (is_auto_parallel_) {
MS_LOG(DEBUG) << name_ << ": Invalid Strategy value it is not the power of 2, " << strategy_value;
MS_LOG(DEBUG) << name_ << ": The strategy is " << StrategyToString(stra)
<< ", the value of strategy must be the power of 2, but get " << strategy_value;
} else { } else {
MS_LOG(ERROR) << name_ << ": Invalid Strategy value it is not the power of 2, " << strategy_value;
MS_LOG(ERROR) << name_ << ": The strategy is " << StrategyToString(stra)
<< ", the value of strategy must be the power of 2, but get " << strategy_value;
} }
return FAILED; return FAILED;
} }
@@ -92,9 +119,11 @@ Status OperatorInfo::CheckStrategyValue(const StrategyPtr &strategy, const Shape
int64_t shape_value = sub_input_shape.at(j); int64_t shape_value = sub_input_shape.at(j);
if ((shape_value % strategy_value) != 0) { if ((shape_value % strategy_value) != 0) {
if (is_auto_parallel_) { if (is_auto_parallel_) {
MS_LOG(DEBUG) << name_ << ": Shape " << shape_value << " cannot be divisible by strategy " << strategy_value;
MS_LOG(DEBUG) << name_ << ": The strategy is " << StrategyToString(stra) << ", shape " << shape_value
<< " cannot be divisible by strategy value " << strategy_value;
} else { } else {
MS_LOG(ERROR) << name_ << ": Shape " << shape_value << " cannot be divisible by strategy " << strategy_value;
MS_LOG(ERROR) << name_ << ": The strategy is " << StrategyToString(stra) << ", shape " << shape_value
<< " cannot be divisible by strategy value " << strategy_value;
} }
return FAILED; return FAILED;
} }
@@ -184,7 +213,9 @@ Status OperatorInfo::InferRepeatedCalcInfo() {
} else if (g_dev_list_size % dev_matrix_size == 0) { } else if (g_dev_list_size % dev_matrix_size == 0) {
repeated_calc_num_ = ((int64_t)(g_dev_list_size / dev_matrix_size)); repeated_calc_num_ = ((int64_t)(g_dev_list_size / dev_matrix_size));
} else { } else {
MS_LOG(ERROR) << name_ << ": Dev list size " << g_dev_list_size << " can not be divisible by dev matrix size "
MS_LOG(ERROR) << name_ << ": The strategy is " << StrategyToString(strategy_->GetInputDim()) << ", it requires "
<< dev_matrix_size << " devices, "
<< "but the device number of this stage is " << g_dev_list_size << ", it can not be divisible by "
<< dev_matrix_size; << dev_matrix_size;
return FAILED; return FAILED;
} }


+ 1
- 1
mindspore/ccsrc/frontend/parallel/ops_info/operator_info.h View File

@@ -297,7 +297,7 @@ OperatorVector CreateMirrorOps(const std::string &group_name, size_t dev_num);
int64_t ComputeRepeatDeviceNumByTensorMap(const Shape &dev_matrix_shape, const Shape &tensor_map); int64_t ComputeRepeatDeviceNumByTensorMap(const Shape &dev_matrix_shape, const Shape &tensor_map);
std::shared_ptr<Strategys> GenerateBatchStrategiesBySplitFlag(const Shapes &shapes, std::shared_ptr<Strategys> GenerateBatchStrategiesBySplitFlag(const Shapes &shapes,
const std::vector<bool> &split_flag_list); const std::vector<bool> &split_flag_list);
std::string StrategyToString(const Strategys &strategy);
void PrintStrategy(const StrategyPtr &strategy); void PrintStrategy(const StrategyPtr &strategy);
// generate strategies for that all inputs' dimensions are independent, such as: ([a, b, c, d]) // generate strategies for that all inputs' dimensions are independent, such as: ([a, b, c, d])
Status GenerateStrategiesForIndependentInputs(int64_t stage_id, const Shapes &inputs_shape, Status GenerateStrategiesForIndependentInputs(int64_t stage_id, const Shapes &inputs_shape,


Loading…
Cancel
Save