fix isolate node bug when using fallback interpret node

This commit is contained in:
lianliguang 2022-03-25 11:15:47 +08:00
parent 0209377062
commit 3d7c56c4cc
2 changed files with 17 additions and 1 deletions

View File

@ -645,7 +645,8 @@ FunctionBlockPtr Parser::ParseExpr(const FunctionBlockPtr &block, const py::obje
<< ", block: " << block << "/"
<< (block->func_graph() ? block->func_graph()->ToString() : "FG(Null)")
<< ", Line: " << trace::GetDebugInfo(no_return_node->debug_info(), "", kSourceLineTipDiscard);
block->AddIsolatedNode(no_return_node);
auto isolated_node = HandleInterpret(block, no_return_node, value_object);
block->AddIsolatedNode(isolated_node);
} else {
// Expand the assign statement,
// e.g.: x.append(y) -> x = x.append(y)

View File

@ -147,3 +147,18 @@ def test_fallback_abs_ms_function_tensor():
return x
assert np.allclose(foo().asnumpy(), abs(np.array([-1, 2, -3])))
def test_fallback_isolated_node():
"""
Feature: JIT Fallback
Description: Test abs(Tensor) the tensor is construct in ms_function
Expectation: No exception
"""
@ms_function
def foo():
a = abs(-1)
abs(2)
return a
assert foo() == 1