check invalid internal output

This commit is contained in:
kswang 2020-07-17 19:35:34 +08:00
parent 11732f0ea2
commit 11f78fb8ad
1 changed files with 10 additions and 0 deletions

View File

@ -978,6 +978,16 @@ CNodePtr SessionBasic::ConstructOutput(const AnfNodePtrList &outputs, const std:
bool internal_output = true;
std::string kernel_target = GetCNodeTarget(front_real_kernel.first);
for (auto user : users) {
auto cnode = user.first->cast<CNodePtr>();
if (cnode == nullptr) {
internal_output = false;
break;
}
auto prim = cnode->input(kAnfPrimitiveIndex);
if (prim == nullptr || !prim->isa<ValueNode>()) {
internal_output = false;
break;
}
if (!AnfAlgo::IsRealKernel(user.first) || kernel_target != GetCNodeTarget(user.first)) {
internal_output = false;
break;