Browse Source

!12904 intercept env in validate

From: @Margaret_wangrui
Reviewed-by: @hwhewei,@zh_qh
Signed-off-by: @zh_qh
tags/v1.2.0-rc1
mindspore-ci-bot Gitee 5 years ago
parent
commit
778d4e8809
1 changed files with 29 additions and 25 deletions
  1. +29
    -25
      mindspore/ccsrc/pipeline/jit/validator.cc

+ 29
- 25
mindspore/ccsrc/pipeline/jit/validator.cc View File

@@ -66,23 +66,14 @@ void ValidateOperation(const AnfNodePtr &node) {
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();
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>()) {
TypePtr ptrType = ptrBase->GetTypeTrack();
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>()) {
// only send string in external
if (!IsValueNode<StringImm>(node)) {
@@ -91,26 +82,39 @@ void ValidateAbstract(const AnfNodePtr &node) {
<< " 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;
}
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;
}

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;
}

if (ptrBase->isa<abstract::AbstractNone>()) {
if (ptrBase->isa<AbstractError>()) {
// NOTICE: validate dead code?
MS_LOG(DEBUG) << "AbstractError in the graph: " << ptrBase->ToString();
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;
}



Loading…
Cancel
Save