!9769 add testcases of type error
From: @echo_hua Reviewed-by: @chujinjin,@zhunaipan Signed-off-by: @zhunaipan
This commit is contained in:
commit
da74482812
|
@ -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__()
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue