Browse Source

MindWizard adapt windows.

tags/v1.2.0-rc1
liuchongming 4 years ago
parent
commit
b528f70f57
2 changed files with 30 additions and 31 deletions
  1. +19
    -20
      tests/st/func/wizard/test_alexnet.py
  2. +11
    -11
      tests/st/func/wizard/test_resnet50.py

+ 19
- 20
tests/st/func/wizard/test_alexnet.py View File

@@ -1,4 +1,4 @@
# Copyright 2020 Huawei Technologies Co., Ltd
# Copyright 2020-2021 Huawei Technologies Co., Ltd
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@@ -101,20 +101,20 @@ class TestAlexNet:
sub_output_dir_list = os.walk(self.output_dir) sub_output_dir_list = os.walk(self.output_dir)
for sub_output_dir in sub_output_dir_list: for sub_output_dir in sub_output_dir_list:
for sub_output_file in sub_output_dir[-1]: for sub_output_file in sub_output_dir[-1]:
content_dir = os.path.relpath(
os.path.join(sub_output_dir[0], sub_output_file),
self.output_dir)
content_dir = os.path.relpath(os.path.join(sub_output_dir[0], sub_output_file),
self.output_dir)


try: try:
with open(os.path.realpath(os.path.join(self.output_dir, content_dir))) as file:
with open(os.path.realpath(os.path.join(self.output_dir, content_dir)), "r",
encoding="utf-8") as file:
content = file.read() content = file.read()
if content_dir == 'src/dataset.py' and dataset_name in content:
if content_dir == os.path.normpath('src/dataset.py') and dataset_name in content:
dataset_is_right = True dataset_is_right = True
elif content_dir == os.path.join('src', NETWORK_NAME.lower() + '.py'): elif content_dir == os.path.join('src', NETWORK_NAME.lower() + '.py'):
network_is_right = True network_is_right = True
elif content_dir == 'src/generator_lr.py':
elif content_dir == os.path.normpath('src/generator_lr.py'):
generator_lr_is_right = True generator_lr_is_right = True
elif content_dir == 'src/config.py':
elif content_dir == os.path.normpath('src/config.py'):
config_dataset_is_right = self._check_config_dataset(config, content) config_dataset_is_right = self._check_config_dataset(config, content)
config_optimizer_is_right = self._check_config_optimizer(config, content) config_optimizer_is_right = self._check_config_optimizer(config, content)
except IOError: except IOError:
@@ -165,15 +165,14 @@ class TestAlexNet:
sub_output_dir_list = os.walk(self.output_dir) sub_output_dir_list = os.walk(self.output_dir)
for sub_output_dir in sub_output_dir_list: for sub_output_dir in sub_output_dir_list:
for sub_output_file in sub_output_dir[-1]: for sub_output_file in sub_output_dir[-1]:
content_dir = os.path.relpath(
os.path.join(sub_output_dir[0], sub_output_file),
self.output_dir)
content_dir = os.path.relpath(os.path.join(sub_output_dir[0], sub_output_file),
self.output_dir)


try: try:
with open(os.path.realpath(os.path.join(self.output_dir, content_dir))) as file:
with open(os.path.realpath(os.path.join(self.output_dir, content_dir)), "r",
encoding="utf-8") as file:
content = file.read() content = file.read()
if content_dir == 'train.py' \
and 'alexnet' in content \
if content_dir == 'train.py' and 'alexnet' in content \
and loss_name in content and optimizer_name in content: and loss_name in content and optimizer_name in content:
train_is_right = True train_is_right = True
elif content_dir == 'eval.py' and 'alexnet' in content and loss_name in content: elif content_dir == 'eval.py' and 'alexnet' in content and loss_name in content:
@@ -205,17 +204,17 @@ class TestAlexNet:
os.path.join(sub_output_dir[0], sub_output_file), os.path.join(sub_output_dir[0], sub_output_file),
self.output_dir) self.output_dir)


if content_dir == 'scripts/run_distribute_train.sh':
if content_dir == os.path.normpath('scripts/run_distribute_train.sh'):
exist_run_distribute_train = True exist_run_distribute_train = True
elif content_dir == 'scripts/run_distribute_train_gpu.sh':
elif content_dir == os.path.normpath('scripts/run_distribute_train_gpu.sh'):
exist_run_distribute_train_gpu = True exist_run_distribute_train_gpu = True
elif content_dir == 'scripts/run_eval.sh':
elif content_dir == os.path.normpath('scripts/run_eval.sh'):
exist_run_eval = True exist_run_eval = True
elif content_dir == 'scripts/run_eval_gpu.sh':
elif content_dir == os.path.normpath('scripts/run_eval_gpu.sh'):
exist_run_eval_gpu = True exist_run_eval_gpu = True
elif content_dir == 'scripts/run_standalone_train.sh':
elif content_dir == os.path.normpath('scripts/run_standalone_train.sh'):
exist_run_standalone_train = True exist_run_standalone_train = True
elif content_dir == 'scripts/run_standalone_train_gpu.sh':
elif content_dir == os.path.normpath('scripts/run_standalone_train_gpu.sh'):
exist_run_standalone_train_gpu = True exist_run_standalone_train_gpu = True


assert exist_run_distribute_train assert exist_run_distribute_train


+ 11
- 11
tests/st/func/wizard/test_resnet50.py View File

@@ -1,4 +1,4 @@
# Copyright 2020 Huawei Technologies Co., Ltd
# Copyright 2020-2021 Huawei Technologies Co., Ltd
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@@ -90,16 +90,16 @@ class TestResNet50:
cross_entorpy_smooth_is_right = False cross_entorpy_smooth_is_right = False
generator_lr_is_right = False generator_lr_is_right = False
for source_file in self.source_files: for source_file in self.source_files:
if source_file.file_relative_path == 'src/dataset.py':
if source_file.file_relative_path == os.path.normpath('src/dataset.py'):
if dataset_name in source_file.content: if dataset_name in source_file.content:
dataset_is_right = True dataset_is_right = True
if source_file.file_relative_path == os.path.join('src', NETWORK_NAME.lower() + '.py'): if source_file.file_relative_path == os.path.join('src', NETWORK_NAME.lower() + '.py'):
network_is_right = True network_is_right = True
if source_file.file_relative_path == 'src/CrossEntropySmooth.py':
if source_file.file_relative_path == os.path.normpath('src/CrossEntropySmooth.py'):
cross_entorpy_smooth_is_right = True cross_entorpy_smooth_is_right = True
if source_file.file_relative_path == 'src/lr_generator.py':
if source_file.file_relative_path == os.path.normpath('src/lr_generator.py'):
generator_lr_is_right = True generator_lr_is_right = True
if source_file.file_relative_path == 'src/config.py':
if source_file.file_relative_path == os.path.normpath('src/config.py'):
content = source_file.content content = source_file.content


config_dataset_is_right = self._check_config_dataset(config, content) config_dataset_is_right = self._check_config_dataset(config, content)
@@ -188,17 +188,17 @@ class TestResNet50:
exist_run_standalone_train_gpu = False exist_run_standalone_train_gpu = False


for source_file in self.source_files: for source_file in self.source_files:
if source_file.file_relative_path == 'scripts/run_distribute_train.sh':
if source_file.file_relative_path == os.path.normpath('scripts/run_distribute_train.sh'):
exist_run_distribute_train = True exist_run_distribute_train = True
if source_file.file_relative_path == 'scripts/run_distribute_train_gpu.sh':
if source_file.file_relative_path == os.path.normpath('scripts/run_distribute_train_gpu.sh'):
exist_run_distribute_train_gpu = True exist_run_distribute_train_gpu = True
if source_file.file_relative_path == 'scripts/run_eval.sh':
if source_file.file_relative_path == os.path.normpath('scripts/run_eval.sh'):
exist_run_eval = True exist_run_eval = True
if source_file.file_relative_path == 'scripts/run_eval_gpu.sh':
if source_file.file_relative_path == os.path.normpath('scripts/run_eval_gpu.sh'):
exist_run_eval_gpu = True exist_run_eval_gpu = True
if source_file.file_relative_path == 'scripts/run_standalone_train.sh':
if source_file.file_relative_path == os.path.normpath('scripts/run_standalone_train.sh'):
exist_run_standalone_train = True exist_run_standalone_train = True
if source_file.file_relative_path == 'scripts/run_standalone_train_gpu.sh':
if source_file.file_relative_path == os.path.normpath('scripts/run_standalone_train_gpu.sh'):
exist_run_standalone_train_gpu = True exist_run_standalone_train_gpu = True


assert exist_run_distribute_train assert exist_run_distribute_train


Loading…
Cancel
Save