Remove a test case

This commit is contained in:
Margaret_wangrui 2021-11-11 20:33:37 +08:00
parent 846205cdab
commit 46e302f101
2 changed files with 4 additions and 31 deletions

View File

@ -87,6 +87,7 @@ class Parameter(Tensor_):
param_a below is name_a, and the name of param_b is the variable name param_b. param_a below is name_a, and the name of param_b is the variable name param_b.
.. code-block:: .. code-block::
self.param_a = Parameter(Tensor([1], ms.float32), name="name_a") self.param_a = Parameter(Tensor([1], ms.float32), name="name_a")
self.param_b = Parameter(Tensor([2], ms.float32)) self.param_b = Parameter(Tensor([2], ms.float32))
@ -94,6 +95,7 @@ class Parameter(Tensor_):
parameters below are Parameter$1 and Parameter$2. parameters below are Parameter$1 and Parameter$2.
.. code-block:: .. code-block::
self.param_list = [Parameter(Tensor([3], ms.float32)), self.param_list = [Parameter(Tensor([3], ms.float32)),
Parameter(Tensor([4], ms.float32))] Parameter(Tensor([4], ms.float32))]
@ -101,6 +103,7 @@ class Parameter(Tensor_):
will be thrown. For example, "its name 'name_a' already exists." will be thrown. will be thrown. For example, "its name 'name_a' already exists." will be thrown.
.. code-block:: .. code-block::
self.param_a = Parameter(Tensor([1], ms.float32), name="name_a") self.param_a = Parameter(Tensor([1], ms.float32), name="name_a")
self.param_tuple = (Parameter(Tensor([5], ms.float32), name="name_a"), self.param_tuple = (Parameter(Tensor([5], ms.float32), name="name_a"),
Parameter(Tensor([6], ms.float32))) Parameter(Tensor([6], ms.float32)))
@ -109,6 +112,7 @@ class Parameter(Tensor_):
example, the following example will not throw an exception. example, the following example will not throw an exception.
.. code-block:: .. code-block::
self.param_a = Parameter(Tensor([1], ms.float32), name="name_a") self.param_a = Parameter(Tensor([1], ms.float32), name="name_a")
self.param_tuple = (self.param_a, self.param_a) self.param_tuple = (self.param_a, self.param_a)

View File

@ -771,37 +771,6 @@ def test_parameter():
assert output2 == output2_expect assert output2 == output2_expect
@pytest.mark.level1
@pytest.mark.platform_arm_ascend_training
@pytest.mark.platform_x86_gpu_training
@pytest.mark.env_onecard
def test_parameter_same_name():
"""
Feature: Check the names of parameters.
Description: If the same name exists between different parameters, an exception will be thrown.
Expectation: Get the expected exception report.
"""
class ParamNet(Cell):
def __init__(self):
super(ParamNet, self).__init__()
self.param_a = Parameter(Tensor([1], ms.float32), name="name_a")
self.param_b = Parameter(Tensor([2], ms.float32), name="name_b")
self.param_tuple = (Parameter(Tensor([5], ms.float32), name="name_a"),
Parameter(Tensor([6], ms.float32)))
def construct(self, x):
res1 = self.param_a + self.param_b - self.param_tuple[0] + self.param_tuple[1] + x
return res1
with pytest.raises(ValueError, match="its name 'name_a' already exists."):
net = ParamNet()
x = Tensor([10], ms.float32)
output = net(x)
output_expect = Tensor(14, ms.float32)
assert output == output_expect
@pytest.mark.level1 @pytest.mark.level1
@pytest.mark.platform_arm_ascend_training @pytest.mark.platform_arm_ascend_training
@pytest.mark.platform_x86_gpu_training @pytest.mark.platform_x86_gpu_training