diff --git a/mindspore/core/utils/ms_context.cc b/mindspore/core/utils/ms_context.cc index e8d38a22fd6..4ca167444b1 100644 --- a/mindspore/core/utils/ms_context.cc +++ b/mindspore/core/utils/ms_context.cc @@ -119,10 +119,12 @@ std::shared_ptr MsContext::GetInstance() { bool MsContext::set_backend_policy(const std::string &policy) { auto policy_new = policy; +#ifdef ENABLE_D auto enable_ge = mindspore::common::GetEnv("MS_ENABLE_GE"); if (enable_ge == "1") { policy_new = "ge"; } +#endif if (policy_map_.find(policy_new) == policy_map_.end()) { MS_LOG(ERROR) << "invalid backend policy name: " << policy_new; return false; diff --git a/tests/st/model_zoo_tests/resnet50/test_resnet50_cifar10.py b/tests/st/model_zoo_tests/resnet50/test_resnet50_cifar10.py index 1a9bb605718..45765ba4fe6 100644 --- a/tests/st/model_zoo_tests/resnet50/test_resnet50_cifar10.py +++ b/tests/st/model_zoo_tests/resnet50/test_resnet50_cifar10.py @@ -18,7 +18,6 @@ import pytest from mindspore import log as logger from tests.st.model_zoo_tests import utils - @pytest.mark.level2 @pytest.mark.platform_x86_ascend_training @pytest.mark.platform_arm_ascend_training @@ -50,7 +49,6 @@ def test_resnet50_cifar10_ascend(): loss_list.append(loss[-1]) assert sum(loss_list) / len(loss_list) < 0.70 - @pytest.mark.level0 @pytest.mark.platform_x86_gpu_training @pytest.mark.env_single diff --git a/tests/ut/python/nn/test_triu.py b/tests/ut/python/nn/test_triu.py index 9e4c0d8f038..70879c5314d 100644 --- a/tests/ut/python/nn/test_triu.py +++ b/tests/ut/python/nn/test_triu.py @@ -15,6 +15,7 @@ """ test nn.Triu() """ +import os import numpy as np import mindspore.nn as nn @@ -23,21 +24,38 @@ from mindspore import context context.set_context(mode=context.GRAPH_MODE) +class TriuNet(nn.Cell): + def __init__(self): + super(TriuNet, self).__init__() + self.value = Tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) + + def construct(self): + triu = nn.Triu() + return triu(self.value, 0) def test_triu(): - class Net(nn.Cell): - def __init__(self): - super(Net, self).__init__() - self.value = Tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) - - def construct(self): - triu = nn.Triu() - return triu(self.value, 0) - - net = Net() + """ + Feature: None + Description: test TriuNet with vm backend + Expectation: None + """ + net = TriuNet() out = net() assert np.sum(out.asnumpy()) == 26 +def test_triu_ge(): + """ + Feature: unify ge and vm backend + Description: test TriuNet with ge backend + Expectation: None + """ + os.environ['MS_ENABLE_GE'] = "1" + os.environ['MS_GE_TRAIN'] = "0" + net = TriuNet() + out = net() + del os.environ['MS_GE_TRAIN'] + del os.environ['MS_ENABLE_GE'] + assert np.sum(out.asnumpy()) == 26 def test_triu_1(): class Net(nn.Cell): @@ -71,9 +89,6 @@ def test_triu_2(): def test_triu_parameter(): class Net(nn.Cell): - def __init__(self): - super(Net, self).__init__() - def construct(self, x): triu = nn.Triu() return triu(x, 0) @@ -84,9 +99,6 @@ def test_triu_parameter(): def test_triu_parameter_1(): class Net(nn.Cell): - def __init__(self): - super(Net, self).__init__() - def construct(self, x): triu = nn.Triu() return triu(x, 1) @@ -97,9 +109,6 @@ def test_triu_parameter_1(): def test_triu_parameter_2(): class Net(nn.Cell): - def __init__(self): - super(Net, self).__init__() - def construct(self, x): triu = nn.Triu() return triu(x, -1) diff --git a/tests/ut/python/pipeline/parse/test_for_stmt.py b/tests/ut/python/pipeline/parse/test_for_stmt.py index 748c73e8738..67d94b081cb 100644 --- a/tests/ut/python/pipeline/parse/test_for_stmt.py +++ b/tests/ut/python/pipeline/parse/test_for_stmt.py @@ -13,6 +13,7 @@ # limitations under the License. # ============================================================================ """ test_for_stmt """ +import os from dataclasses import dataclass import numpy as np @@ -91,6 +92,15 @@ def test_op_seq_test(): input_me = Tensor(input_np) net(input_me) +def test_op_seq_test_ge(): + """ + Feature: unify ge and vm backend + Description: test op seq with ge backend + Expectation: None + """ + os.environ['MS_ENABLE_GE'] = "1" + test_op_seq_test() + del os.environ['MS_ENABLE_GE'] _grad_fusion = C.MultitypeFuncGraph("grad_fushion") @@ -124,3 +134,13 @@ def test_allreduce_fushio_test(): input_np = np.random.randn(2, 3, 4, 5).astype(np.float32) input_me = Tensor(input_np) net(input_me) + +def test_allreduce_fushio_test_ge(): + """ + Feature: unify ge and vm backend + Description: test allreduce fushio with ge backend + Expectation: None + """ + os.environ['MS_ENABLE_GE'] = "1" + test_allreduce_fushio_test() + del os.environ['MS_ENABLE_GE']