!30728 add ci test for unify backend

Merge pull request !30728 from xiaoyao/master
This commit is contained in:
i-robot 2022-03-11 01:50:03 +00:00 committed by Gitee
commit a064d0855b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 50 additions and 21 deletions

View File

@ -119,10 +119,12 @@ std::shared_ptr<MsContext> 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;

View File

@ -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

View File

@ -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)

View File

@ -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']