| @@ -66,23 +66,14 @@ void ValidateOperation(const AnfNodePtr &node) { | |||||
| MS_LOG(EXCEPTION) << "Illegal primitive: " << prim->name(); | MS_LOG(EXCEPTION) << "Illegal primitive: " << prim->name(); | ||||
| } | } | ||||
| void ValidateAbstract(const AnfNodePtr &node) { | |||||
| if (node == nullptr) { | |||||
| MS_LOG(DEBUG) << "Node to validate is invalid"; | |||||
| return; | |||||
| } | |||||
| bool CheckAbstractScalar(const AnfNodePtr &node) { | |||||
| AbstractBasePtr ptrBase = node->abstract(); | AbstractBasePtr ptrBase = node->abstract(); | ||||
| if (ptrBase == nullptr) { | |||||
| MS_LOG(DEBUG) << "Abstract is null in node: " << node->DebugString(); | |||||
| return; | |||||
| } | |||||
| if (ptrBase->isa<AbstractClass>() || ptrBase->isa<AbstractJTagged>()) { | |||||
| // Validate a type. | |||||
| MS_LOG(EXCEPTION) << "Illegal type in the graph: " << ptrBase->ToString(); | |||||
| } | |||||
| if (ptrBase->isa<AbstractScalar>()) { | if (ptrBase->isa<AbstractScalar>()) { | ||||
| TypePtr ptrType = ptrBase->GetTypeTrack(); | TypePtr ptrType = ptrBase->GetTypeTrack(); | ||||
| MS_EXCEPTION_IF_NULL(ptrType); | MS_EXCEPTION_IF_NULL(ptrType); | ||||
| if (ptrType->isa<EnvType>()) { | |||||
| MS_LOG(EXCEPTION) << "Illegal type in the graph: " << ptrBase->ToString() << " for node=" << node->DebugString(); | |||||
| } | |||||
| if (ptrType->isa<Problem>() || ptrType->isa<External>()) { | if (ptrType->isa<Problem>() || ptrType->isa<External>()) { | ||||
| // only send string in external | // only send string in external | ||||
| if (!IsValueNode<StringImm>(node)) { | if (!IsValueNode<StringImm>(node)) { | ||||
| @@ -91,26 +82,39 @@ void ValidateAbstract(const AnfNodePtr &node) { | |||||
| << " for node=" << node->DebugString(); | << " for node=" << node->DebugString(); | ||||
| } | } | ||||
| } | } | ||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| void ValidateAbstract(const AnfNodePtr &node) { | |||||
| if (node == nullptr) { | |||||
| MS_LOG(DEBUG) << "Node to validate is invalid"; | |||||
| return; | return; | ||||
| } | } | ||||
| if (ptrBase->isa<AbstractError>()) { | |||||
| // NOTICE: validate dead code? | |||||
| MS_LOG(DEBUG) << "AbstractError in the graph: " << ptrBase->ToString(); | |||||
| AbstractBasePtr ptrBase = node->abstract(); | |||||
| if (ptrBase == nullptr) { | |||||
| MS_LOG(DEBUG) << "Abstract is null in node: " << node->DebugString(); | |||||
| return; | return; | ||||
| } | } | ||||
| if (ptrBase->isa<AbstractType>() || ptrBase->isa<AbstractFunction>() || ptrBase->isa<AbstractTuple>() || | |||||
| ptrBase->isa<AbstractList>() || ptrBase->isa<AbstractTensor>() || ptrBase->isa<AbstractRowTensor>() || | |||||
| ptrBase->isa<AbstractSparseTensor>() || ptrBase->isa<abstract::AbstractRefKey>() || ptrBase->isa<AbstractRef>()) { | |||||
| if (ptrBase->isa<AbstractClass>() || ptrBase->isa<AbstractJTagged>()) { | |||||
| // Validate a type. | |||||
| MS_LOG(EXCEPTION) << "Illegal type in the graph: " << ptrBase->ToString() << " for node=" << node->DebugString(); | |||||
| } | |||||
| if (CheckAbstractScalar(node)) { | |||||
| return; | return; | ||||
| } | } | ||||
| if (ptrBase->isa<abstract::AbstractNone>()) { | |||||
| if (ptrBase->isa<AbstractError>()) { | |||||
| // NOTICE: validate dead code? | |||||
| MS_LOG(DEBUG) << "AbstractError in the graph: " << ptrBase->ToString(); | |||||
| return; | return; | ||||
| } | } | ||||
| // UMonad or IOMonad | |||||
| if (ptrBase->isa<abstract::AbstractMonad>()) { | |||||
| bool checkAbstractIslegal = | |||||
| ptrBase->isa<AbstractType>() || ptrBase->isa<AbstractFunction>() || ptrBase->isa<AbstractTuple>() || | |||||
| ptrBase->isa<AbstractList>() || ptrBase->isa<AbstractTensor>() || ptrBase->isa<AbstractRowTensor>() || | |||||
| ptrBase->isa<AbstractSparseTensor>() || ptrBase->isa<abstract::AbstractRefKey>() || ptrBase->isa<AbstractRef>() || | |||||
| ptrBase->isa<abstract::AbstractNone>() || ptrBase->isa<abstract::AbstractMonad>(); | |||||
| if (checkAbstractIslegal) { | |||||
| return; | return; | ||||
| } | } | ||||