!26561 Add Dynamic Shape Check

Merge pull request !26561 from hwjiaorui/dynamic-and-format
This commit is contained in:
i-robot 2021-11-22 11:03:59 +00:00 committed by Gitee
commit af7b3767dc
1 changed files with 13 additions and 0 deletions

View File

@ -279,6 +279,17 @@ void AddGraphToManager(const NotNull<KernelGraphPtr> graph, NotNull<FuncGraphMan
AddGraphToManager(NOT_NULL(child_graph.lock()), manager, memo);
}
}
void CheckControlFlowDynamicShape(std::vector<KernelGraphPtr> all_graphs) {
if (all_graphs.size() <= 1) {
return;
}
for (auto &graph : all_graphs) {
if (graph->is_dynamic_shape()) {
MS_LOG(EXCEPTION) << "Dynamic shape is not supported with control flow(loop control statements and conditions "
"control statements).";
}
}
}
} // namespace
void AscendSession::Init(uint32_t device_id) { InitExecutor(kAscendDevice, device_id); }
@ -387,6 +398,8 @@ GraphId AscendSession::CompileGraphImpl(NotNull<FuncGraphPtr> func_graph) {
}
UnifyMindIR(root_graph);
opt::BackendCommonOptimization(root_graph);
CheckControlFlowDynamicShape(all_graphs);
// empty graph dont entry to backend
if (root_graph->execution_order().empty()) {
MS_LOG(INFO) << root_graph->ToString() << " is empty graph.";