forked from mindspore-Ecosystem/mindspore
!8911 add control flow error of dynamic shape
From: @hwjiaorui Reviewed-by: @jjfeing,@kisnwang Signed-off-by: @kisnwang
This commit is contained in:
commit
d1322b62b1
|
@ -146,8 +146,7 @@ GraphId AscendSession::CompileGraphImpl(NotNull<FuncGraphPtr> func_graph) {
|
|||
std::vector<KernelGraphPtr> all_graphs;
|
||||
auto root_graph = ConstructKernelGraph(func_graph, &all_graphs);
|
||||
// Update Graph Dynamic Shape Attr
|
||||
UpdateGraphDynamicShapeAttr(NOT_NULL(root_graph));
|
||||
root_graph->UpdateGraphDynamicAttr();
|
||||
UpdateAllGraphDynamicShapeAttr(all_graphs);
|
||||
BackendOptimization(all_graphs);
|
||||
// empty graph dont entry to backend
|
||||
if (root_graph->execution_order().empty()) {
|
||||
|
|
|
@ -1592,6 +1592,17 @@ bool IsNodeInputDynamicShape(const CNodePtr &anf_node_ptr) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void SessionBasic::UpdateAllGraphDynamicShapeAttr(const std::vector<KernelGraphPtr> &all_graphs) {
|
||||
bool is_dynamic = false;
|
||||
for (const auto &graph : all_graphs) {
|
||||
UpdateGraphDynamicShapeAttr(NOT_NULL(graph));
|
||||
is_dynamic = graph->is_dynamic_shape() || is_dynamic;
|
||||
}
|
||||
if (is_dynamic && all_graphs.size() > 1) {
|
||||
MS_LOG(EXCEPTION) << "Dynamic shape is not supported with control flow.";
|
||||
}
|
||||
}
|
||||
|
||||
void SessionBasic::UpdateGraphDynamicShapeAttr(const NotNull<KernelGraphPtr> &root_graph) {
|
||||
for (const auto &cnode : root_graph->execution_order()) {
|
||||
auto output_dynamic = IsNodeOutputDynamicShape(NOT_NULL(cnode));
|
||||
|
|
|
@ -183,6 +183,7 @@ class SessionBasic : public std::enable_shared_from_this<SessionBasic> {
|
|||
void InitInternalOutputParameter(const AnfNodePtr &out_node, const AnfNodePtr ¶meter);
|
||||
AnfNodePtr FindPullNode(const AnfNodePtr &push_node, const std::vector<AnfNodePtr> &node_list);
|
||||
void UpdateGraphDynamicShapeAttr(const NotNull<KernelGraphPtr> &root_graph);
|
||||
void UpdateAllGraphDynamicShapeAttr(const std::vector<KernelGraphPtr> &all_graphs);
|
||||
|
||||
std::unordered_map<GraphId, std::shared_ptr<KernelGraph>> graphs_;
|
||||
std::unordered_map<GraphInfo, std::shared_ptr<KernelGraph>> run_op_graphs_;
|
||||
|
|
Loading…
Reference in New Issue