Skip to content

Avoid importing testing module from the top level module directly #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/mxnet/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

import collections

import numpy as np

import chainer
import chainer.functions as F
import numpy as np

import chainercv.links as C
import mxnet
import onnx_chainer
Expand Down
4 changes: 2 additions & 2 deletions examples/nnvm/export.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import chainer
import chainer.functions as F
import numpy as np
import onnx

import chainer
import chainer.functions as F
import chainercv.links as C
import nnvm
import onnx_chainer
Expand Down
6 changes: 3 additions & 3 deletions examples/sample_rt.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import numpy as np
import onnxruntime as rt

import chainer
import chainer.links as L
import numpy as np

import onnx_chainer
import onnxruntime as rt
from chainercv import transforms
from PIL import Image

Expand Down
2 changes: 1 addition & 1 deletion onnx_chainer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from onnx_chainer.export import convert_parameter # NOQA
from onnx_chainer.export import export # NOQA

from onnx_chainer import testing # NOQA
from onnx_chainer.export import MINIMUM_OPSET_VERSION # NOQA
9 changes: 5 additions & 4 deletions onnx_chainer/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import collections
import warnings

import chainer
import numpy
import onnx
from onnx.mapping import NP_TYPE_TO_TENSOR_TYPE

import chainer
from onnx_chainer import functions, mapping
from onnx_chainer.testing import test_onnxruntime

try:
from onnx import checker
Expand All @@ -20,6 +19,8 @@
except ImportError:
_available = False

MINIMUM_OPSET_VERSION = 7


def _check_available():
if not _available:
Expand Down Expand Up @@ -197,14 +198,14 @@ def export(model, args, filename=None, export_params=True,

if opset_version is None:
opset_version = int(onnx.defs.onnx_opset_version())
elif opset_version < test_onnxruntime.MINIMUM_OPSET_VERSION:
elif opset_version < MINIMUM_OPSET_VERSION:
warnings.warn(
'ONNX-Chainer has been tested only with opset_version >= {m}. '
'This is because ONNXRuntime supports only opset_version >= {m}. '
'The ONNX file exported with your requested opset_version ({o}) '
'may cause some problems because the converters used for the '
'opset_version have not been tested.'.format(
m=test_onnxruntime.MINIMUM_OPSET_VERSION,
m=MINIMUM_OPSET_VERSION,
o=opset_version)
)

Expand Down
2 changes: 1 addition & 1 deletion onnx_chainer/functions/array.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import chainer
import numpy as np
from onnx import helper
from onnx.mapping import NP_TYPE_TO_TENSOR_TYPE

import chainer
from onnx_chainer import mapping


Expand Down
3 changes: 1 addition & 2 deletions onnx_chainer/functions/connection.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import chainer
import numpy as np
from onnx import helper

import chainer


def convert_Convolution2DFunction(func, onnx_op_name, opset_version,
input_names, output_names, parameters):
Expand Down
3 changes: 1 addition & 2 deletions onnx_chainer/functions/math.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import chainer
import numpy as np
from onnx import helper

import chainer


def convert_Add(func, onnx_op_name, opset_version, input_names, output_names,
parameters):
Expand Down
3 changes: 1 addition & 2 deletions onnx_chainer/functions/noise.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from onnx import helper

import chainer
from onnx import helper


def convert_Dropout(
Expand Down
3 changes: 1 addition & 2 deletions onnx_chainer/functions/normalization.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import sys

from onnx import helper

import chainer
from onnx import helper


def convert_BatchNormalization(func, onnx_op_name, opset_version, input_names,
Expand Down
2 changes: 1 addition & 1 deletion onnx_chainer/testing/test_mxnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import os
import warnings

import chainer
import numpy as np
import onnx

import chainer
import onnx_chainer

try:
Expand Down
2 changes: 1 addition & 1 deletion onnx_chainer/testing/test_onnxruntime.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import warnings

import chainer
import numpy as np
import onnx

import chainer
import onnx_chainer

try:
Expand Down
11 changes: 6 additions & 5 deletions tests/functions_tests/test_activations.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import unittest

import numpy as np
import onnx

import chainer
import chainer.functions as F
import chainer.links as L
import numpy as np
import onnx
from chainer import testing

import onnx_chainer
from onnx_chainer.testing import test_onnxruntime


Expand Down Expand Up @@ -42,7 +43,7 @@ def __call__(self, x):

def test_output(self):
for opset_version in range(
test_onnxruntime.MINIMUM_OPSET_VERSION,
onnx_chainer.MINIMUM_OPSET_VERSION,
onnx.defs.onnx_opset_version() + 1):
test_onnxruntime.check_output(
self.model, self.x, self.fn, opset_version=opset_version)
Expand All @@ -68,7 +69,7 @@ def __call__(self, x):

def test_output(self):
for opset_version in range(
test_onnxruntime.MINIMUM_OPSET_VERSION,
onnx_chainer.MINIMUM_OPSET_VERSION,
onnx.defs.onnx_opset_version() + 1):
test_onnxruntime.check_output(
self.model, self.x, self.fn, opset_version=opset_version)
11 changes: 6 additions & 5 deletions tests/functions_tests/test_arrays.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import unittest

import numpy as np
import onnx

import chainer
import chainer.functions as F
import numpy as np
import onnx
from chainer import testing

import onnx_chainer
from onnx_chainer.testing import test_onnxruntime


Expand Down Expand Up @@ -105,7 +106,7 @@ def __call__(self, x):

def test_output(self):
for opset_version in range(
test_onnxruntime.MINIMUM_OPSET_VERSION,
onnx_chainer.MINIMUM_OPSET_VERSION,
onnx.defs.onnx_opset_version() + 1):
test_onnxruntime.check_output(
self.model, self.x, self.fn, opset_version=opset_version)
Expand Down Expand Up @@ -133,7 +134,7 @@ def __call__(self, x1, x2):

def test_output(self):
for opset_version in range(
test_onnxruntime.MINIMUM_OPSET_VERSION,
onnx_chainer.MINIMUM_OPSET_VERSION,
onnx.defs.onnx_opset_version() + 1):
test_onnxruntime.check_output(
self.model, (self.x1, self.x2), self.fn,
Expand Down
9 changes: 5 additions & 4 deletions tests/functions_tests/test_connections.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import unittest

import numpy as np
import onnx

import chainer
import chainer.links as L
import numpy as np
import onnx
from chainer import testing

import onnx_chainer
from onnx_chainer.testing import test_onnxruntime


Expand Down Expand Up @@ -86,7 +87,7 @@ def __call__(self, x):

def test_output(self):
for opset_version in range(
test_onnxruntime.MINIMUM_OPSET_VERSION,
onnx_chainer.MINIMUM_OPSET_VERSION,
onnx.defs.onnx_opset_version() + 1):
test_onnxruntime.check_output(
self.model, self.x, self.fn, opset_version=opset_version)
11 changes: 6 additions & 5 deletions tests/functions_tests/test_maths.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import unittest

import chainer
import numpy as np
import onnx

import chainer
from chainer import testing

import onnx_chainer
from onnx_chainer.testing import test_onnxruntime


Expand Down Expand Up @@ -47,7 +48,7 @@ def __call__(self, a):

def test_output(self):
for opset_version in range(
test_onnxruntime.MINIMUM_OPSET_VERSION,
onnx_chainer.MINIMUM_OPSET_VERSION,
onnx.defs.onnx_opset_version() + 1):
test_onnxruntime.check_output(
self.model, self.a, self.fn, opset_version=opset_version)
Expand Down Expand Up @@ -86,7 +87,7 @@ def __call__(self, a, b):

def test_output(self):
for opset_version in range(
test_onnxruntime.MINIMUM_OPSET_VERSION,
onnx_chainer.MINIMUM_OPSET_VERSION,
onnx.defs.onnx_opset_version() + 1):
test_onnxruntime.check_output(
self.model, self.x, self.fn, opset_version=opset_version)
Expand Down Expand Up @@ -123,7 +124,7 @@ def __call__(self, a, b, c):

def test_output(self):
for opset_version in range(
test_onnxruntime.MINIMUM_OPSET_VERSION,
onnx_chainer.MINIMUM_OPSET_VERSION,
onnx.defs.onnx_opset_version() + 1):
test_onnxruntime.check_output(
self.model, self.x, self.fn, opset_version=opset_version)
9 changes: 5 additions & 4 deletions tests/functions_tests/test_noises.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import unittest

import numpy as np
import onnx

import chainer
import chainer.functions as F
import numpy as np
import onnx
from chainer import testing

import onnx_chainer
from onnx_chainer.testing import test_onnxruntime


Expand Down Expand Up @@ -33,7 +34,7 @@ def __call__(self, x):

def test_output(self):
for opset_version in range(
test_onnxruntime.MINIMUM_OPSET_VERSION,
onnx_chainer.MINIMUM_OPSET_VERSION,
onnx.defs.onnx_opset_version() + 1):
test_onnxruntime.check_output(
self.model, self.x, self.fn, opset_version=opset_version)
11 changes: 6 additions & 5 deletions tests/functions_tests/test_normalizations.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import unittest

import numpy as np
import onnx

import chainer
import chainer.functions as F
import chainer.links as L
import numpy as np
import onnx
from chainer import testing

import onnx_chainer
from onnx_chainer.testing import test_onnxruntime


Expand Down Expand Up @@ -52,7 +53,7 @@ def __call__(self, x):

def test_output(self):
for opset_version in range(
test_onnxruntime.MINIMUM_OPSET_VERSION,
onnx_chainer.MINIMUM_OPSET_VERSION,
onnx.defs.onnx_opset_version() + 1):
test_onnxruntime.check_output(
self.model, self.x, self.fn, opset_version=opset_version)
Expand Down Expand Up @@ -83,7 +84,7 @@ def __call__(self, x):

def test_output(self):
for opset_version in range(
test_onnxruntime.MINIMUM_OPSET_VERSION,
onnx_chainer.MINIMUM_OPSET_VERSION,
onnx.defs.onnx_opset_version() + 1):
test_onnxruntime.check_output(
self.model, self.x, self.fn, opset_version=opset_version)
11 changes: 6 additions & 5 deletions tests/functions_tests/test_poolings.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import unittest

import numpy as np
import onnx

import chainer
import chainer.functions as F
import numpy as np
import onnx
from chainer import testing

import onnx_chainer
from onnx_chainer.testing import test_onnxruntime


Expand Down Expand Up @@ -35,7 +36,7 @@ def setUp(self):

def test_output(self):
for opset_version in range(
test_onnxruntime.MINIMUM_OPSET_VERSION,
onnx_chainer.MINIMUM_OPSET_VERSION,
onnx.defs.onnx_opset_version() + 1):
test_onnxruntime.check_output(
self.model, self.x, self.fn, opset_version=opset_version)
Expand All @@ -57,7 +58,7 @@ def setUp(self):

def test_output(self):
for opset_version in range(
test_onnxruntime.MINIMUM_OPSET_VERSION,
onnx_chainer.MINIMUM_OPSET_VERSION,
onnx.defs.onnx_opset_version() + 1):
with self.assertRaises(RuntimeError):
test_onnxruntime.check_output(
Expand Down
Loading