diff --git a/mindspore/ccsrc/pipeline/jit/validator.cc b/mindspore/ccsrc/pipeline/jit/validator.cc index 9251798fd1b..17426ad4e0b 100644 --- a/mindspore/ccsrc/pipeline/jit/validator.cc +++ b/mindspore/ccsrc/pipeline/jit/validator.cc @@ -66,6 +66,27 @@ void ValidateOperation(const AnfNodePtr &node) { MS_LOG(EXCEPTION) << "Illegal primitive: " << prim->name(); } +bool CheckAbstractScalar(const AnfNodePtr &node) { + AbstractBasePtr ptrBase = node->abstract(); + if (ptrBase->isa()) { + TypePtr ptrType = ptrBase->GetTypeTrack(); + MS_EXCEPTION_IF_NULL(ptrType); + if (ptrType->isa()) { + MS_LOG(EXCEPTION) << "Illegal type in the graph: " << ptrBase->ToString() << " for node=" << node->DebugString(); + } + if (ptrType->isa() || ptrType->isa()) { + // only send string in external + if (!IsValueNode(node)) { + // Validate a type. + MS_LOG(EXCEPTION) << "Illegal type in the graph: " << ptrBase->ToString() + << " for node=" << node->DebugString(); + } + } + return true; + } + return false; +} + void ValidateAbstract(const AnfNodePtr &node) { if (node == nullptr) { MS_LOG(DEBUG) << "Node to validate is invalid"; @@ -78,19 +99,9 @@ void ValidateAbstract(const AnfNodePtr &node) { } if (ptrBase->isa() || ptrBase->isa()) { // Validate a type. - MS_LOG(EXCEPTION) << "Illegal type in the graph: " << ptrBase->ToString(); + MS_LOG(EXCEPTION) << "Illegal type in the graph: " << ptrBase->ToString() << " for node=" << node->DebugString(); } - if (ptrBase->isa()) { - TypePtr ptrType = ptrBase->GetTypeTrack(); - MS_EXCEPTION_IF_NULL(ptrType); - if (ptrType->isa() || ptrType->isa()) { - // only send string in external - if (!IsValueNode(node)) { - // Validate a type. - MS_LOG(EXCEPTION) << "Illegal type in the graph: " << ptrBase->ToString() - << " for node=" << node->DebugString(); - } - } + if (CheckAbstractScalar(node)) { return; } if (ptrBase->isa()) { @@ -98,19 +109,12 @@ void ValidateAbstract(const AnfNodePtr &node) { MS_LOG(DEBUG) << "AbstractError in the graph: " << ptrBase->ToString(); return; } - - if (ptrBase->isa() || ptrBase->isa() || ptrBase->isa() || - ptrBase->isa() || ptrBase->isa() || ptrBase->isa() || - ptrBase->isa() || ptrBase->isa() || ptrBase->isa()) { - return; - } - - if (ptrBase->isa()) { - return; - } - - // UMonad or IOMonad - if (ptrBase->isa()) { + bool checkAbstractIslegal = + ptrBase->isa() || ptrBase->isa() || ptrBase->isa() || + ptrBase->isa() || ptrBase->isa() || ptrBase->isa() || + ptrBase->isa() || ptrBase->isa() || ptrBase->isa() || + ptrBase->isa() || ptrBase->isa(); + if (checkAbstractIslegal) { return; }