!7380 fix bug in searching strategy of reshape

Merge pull request !7380 from yao_yf/reshape_strategy_search_fix
This commit is contained in:
mindspore-ci-bot 2020-10-16 17:40:13 +08:00 committed by Gitee
commit 412141871b
2 changed files with 3 additions and 1 deletions

View File

@ -423,6 +423,7 @@ void ReshapeInfo::SetCostForReshape(const mindspore::parallel::StrategyPtr &stra
std::make_shared<StrategyWithCost>(strategy, inputs_tensor_info_, outputs_tensor_info_);
swc->cost_list.push_back(result);
strategy_cost_.emplace_back(swc);
ResetQueueMember();
}
Status ReshapeInfo::GenerateStrategies(int32_t stage_id) {

View File

@ -223,7 +223,8 @@ Status TensorRedistribution::ComputeCost() {
} else {
prev_shape = from_.tensor_shape().array();
}
double prev_prod = std::accumulate(prev_shape.begin(), prev_shape.end(), 1, std::multiplies<int>());
double prev_prod =
std::accumulate(prev_shape.begin(), prev_shape.end(), static_cast<double>(1.0), std::multiplies<double>());
computation_cost_ += 2.0 * prev_prod;
memory_cost_ += 2.0 * prev_prod;
}