From 0509c4cec88bbc296533312d04f633a171dfdc40 Mon Sep 17 00:00:00 2001 From: TinaMengtingZhang Date: Tue, 2 Aug 2022 21:18:56 +0000 Subject: [PATCH] fix testcases - PopulationCount and ApproximateEqual cpu --- tests/st/ops/cpu/test_approximate_equal_op.py | 18 ++++++++++++++++++ tests/st/ops/cpu/test_population_count_op.py | 17 +++++++++-------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/tests/st/ops/cpu/test_approximate_equal_op.py b/tests/st/ops/cpu/test_approximate_equal_op.py index b171e7b0d98..77695479dd5 100644 --- a/tests/st/ops/cpu/test_approximate_equal_op.py +++ b/tests/st/ops/cpu/test_approximate_equal_op.py @@ -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. diff --git a/tests/st/ops/cpu/test_population_count_op.py b/tests/st/ops/cpu/test_population_count_op.py index 389f3fd31c6..b376fdead9f 100644 --- a/tests/st/ops/cpu/test_population_count_op.py +++ b/tests/st/ops/cpu/test_population_count_op.py @@ -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()