From b4ecf65e71febcb4b224b889b0e0f4f4030d21c8 Mon Sep 17 00:00:00 2001 From: wanghua Date: Thu, 10 Dec 2020 14:29:17 +0800 Subject: [PATCH] add typeerror testcases --- .../test_pynative_control_flow.py | 2 +- .../pynative/parser/test_parser_construct.py | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/st/pynative/dynamic_shape/test_pynative_control_flow.py b/tests/st/pynative/dynamic_shape/test_pynative_control_flow.py index 9a1ee9fa13..95ea24bbe0 100644 --- a/tests/st/pynative/dynamic_shape/test_pynative_control_flow.py +++ b/tests/st/pynative/dynamic_shape/test_pynative_control_flow.py @@ -41,7 +41,7 @@ class GradofAllInputsAndParams(nn.Cell): @pytest.mark.platform_arm_ascend_training @pytest.mark.platform_x86_ascend_training @pytest.mark.env_onecard -def test_pynative_diff_shape_with_while_in_construct(): +def test_sit_pynative_diff_shape_with_while_in_construct(): class WhileNetMs(nn.Cell): def __init__(self): super().__init__() diff --git a/tests/st/pynative/parser/test_parser_construct.py b/tests/st/pynative/parser/test_parser_construct.py index 65d8cace8e..5206518908 100644 --- a/tests/st/pynative/parser/test_parser_construct.py +++ b/tests/st/pynative/parser/test_parser_construct.py @@ -20,6 +20,7 @@ from mindspore.nn import Cell from mindspore.common.tensor import Tensor from mindspore.ops import operations as P from mindspore.ops.composite import GradOperation +from mindspore.common.parameter import Parameter def setup_module(): context.set_context(mode=context.PYNATIVE_MODE, device_target="Ascend") @@ -68,3 +69,22 @@ def test_parser_construct(): assert np.allclose(input_np_x, out_me.asnumpy(), 0.001, 0.001) assert np.allclose(input_np_x, grad_me.asnumpy(), 0.001, 0.001) + + +@pytest.mark.level0 +@pytest.mark.platform_arm_ascend_training +@pytest.mark.platform_x86_ascend_training +@pytest.mark.env_onecard +def test_sit_parser_input_parameter(): + def tensor_add(x, y): + add = P.TensorAdd() + z = add(x, y) + return z + x = Tensor(np.ones([2, 2]).astype(np.float32)) + x = Parameter(x, name="x") + y = Tensor(np.ones([2, 2]).astype(np.float32)) + y = Parameter(y, name="y") + grad = GradOperation(get_all=True, get_by_list=False, sens_param=False) + + with pytest.raises(TypeError): + grad(tensor_add)(x, y)