Skip to content

Commit

Permalink
Fix opset with type long not recognized as integer in Python 2 issue (#…
Browse files Browse the repository at this point in the history
…181)

* Fix opset with type long not recognized as integer in Python 2 issue

* Update frontend.py

* Update frontend.py

* fix another occurence
  • Loading branch information
tjingrant authored May 17, 2018
1 parent 8400226 commit 2ac0530
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions onnx_tf/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@
import importlib
import inspect
from itertools import chain
import sys
import warnings

import numpy as np
import tensorflow as tf
from tensorflow.python.framework.tensor_util import MakeNdarray
from tensorflow.core.framework.attr_value_pb2 import AttrValue

# Define long type for Python 3:
if sys.version_info > (3,):
long = int

from onnx_tf.common import (
TF_TYPE_TO_ONNX_TYPE,
TF_OP_STR_TO_ONNX_OP,
Expand Down Expand Up @@ -234,7 +239,7 @@ def tensorflow_graph_to_onnx_graph(cls,
opset_dict[domain] = version
defs.ONNX_DOMAIN = domain
assert isinstance(
version, int
version, (int, long)
) and (version <= defs.onnx_opset_version()) and (
version >= 0
), "Opset should be an int less than or equal to {}, but {}: {}".format(
Expand Down Expand Up @@ -412,10 +417,10 @@ def get_node_by_name(nodes, name):

assert isinstance(
opset,
(int, list,
(int, long, list,
tuple)), "opset is expected to int, list or tuple, but {}.".format(
type(opset))
if isinstance(opset, int):
if isinstance(opset, (int, long)):
if opset == 0:
opset = defs.onnx_opset_version()
opset = [("", opset)]
Expand Down

0 comments on commit 2ac0530

Please sign in to comment.