Skip to content

Upgrade tf versions. #2369

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

Closed
wants to merge 9 commits into from
Closed
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: 3 additions & 0 deletions .github/actions/keras_application_test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ runs:
pip install numpy==1.19.0
else
pip install transformers
pip install tf_keras
pip install "numpy<2"
fi

Expand All @@ -71,5 +72,7 @@ runs:
run: |
python -c "import onnxruntime"
pytest tests/keras2onnx_unit_tests --doctest-modules --junitxml=junit/test-results.xml

export TF_USE_LEGACY_KERAS=True
cd tests/keras2onnx_applications/nightly_build
python run_all_v2.py
5 changes: 4 additions & 1 deletion .github/actions/keras_unit_test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ runs:
python -m pip install --upgrade pip
pip install onnxconverter-common
pip install onnx==${{ inputs.onnx_version }}
pip install tf_keras
pip install h5py==3.7.0
pip install parameterized
pip install timeout-decorator
Expand All @@ -35,7 +36,8 @@ runs:
pip install "protobuf~=3.20"
if [[ ${{ inputs.tf_version }} == 1.* ]]; then
pip install numpy==1.19.0
else
else
pip install tf_keras
pip install "numpy<2"
fi

Expand All @@ -48,6 +50,7 @@ runs:
shell: bash
if: runner.os == 'Linux'
run: |
export TF_USE_LEGACY_KERAS=True
python -c "import onnxruntime"
python -c "import onnxconverter_common"
pytest tests/keras2onnx_unit_tests --doctest-modules --junitxml=junit/test-results.xml
2 changes: 2 additions & 0 deletions .github/actions/unit_test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ runs:
export TF2ONNX_SKIP_TFLITE_TESTS=${{ inputs.skip_tflite }}
export TF2ONNX_SKIP_TFJS_TESTS=True
export TF2ONNX_SKIP_TF_TESTS=False
export TF_USE_LEGACY_KERAS=True
python -m pytest --cov=tf2onnx --cov-report=term --disable-pytest-warnings -r s tests --cov-append --junitxml=junit/test-results.xml
ls

Expand All @@ -58,5 +59,6 @@ runs:
set TF2ONNX_SKIP_TFLITE_TESTS=${{ inputs.skip_tflite }}
set TF2ONNX_SKIP_TFJS_TESTS=True
set TF2ONNX_SKIP_TF_TESTS=False
set TF_USE_LEGACY_KERAS=True
python -m pytest --cov=tf2onnx --cov-report=term --disable-pytest-warnings -r s tests --cov-append --junitxml=junit/test-results.xml
ls
26 changes: 13 additions & 13 deletions .github/workflows/keras_application_test_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Tests (Py38-TF2.9)
- name: Run Tests (Py38-TF2.12)
uses: ./.github/actions/keras_application_test
with:
tf_version: '2.9.0'
tf_version: '2.12.0'
python_version: '3.8'
ort_version: '1.16.3'
onnx_version: '1.16.1'
Expand All @@ -36,7 +36,7 @@ jobs:
if: always()
uses: actions/upload-artifact@v3
with:
name: Test Results (Py38-TF2.9-ubuntu)
name: Test Results (Py38-TF2.12-ubuntu)
path: ./**/test-results-*.xml

Test_max_py_with_latest_tf: # Do not change this name because it is used in Ruleset of this repo.
Expand All @@ -48,10 +48,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Tests (Py310-TF2.15)
- name: Run Tests (Py310-TF2.18)
uses: ./.github/actions/keras_application_test
with:
tf_version: '2.15.0'
tf_version: '2.18.0'
python_version: '3.10'
ort_version: '1.16.3'
onnx_version: '1.16.1'
Expand All @@ -60,13 +60,13 @@ jobs:
if: always()
uses: actions/upload-artifact@v3
with:
name: Test Results (Py310-TF2.15-ubuntu)
name: Test Results (Py310-TF2.18-ubuntu)
path: ./**/test-results-*.xml

Test_py37_with_tf1_15: # Do not change this name because it is used in Ruleset of this repo.
strategy:
fail-fast: false
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- name: Checkout code
Expand All @@ -92,17 +92,17 @@ jobs:
fail-fast: false
matrix:
name:
- 'py39-tf2.10'
- 'py39-tf2.15'
- 'py39-tf2.17'
- 'py39-tf2.18'
os: ['ubuntu-latest', 'windows-2022']
ort_version: ['1.16.3']
onnx_version: ['1.16.1']
include:
- name: 'py39-tf2.10'
tf_version: '2.10.0'
- name: 'py39-tf2.17'
tf_version: '2.17.0'
python_version: '3.9'
- name: 'py39-tf2.15'
tf_version: '2.15.0'
- name: 'py39-tf2.18'
tf_version: '2.18.0'
python_version: '3.9'
runs-on: ${{ matrix.os }}

Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/keras_unit_test_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Tests (Py38-TF2.9)
- name: Run Tests (Py38-TF2.12)
uses: ./.github/actions/keras_unit_test
with:
tf_version: '2.9.0'
tf_version: '2.13.1'
python_version: '3.8'
ort_version: '1.16.3'
onnx_version: '1.16.1'
Expand All @@ -35,7 +35,7 @@ jobs:
if: always()
uses: actions/upload-artifact@v3
with:
name: Test Results (Py38-TF2.9-ubuntu)
name: Test Results (Py38-TF2.12-ubuntu)
path: ./**/test-results-*.xml

Test_max_py_with_latest_tf: # Do not change this name because it is used in Ruleset of this repo.
Expand All @@ -47,10 +47,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Tests (Py310-TF2.15)
- name: Run Tests (Py310-TF2.18)
uses: ./.github/actions/keras_unit_test
with:
tf_version: '2.15.0'
tf_version: '2.18.0'
python_version: '3.10'
ort_version: '1.16.3'
onnx_version: '1.16.1'
Expand All @@ -59,13 +59,13 @@ jobs:
if: always()
uses: actions/upload-artifact@v3
with:
name: Test Results (Py310-TF2.15-ubuntu)
name: Test Results (Py310-TF2.18-ubuntu)
path: ./**/test-results-*.xml

Test_py37_with_tf1_15: # Do not change this name because it is used in Ruleset of this repo.
strategy:
fail-fast: false
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- name: Checkout code
Expand All @@ -91,17 +91,17 @@ jobs:
fail-fast: false
matrix:
name:
- 'py39-tf2.10'
- 'py39-tf2.15'
- 'py39-tf2.17'
- 'py39-tf2.18'
os: ['ubuntu-latest', 'windows-2022']
ort_version: ['1.16.3']
onnx_version: ['1.16.1']
include:
- name: 'py39-tf2.10'
tf_version: '2.10.0'
- name: 'py39-tf2.17'
tf_version: '2.17.0'
python_version: '3.9'
- name: 'py39-tf2.15'
tf_version: '2.15.0'
- name: 'py39-tf2.18'
tf_version: '2.18.0'
python_version: '3.9'
runs-on: ${{ matrix.os }}

Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/pretrained_model_test_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Tests (Py38-TF2.9-18)
- name: Run Tests (Py38-TF2.12-18)
uses: ./.github/actions/pretrained_model_test
with:
os: 'ubuntu-latest'
tf_version: '2.9.0'
tf_version: '2.13.1'
python_version: '3.8'
ort_version: '1.16.3'
onnx_version: '1.16.1'
Expand All @@ -39,7 +39,7 @@ jobs:
if: always()
uses: actions/upload-artifact@v3
with:
name: Test Results (Py38-TF2.9-18-ubuntu)
name: Test Results (Py38-TF2.12-18-ubuntu)
path: ./**/test-results-*.xml

Test_max_py_with_latest_tf: # Do not change this name because it is used in Ruleset of this repo.
Expand All @@ -51,11 +51,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Tests (Py310-TF2.15-18)
- name: Run Tests (Py310-TF2.18-18)
uses: ./.github/actions/pretrained_model_test
with:
os: 'ubuntu-latest'
tf_version: '2.15.0'
tf_version: '2.18.0'
python_version: '3.10'
ort_version: '1.16.3'
onnx_version: '1.16.1'
Expand All @@ -66,37 +66,37 @@ jobs:
if: always()
uses: actions/upload-artifact@v3
with:
name: Test Results (Py310-TF2.15-18-ubuntu)
name: Test Results (Py310-TF2.18-18-ubuntu)
path: ./**/test-results-*.xml

Extra_tests:
strategy:
fail-fast: false
matrix:
name:
- 'py38-tf2.13'
- 'py39-tf2.15'
os: ['ubuntu-latest', 'windows-2022']
- 'py39-tf2.17'
- 'py39-tf2.18'
os: ['ubuntu-22.04', 'windows-2022']
opset_version: ['18', '15']
ort_version: ['1.16.3']
onnx_version: ['1.16.1']
skip_tflite: ['False']
include:
- name: 'py38-tf2.13'
tf_version: '2.13.0'
tf_version: '2.13.1'
python_version: '3.8'
- name: 'py39-tf2.15'
tf_version: '2.15.0'
- name: 'py39-tf2.18'
tf_version: '2.18.0'
python_version: '3.9'
- name: 'py37-tf1.15'
tf_version: '1.15.5'
python_version: '3.7'
os: 'ubuntu-latest'
os: 'ubuntu-22.04'
opset_version: '15'
ort_version: '1.14.1'
onnx_version: '1.14.1'

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/unit_test_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: ./.github/actions/unit_test
with:
os: 'ubuntu-latest'
tf_version: '2.9.0'
tf_version: '2.13.1'
python_version: '3.8'
ort_version: '1.16.3'
onnx_version: '1.16.1'
Expand All @@ -51,11 +51,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Tests (Py310-TF2.15-18)
- name: Run Tests (Py310-TF2.18-18)
uses: ./.github/actions/unit_test
with:
os: 'ubuntu-latest'
tf_version: '2.15.0'
tf_version: '2.18.0'
python_version: '3.10'
ort_version: '1.16.3'
onnx_version: '1.16.1'
Expand All @@ -66,32 +66,32 @@ jobs:
if: always()
uses: actions/upload-artifact@v3
with:
name: Test Results (Py310-TF2.15-18-ubuntu)
name: Test Results (Py310-TF2.18-18-ubuntu)
path: ./**/test-results-*.xml

Extra_tests:
strategy:
fail-fast: false
matrix:
name:
- 'py38-tf2.13'
- 'py39-tf2.15'
os: ['ubuntu-latest', 'windows-2022']
- 'py38-tf2.17'
- 'py39-tf2.18'
os: ['ubuntu-22.04', 'windows-2022']
opset_version: ['18', '15']
ort_version: ['1.16.3']
onnx_version: ['1.16.1']
skip_tflite: ['False']
include:
- name: 'py38-tf2.13'
tf_version: '2.13.0'
python_version: '3.8'
- name: 'py39-tf2.15'
tf_version: '2.15.0'
- name: 'py39-tf2.17'
tf_version: '2.17.0'
python_version: '3.9'
- name: 'py39-tf2.18'
tf_version: '2.18.0'
python_version: '3.9'
- name: 'py37-tf1.15'
tf_version: '1.15.5'
python_version: '3.7'
os: 'ubuntu-latest'
os: 'ubuntu-22.04'
opset_version: '15'
ort_version: '1.14.1'
onnx_version: '1.14.1'
Expand Down
15 changes: 11 additions & 4 deletions tests/keras2onnx_unit_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

K = keras.backend

def is_keras_3():
return tf.__version__.startswith("2.18") or tf.__version__.startswith("2.17") or tf.__version__.startswith("2.16")

@pytest.fixture(scope='function')
def runner():
Expand All @@ -25,10 +27,15 @@ def runner():
def runner_func(*args, **kwargs):
return run_onnx_runtime(*args, model_files, **kwargs)

# Ensure Keras layer naming is reset for each function
K.reset_uids()
# Reset the TensorFlow session to avoid resource leaking between tests
K.clear_session()
if is_keras_3():
import tf_keras
tf_keras.backend.reset_uids()
tf_keras.backend.clear_session()
else:
# Ensure Keras layer naming is reset for each function
K.reset_uids()
# Reset the TensorFlow session to avoid resource leaking between tests
K.clear_session()

# Provide wrapped run_onnx_runtime function
yield runner_func
Expand Down
2 changes: 2 additions & 0 deletions tests/utils/setup_test_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pip install tensorflow==$TF_VERSION
pip uninstall -y protobuf
pip install "protobuf~=3.20"

pip install tf_keras

python setup.py install

echo "----- List all of depdencies:"
Expand Down
Loading