!12904 intercept env in validate

From: @Margaret_wangrui
Reviewed-by: @hwhewei,@zh_qh
Signed-off-by: @zh_qh
pull/12904/MERGE
mindspore-ci-bot 5 years ago committed by Gitee
commit 778d4e8809

@ -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) { bool CheckAbstractScalar(const AnfNodePtr &node) {
if (node == nullptr) {
MS_LOG(DEBUG) << "Node to validate is invalid";
return;
}
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>()) { AbstractBasePtr ptrBase = node->abstract();
// NOTICE: validate dead code? if (ptrBase == nullptr) {
MS_LOG(DEBUG) << "AbstractError in the graph: " << ptrBase->ToString(); MS_LOG(DEBUG) << "Abstract is null in node: " << node->DebugString();
return; return;
} }
if (ptrBase->isa<AbstractClass>() || ptrBase->isa<AbstractJTagged>()) {
if (ptrBase->isa<AbstractType>() || ptrBase->isa<AbstractFunction>() || ptrBase->isa<AbstractTuple>() || // Validate a type.
ptrBase->isa<AbstractList>() || ptrBase->isa<AbstractTensor>() || ptrBase->isa<AbstractRowTensor>() || MS_LOG(EXCEPTION) << "Illegal type in the graph: " << ptrBase->ToString() << " for node=" << node->DebugString();
ptrBase->isa<AbstractSparseTensor>() || ptrBase->isa<abstract::AbstractRefKey>() || ptrBase->isa<AbstractRef>()) { }
if (CheckAbstractScalar(node)) {
return; return;
} }
if (ptrBase->isa<AbstractError>()) {
if (ptrBase->isa<abstract::AbstractNone>()) { // NOTICE: validate dead code?
MS_LOG(DEBUG) << "AbstractError in the graph: " << ptrBase->ToString();
return; return;
} }
bool checkAbstractIslegal =
// UMonad or IOMonad ptrBase->isa<AbstractType>() || ptrBase->isa<AbstractFunction>() || ptrBase->isa<AbstractTuple>() ||
if (ptrBase->isa<abstract::AbstractMonad>()) { 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;
} }

Loading…
Cancel
Save