!12992 Enable dynamic shape when RunOpsInGraph

From: @HulkTang
Reviewed-by: @chujinjin
Signed-off-by:
pull/12992/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit 6caca505fa

@ -735,6 +735,10 @@ void AscendSession::BuildOpsInGraph(const GraphId &graph_id, const std::map<AnfN
// Get OpRunInfo and GraphInfo
OpRunInfo op_run_info;
GetSingleOpRunInfo(kernel, &op_run_info);
if (op_run_info.is_dynamic_shape) {
MS_LOG(INFO) << "BuildOpsInGraph stop, op " << op_run_info.op_name << " is dynamic shape.";
break;
}
const GraphInfo &graph_info = GetSingleOpGraphInfo(kernel, input_tensor_info.input_tensors);
const auto &single_op_graph_iter = run_op_graphs_.find(graph_info);
if (single_op_graph_iter != run_op_graphs_.end()) {

@ -1345,10 +1345,17 @@ void SessionBasic::GetSingleOpRunInfo(const CNodePtr cnode, OpRunInfo *run_info)
auto primitive = AnfAlgo::GetCNodePrimitive(cnode);
run_info->primitive = primitive;
run_info->op_name = primitive->name();
if (cnode->abstract() == nullptr) {
const auto &abstract = cnode->abstract();
if (abstract == nullptr) {
MS_LOG(EXCEPTION) << "Abstract is nullptr, node = " << cnode->DebugString();
}
run_info->abstract = cnode->abstract();
run_info->abstract = abstract;
const auto &shape = abstract->BuildShape();
MS_EXCEPTION_IF_NULL(shape);
const auto &shape_info = shape->ToString();
if (shape_info.find("-1") != string::npos) {
run_info->is_dynamic_shape = true;
}
}
TensorPtr SessionBasic::GetValueNodeOutputTensor(const AnfNodePtr &node, size_t output_index) {

Loading…
Cancel
Save