From d0d46b78da94d7bc6112854ef596a401f0bd57c5 Mon Sep 17 00:00:00 2001 From: lianliguang Date: Mon, 7 Jun 2021 15:00:43 +0800 Subject: [PATCH] fix make tuple abstract error --- .../backend/session/anf_runtime_algorithm.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/mindspore/ccsrc/backend/session/anf_runtime_algorithm.cc b/mindspore/ccsrc/backend/session/anf_runtime_algorithm.cc index 786b37da9a3..ac0705d9d95 100644 --- a/mindspore/ccsrc/backend/session/anf_runtime_algorithm.cc +++ b/mindspore/ccsrc/backend/session/anf_runtime_algorithm.cc @@ -1050,13 +1050,17 @@ void AnfRuntimeAlgorithm::SetOutputTypeAndDetailShape(const std::vector MS_EXCEPTION_IF_NULL(node); auto node_ptr = node->cast(); MS_EXCEPTION_IF_NULL(node_ptr); + std::string node_name = ""; + if (node_ptr->isa()) { + node_name = GetCNodeName(node_ptr); + } if (types.size() != shapes.size()) { MS_LOG(EXCEPTION) << "Types size " << types.size() << "should be same with shapes size " << shapes.size() << " trace: " << trace::DumpSourceLines(node); } - if (shapes.empty()) { + if (shapes.empty() && node_name != prim::kPrimMakeTuple->name()) { node->set_abstract(std::make_shared()); - } else if (shapes.size() == 1) { + } else if (shapes.size() == 1 && node_name != prim::kPrimMakeTuple->name()) { // single output handle auto abstract = std::make_shared(TypeIdToType(types[0]), shapes[0]); node->set_abstract(abstract); @@ -1077,15 +1081,19 @@ void AnfRuntimeAlgorithm::SetOutputInferTypeAndShape(const std::vector & const std::vector> &shapes, AnfNode *node) { MS_EXCEPTION_IF_NULL(node); auto node_ptr = node->cast(); + std::string node_name = ""; + if (node_ptr->isa()) { + node_name = GetCNodeName(node_ptr); + } MS_EXCEPTION_IF_NULL(node_ptr); if (types.size() != shapes.size()) { MS_LOG(EXCEPTION) << "Types size " << types.size() << "should be same with shapes size " << shapes.size() << " trace: " << trace::DumpSourceLines(node); } auto abstract_ptr = node_ptr->abstract(); - if (shapes.empty()) { + if (shapes.empty() && node_name != prim::kPrimMakeTuple->name()) { node->set_abstract(std::make_shared()); - } else if (shapes.size() == 1) { + } else if (shapes.size() == 1 && node_name != prim::kPrimMakeTuple->name()) { // single output handle ShapeVector shape_int; abstract::AbstractTensorPtr abstract = nullptr;