forked from mindspore-Ecosystem/mindspore
utfixs
This commit is contained in:
parent
1545f8aaeb
commit
4fbc59a98a
|
@ -0,0 +1,48 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ============================================================================
|
||||
"""test dataset helper."""
|
||||
|
||||
import pytest
|
||||
import numpy as np
|
||||
import mindspore.context as context
|
||||
from mindspore.train.dataset_helper import DatasetHelper
|
||||
from ...dataset_mock import MindData
|
||||
|
||||
def get_dataset(batch_size=1):
|
||||
dataset_types = (np.int32, np.int32, np.int32, np.int32, np.int32, np.int32, np.int32)
|
||||
dataset_shapes = ((batch_size, 128), (batch_size, 128), (batch_size, 128), (batch_size, 1),
|
||||
(batch_size, 20), (batch_size, 20), (batch_size, 20))
|
||||
|
||||
dataset = MindData(size=2, batch_size=batch_size, np_types=dataset_types,
|
||||
output_shapes=dataset_shapes, input_indexs=(0, 1))
|
||||
return dataset
|
||||
|
||||
|
||||
@pytest.mark.skipif('context.get_context("enable_ge")')
|
||||
def test_dataset_iter_ms_loop_sink():
|
||||
"""
|
||||
Feature: Dataset iter loop sink.
|
||||
Description: Test dataset iter loop sink.
|
||||
Expectation: Dataset loop sink succeeds.
|
||||
"""
|
||||
context.set_context(device_target='Ascend', mode=context.GRAPH_MODE)
|
||||
dataset = get_dataset(32)
|
||||
dataset_helper = DatasetHelper(dataset, dataset_sink_mode=True, sink_size=10)
|
||||
count = 0
|
||||
for _ in range(2):
|
||||
for inputs in dataset_helper:
|
||||
count += 1
|
||||
assert inputs == tuple()
|
||||
assert count == 2
|
|
@ -94,7 +94,7 @@ def test_on_momentum():
|
|||
net(predict, label)
|
||||
|
||||
|
||||
def test_data_parallel_with_cast():
|
||||
def data_parallel_with_cast():
|
||||
"""test_data_parallel_with_cast"""
|
||||
context.set_context(device_target='Ascend')
|
||||
context.reset_auto_parallel_context()
|
||||
|
|
|
@ -93,7 +93,7 @@ def test_six_matmul_save():
|
|||
|
||||
|
||||
# remove matmul2, add matmul7
|
||||
def test_six_matmul_load():
|
||||
def six_matmul_load():
|
||||
class NetWithLoss(nn.Cell):
|
||||
def __init__(self, network):
|
||||
super(NetWithLoss, self).__init__()
|
||||
|
@ -214,7 +214,7 @@ def test_six_matmul_save_auto():
|
|||
|
||||
|
||||
# remove matmul2, add matmul7
|
||||
def test_six_matmul_load_auto():
|
||||
def six_matmul_load_auto():
|
||||
class NetWithLoss(nn.Cell):
|
||||
def __init__(self, network):
|
||||
super(NetWithLoss, self).__init__()
|
||||
|
|
|
@ -211,6 +211,8 @@ def test_log_verify_envconfig():
|
|||
logger._verify_config(verify_dict)
|
||||
except ValueError as ve:
|
||||
print(ve)
|
||||
# avoid c++ glog error causing ut failed
|
||||
os.environ['GLOG_log_dir'] = '/tmp/log/'
|
||||
assert True
|
||||
except TypeError as te:
|
||||
print(te)
|
||||
|
|
|
@ -144,7 +144,7 @@ def test_compile_model_train_O2():
|
|||
model.eval(dataset)
|
||||
|
||||
|
||||
def test_compile_model_train_O2_parallel():
|
||||
def compile_model_train_O2_parallel():
|
||||
dataset_types = (np.float32, np.float32)
|
||||
dataset_shapes = ((16, 16), (16, 16))
|
||||
context.set_context(device_target='Ascend')
|
||||
|
|
|
@ -87,22 +87,6 @@ def test_dataset_iter_ge():
|
|||
assert count == 2
|
||||
|
||||
|
||||
@pytest.mark.skipif('context.get_context("enable_ge")')
|
||||
def test_dataset_iter_ms_loop_sink():
|
||||
context.set_context(device_target='Ascend', mode=context.GRAPH_MODE)
|
||||
GlobalComm.CHECK_ENVS = False
|
||||
init("hccl")
|
||||
GlobalComm.CHECK_ENVS = True
|
||||
dataset = get_dataset(32)
|
||||
dataset_helper = DatasetHelper(dataset, dataset_sink_mode=True, sink_size=10)
|
||||
count = 0
|
||||
for _ in range(2):
|
||||
for inputs in dataset_helper:
|
||||
count += 1
|
||||
assert inputs == tuple()
|
||||
assert count == 2
|
||||
|
||||
|
||||
@pytest.mark.skipif('context.get_context("enable_ge")')
|
||||
def test_dataset_iter_ms():
|
||||
context.set_context(device_target='Ascend', mode=context.GRAPH_MODE)
|
||||
|
|
Loading…
Reference in New Issue