Skip to content

Update the way to get opset version for running tests. #2033

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 1 commit into from
Aug 31, 2022
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
3 changes: 1 addition & 2 deletions tests/keras2onnx_unit_tests/test_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

import pytest
import numpy as np
from tf2onnx.keras2onnx_api import get_maximum_opset_supported
from mock_keras2onnx.proto.tfcompat import is_tf2, tensorflow as tf
from mock_keras2onnx.proto import (keras, is_tf_keras,
is_tensorflow_older_than, is_tensorflow_later_than,
is_keras_older_than, is_keras_later_than, python_keras_is_deprecated)
from test_utils import no_loops_in_tf2, all_recurrents_should_bidirectional, convert_keras_for_test as convert_keras
from test_utils import no_loops_in_tf2, all_recurrents_should_bidirectional, convert_keras_for_test as convert_keras, get_max_opset_supported_for_test as get_maximum_opset_supported

K = keras.backend
Activation = keras.layers.Activation
Expand Down
9 changes: 6 additions & 3 deletions tests/keras2onnx_unit_tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from mock_keras2onnx.proto import keras, is_keras_older_than
from mock_keras2onnx.proto.tfcompat import is_tf2
from packaging.version import Version
from tf2onnx.keras2onnx_api import convert_keras
from tf2onnx.keras2onnx_api import convert_keras, get_maximum_opset_supported
import time
import json
import urllib
Expand Down Expand Up @@ -323,10 +323,13 @@ def get_max_opset_supported_by_ort():
return None


def get_max_opset_supported_for_test():
return min(get_max_opset_supported_by_ort(), get_maximum_opset_supported())


def convert_keras_for_test(model, name=None, target_opset=None, **kwargs):
if target_opset is None:
target_opset = get_max_opset_supported_by_ort()

print("Trying to run test with opset version: {}".format(target_opset))

return convert_keras(model=model, name=name, target_opset=target_opset, **kwargs)
return convert_keras(model=model, name=name, target_opset=target_opset, **kwargs)