Skip to content

Commit

Permalink
Refine tests. (#553)
Browse files Browse the repository at this point in the history
1. Remove "osx" from .travis.yml temporarily.
2. Make the tests run locally.
3. Add a simple test generator which create a test file for the tuple <source_framework, target_framework, model_name>
  • Loading branch information
linmajia committed Jan 8, 2019
1 parent 13ba9a0 commit e682d87
Show file tree
Hide file tree
Showing 15 changed files with 497 additions and 44 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ dist: xenial

os:
- linux
- osx

language: python
python:
Expand Down Expand Up @@ -66,7 +65,6 @@ matrix:
fast_finish: true

allow_failures:
- os: osx
- env: TEST_PARSER=paddle TEST_ONNX=true
- env: TEST_PARSER=paddle TEST_ONNX=false

Expand Down
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ python -m pytest -s -q tests/test_$1.py >> $BUILD_OUTPUT 2>&1
dump_output

# nicely terminate the ping output loop
kill $PING_LOOP_PID
kill $PING_LOOP_PID
44 changes: 39 additions & 5 deletions tests/conversion_imagenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,38 @@
from utils import *


def is_paddle_supported():
if (sys.version_info > (2, 7)):
print('PaddlePaddle does not support Python {0}'.format(sys.version), file=sys.stderr)
return False

return True


def is_coreml_supported():
import sys
if sys.platform == 'darwin':
import platform
ver_str = platform.mac_ver()[0]
if (tuple([int(v) for v in ver_str.split('.')]) >= (10, 13)):
return True

print('CoreML is not supported on your platform.', file=sys.stderr)
return False


def check_env(source_framework, target_framework, model_name):
if ((source_framework == 'paddle') or (target_framework == 'paddle')):
if not is_paddle_supported():
return False

if ((source_framework == 'coreml') or (target_framework == 'coreml')):
if not is_coreml_supported():
return False

return True


class TestModels(CorrectnessTest):

image_path = "mmdnn/conversion/examples/data/seagull.jpg"
Expand Down Expand Up @@ -616,9 +648,7 @@ def prep_for_coreml(prename, BGRTranspose):
# save model
# coremltools.utils.save_spec(model.get_spec(), converted_file)

from coremltools.models.utils import macos_version

if macos_version() < (10, 13):
if not is_coreml_supported():
return None
else:

Expand Down Expand Up @@ -892,8 +922,7 @@ def _need_assert(cls, original_framework, target_framework, network_name, origin
return False

if target_framework == 'coreml':
from coremltools.models.utils import macos_version
if macos_version() < (10, 13):
if not is_coreml_supported():
return False

if target_framework == 'onnx' or target_framework == 'caffe':
Expand All @@ -919,6 +948,11 @@ def _test_function(self, original_framework, parser):
if isinstance(emit, staticmethod):
emit = emit.__func__
target_framework = emit.__name__[:-5]

if (target_framework == 'coreml'):
if not is_coreml_supported():
continue

print('Testing {} from {} to {}.'.format(network_name, original_framework, target_framework), file=sys.stderr)
converted_predict = emit(
original_framework,
Expand Down
Loading

0 comments on commit e682d87

Please sign in to comment.