!8911 add control flow error of dynamic shape

From: @hwjiaorui
Reviewed-by: @jjfeing,@kisnwang
Signed-off-by: @kisnwang
pull/8911/MERGE
mindspore-ci-bot 5 years ago committed by Gitee
commit d1322b62b1

@ -146,8 +146,7 @@ GraphId AscendSession::CompileGraphImpl(NotNull<FuncGraphPtr> func_graph) {
std::vector<KernelGraphPtr> all_graphs; std::vector<KernelGraphPtr> all_graphs;
auto root_graph = ConstructKernelGraph(func_graph, &all_graphs); auto root_graph = ConstructKernelGraph(func_graph, &all_graphs);
// Update Graph Dynamic Shape Attr // Update Graph Dynamic Shape Attr
UpdateGraphDynamicShapeAttr(NOT_NULL(root_graph)); UpdateAllGraphDynamicShapeAttr(all_graphs);
root_graph->UpdateGraphDynamicAttr();
BackendOptimization(all_graphs); BackendOptimization(all_graphs);
// empty graph dont entry to backend // empty graph dont entry to backend
if (root_graph->execution_order().empty()) { if (root_graph->execution_order().empty()) {

@ -1592,6 +1592,17 @@ bool IsNodeInputDynamicShape(const CNodePtr &anf_node_ptr) {
return false; 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) { void SessionBasic::UpdateGraphDynamicShapeAttr(const NotNull<KernelGraphPtr> &root_graph) {
for (const auto &cnode : root_graph->execution_order()) { for (const auto &cnode : root_graph->execution_order()) {
auto output_dynamic = IsNodeOutputDynamicShape(NOT_NULL(cnode)); 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 &parameter); void InitInternalOutputParameter(const AnfNodePtr &out_node, const AnfNodePtr &parameter);
AnfNodePtr FindPullNode(const AnfNodePtr &push_node, const std::vector<AnfNodePtr> &node_list); AnfNodePtr FindPullNode(const AnfNodePtr &push_node, const std::vector<AnfNodePtr> &node_list);
void UpdateGraphDynamicShapeAttr(const NotNull<KernelGraphPtr> &root_graph); 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<GraphId, std::shared_ptr<KernelGraph>> graphs_;
std::unordered_map<GraphInfo, std::shared_ptr<KernelGraph>> run_op_graphs_; std::unordered_map<GraphInfo, std::shared_ptr<KernelGraph>> run_op_graphs_;

Loading…
Cancel
Save