diff --git a/mindspore/ccsrc/runtime/graph_scheduler/graph_compiler.cc b/mindspore/ccsrc/runtime/graph_scheduler/graph_compiler.cc index bad1061cf73..f984a4b41b0 100644 --- a/mindspore/ccsrc/runtime/graph_scheduler/graph_compiler.cc +++ b/mindspore/ccsrc/runtime/graph_scheduler/graph_compiler.cc @@ -429,6 +429,7 @@ GraphId GraphCompiler::CompileGraph(const FuncGraphPtr &func_graph, const Device // The graph common optimization. opt::BackendCommonOptimization(root_graph); + root_graph->SetInputNodes(); auto graph_id = CompileGraphImpl(root_graph, device_context); diff --git a/tests/st/pynative/ms_function/test_pynative_ms_function.py b/tests/st/pynative/ms_function/test_pynative_ms_function.py index 4002eee516e..324b116de09 100644 --- a/tests/st/pynative/ms_function/test_pynative_ms_function.py +++ b/tests/st/pynative/ms_function/test_pynative_ms_function.py @@ -383,3 +383,36 @@ def test_pynative_ms_function_with_dynamic_shape(): x = Tensor([[1, 1, 2], [3, 3, 5]], ms.int32) output = test(x) assert (output[0].asnumpy() == np.array([1, 2, 3, 5])).all() + + +@pytest.mark.level0 +@pytest.mark.platform_x86_cpu +@pytest.mark.platform_arm_ascend_training +@pytest.mark.platform_x86_ascend_training +@pytest.mark.platform_x86_gpu_training +@pytest.mark.env_onecard +def test_pynative_ms_function_with_tuple_inputs(): + """ + Feature: PyNative ms_function. + Description: PyNative ms_function with tuple inputs. + Expectation: The calculation result is correct. + """ + + class Net(nn.Cell): + def __init__(self): + super(Net, self).__init__() + self.enable_tuple_broaden = True + + @ms_function + def construct(self, grads): + new_grads = [] + for grad in grads: + new_grads.append(grad + 1) + return new_grads + + + x = Tensor(np.ones([2, 2]), dtype=ms.int32) + y = Tensor(np.ones([2, 2]), dtype=ms.int32) + net = Net() + out = net((x, y)) + assert (out[0].asnumpy() == np.ones([2, 2]) + 1).all()