Skip to content
Permalink
Browse files

Refine tests. (#553)

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 e682d874381d3049db38a6f14c49b407481a5ee0
@@ -3,7 +3,6 @@ dist: xenial

os:
- linux
- osx

language: python
python:
@@ -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

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

@@ -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':
@@ -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,
Oops, something went wrong.

0 comments on commit e682d87

Please sign in to comment.
You can’t perform that action at this time.