fix testcases - PopulationCount and ApproximateEqual cpu

This commit is contained in:
TinaMengtingZhang 2022-08-02 21:18:56 +00:00
parent 740c749bc9
commit 0509c4cec8
2 changed files with 27 additions and 8 deletions

View File

@ -85,6 +85,9 @@ def test_approxmiate_equal_docs():
assert(output.asnumpy() == expect).all()
@pytest.mark.level0
@pytest.mark.platform_x86_cpu
@pytest.mark.env_onecard
def test_approxmiate_equal_different_shape():
r"""
Feature: test ops ApproximateEqual.
@ -99,6 +102,9 @@ def test_approxmiate_equal_different_shape():
approx_equal.change_xy(Tensor(x1), Tensor(x2))
@pytest.mark.level0
@pytest.mark.platform_x86_cpu
@pytest.mark.env_onecard
def test_approxmiate_equal_tol_not_float():
r"""
Feature: test ops ApproximateEqual.
@ -113,6 +119,9 @@ def test_approxmiate_equal_tol_not_float():
approx_equal.change_xy(Tensor(x1), Tensor(x2))
@pytest.mark.level0
@pytest.mark.platform_x86_cpu
@pytest.mark.env_onecard
def test_approxmiate_equal_max_rank():
r"""
Feature: test ops ApproximateEqual.
@ -129,6 +138,9 @@ def test_approxmiate_equal_max_rank():
approx_equal.change_xy(Tensor(x1), Tensor(x2))
@pytest.mark.level0
@pytest.mark.platform_x86_cpu
@pytest.mark.env_onecard
def test_approxmiate_equal_diff_dtype():
r"""
Feature: test ops ApproximateEqual.
@ -145,6 +157,9 @@ def test_approxmiate_equal_diff_dtype():
assert(output.asnumpy() == expect).all()
@pytest.mark.level0
@pytest.mark.platform_x86_cpu
@pytest.mark.env_onecard
def test_approxmiate_equal_tensor_api():
r"""
Feature: test ops ApproximateEqual on tensor API.
@ -168,6 +183,9 @@ def test_approxmiate_equal_tensor_api():
assert(output.asnumpy() == expect).all()
@pytest.mark.level0
@pytest.mark.platform_x86_cpu
@pytest.mark.env_onecard
def test_approxmiate_equal_functional_api():
r"""
Feature: test ops ApproximateEqual on functional API.

View File

@ -13,6 +13,7 @@
# limitations under the License.
# ============================================================================
import pytest
import numpy as np
import mindspore.context as context
import mindspore.nn as nn
@ -32,25 +33,25 @@ class Net(nn.Cell):
return self.population_count(x0)
@pytest.mark.level0
@pytest.mark.platform_x86_cpu
@pytest.mark.env_onecard
def test16_net():
x = Tensor(np.array([13, 65]), mstype.int16)
print("x:\n", x)
pc = Net()
output = pc(x)
print("x:\n", output)
expect_x_result = [4, 7]
print("expected_x:\n", expect_x_result)
expect_x_result = [3, 2]
assert (output.asnumpy() == expect_x_result).all()
@pytest.mark.level0
@pytest.mark.platform_x86_cpu
@pytest.mark.env_onecard
def test8_net():
x = Tensor(np.array([13, 65]), mstype.int8)
pc = Net()
output = pc(x)
print("x:\n", output)
expect_x_result = [4, 7]
print("expected_x:\n", expect_x_result)
expect_x_result = [3, 2]
assert (output.asnumpy() == expect_x_result).all()