Skip to content

fix: match TensorFlow for empty segments in segment ops #425

fix: match TensorFlow for empty segments in segment ops

fix: match TensorFlow for empty segments in segment ops #425

Workflow file for this run

# Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
name: Unit Test
on:
pull_request:
branches:
- main
paths-ignore:
- '**.md'
push:
branches:
- main
paths-ignore:
- '**.md'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
test:
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-2022']
tf_version: ['2.13.0', '2.15.0']
python_version: ['3.10', '3.11']
opset_version: ['18', '15']
# Single-element lists so existing combinations keep these pins without
# multiplying the matrix; the entries below override them per job.
onnx_version: ['1.16.1']
ort_version: ['1.16.3']
exclude:
# TF 2.13 supports Python 3.8-3.11 only
- tf_version: '2.13.0'
python_version: '3.12'
- tf_version: '2.13.0'
python_version: '3.13'
include:
# --- newer-opset coverage (onnx 1.17) -------------------------------
# The full backend suite converts real ops/models and runs them through
# onnxruntime, so these exercise opset 19-22 end-to-end. onnxruntime
# enforces an opset ceiling on model loading (verified empirically by
# trying to load a minimal opset-N model): ort 1.16.3 -> 19,
# 1.19.2/1.20.1 -> 21, opset 22 needs ort >= 1.21.0 (1.20.1 still
# rejects it), so each entry pins a compatible ort. The opset22 lane
# is further pinned to the latest ort (1.28.0, also verified
# empirically) because ort only gained a LpNormalization(22) kernel
# in 1.25.0; RandomNormal/RandomUniform/Multinomial still have no
# opset-22 kernel as of 1.28.0, so tests hitting those are skipped
# in tests/test_backend.py pending upstream ort support.
- os: 'ubuntu-latest'
tf_version: '2.15.0'
python_version: '3.11'
opset_version: '19'
onnx_version: '1.17.0'
ort_version: '1.19.2'
experimental: true
- os: 'ubuntu-latest'
tf_version: '2.15.0'
python_version: '3.11'
opset_version: '20'
onnx_version: '1.17.0'
ort_version: '1.19.2'
experimental: true
- os: 'ubuntu-latest'
tf_version: '2.15.0'
python_version: '3.11'
opset_version: '21'
onnx_version: '1.17.0'
ort_version: '1.19.2'
experimental: true
- os: 'ubuntu-latest'
tf_version: '2.15.0'
python_version: '3.11'
opset_version: '22'
onnx_version: '1.17.0'
ort_version: '1.28.0'
experimental: true
# --- newer onnx *package* integration (#2446, #2462) ----------------
# Detect API/behaviour incompatibilities with recent onnx releases by
# running the suite against them. Conversion opset is kept modest so the
# produced models stay runnable under the paired ort; the point is to
# exercise the onnx python API (build/checker/shape-inference/optimizer).
# NOTE: setup_test_env.sh pins numpy<2 while these onnx/ort wheels favour
# numpy 2.x, so a failure here may be a numpy-ABI mismatch rather than a
# real onnx-API regression - check the log before acting. These jobs are
# advisory (experimental) so such noise never blocks other PRs.
- os: 'ubuntu-latest'
tf_version: '2.15.0'
python_version: '3.11'
opset_version: '20'
onnx_version: '1.21.0'
ort_version: '1.20.1'
experimental: true
- os: 'ubuntu-latest'
tf_version: '2.15.0'
python_version: '3.11'
opset_version: '20'
onnx_version: '1.22.0'
ort_version: '1.20.1'
experimental: true
runs-on: ${{ matrix.os }}
# Newly added coverage entries are advisory (experimental) so a failure there
# never blocks unrelated PRs; the pre-existing combinations stay required.
continue-on-error: ${{ matrix.experimental || false }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./.github/actions/unit_test
with:
tf_version: ${{ matrix.tf_version }}
python_version: ${{ matrix.python_version }}
ort_version: ${{ matrix.ort_version }}
onnx_version: ${{ matrix.onnx_version }}
opset_version: ${{ matrix.opset_version }}
skip_tflite: 'False'
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: Test Results (${{ matrix.os }}-tf${{ matrix.tf_version }}-py${{ matrix.python_version }}-opset${{ matrix.opset_version }})
path: junit/test-results.xml
publish-test-results:
name: "Publish Tests Results to Github"
needs: [test]
if: always()
permissions:
checks: write
pull-requests: write
uses: ./.github/workflows/publish-test-results.yml
tflite-op-coverage:
# Advisory guard that flags TFLite builtins with no @tfl_op handler
# (tests/test_tflite_op_coverage.py). It is deterministic (pure source
# introspection, no model conversion) and isolated from the test matrix, so
# it can only fail for a PR that actually changes the handled-op set - never
# for unrelated changes. `continue-on-error` keeps it non-blocking while it
# beds in; promote to a required check once the baseline is trusted.
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.11'
- name: Install tf2onnx
run: |
python -m pip install --upgrade pip
# tensorflow and onnxruntime are required even though this test never
# runs a model: tf2onnx imports tensorflow unconditionally at package
# init (verbose_logging), and tests/conftest.py pulls in onnxruntime
# via TestConfig._get_backend_version(), so the guard cannot collect
# without either. Versions are pinned to keep the job deterministic.
pip install "numpy<2" onnx==1.16.1 onnxruntime==1.16.3 flatbuffers packaging parameterized pytest tensorflow==2.15.0
pip install -e .
- name: Run TFLite op coverage guard
env:
TF2ONNX_TFLITE_COVERAGE: '1'
run: python -m pytest tests/test_tflite_op_coverage.py -o addopts="" -v