You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Relax][ONNX] Use ONNX Backend Tests to improve frontend coverage #19505
This is my brain dump for a possible improvement to the Relax ONNX frontend tests.
Currently, many ONNX frontend tests in Relax manually construct small ONNX models and compare the imported Relax program against ONNX Runtime. This makes the test suite somewhat ad-hoc. As coverage grows, it becomes easy to miss ONNX spec corner cases, opset-specific behavior, and edge cases that are already covered by the official ONNX test suite.
ONNX provides an official Backend Test suite, including node-level tests for operator behavior:
I think it would be worth exploring whether Relax's ONNX frontend tests can reuse those tests as a more systematic source of coverage.
The goal is not necessarily to expose TVM as a full ONNX backend. Rather, the idea is to use the ONNX Backend Tests as a testing mechanism for the importer:
improve coverage of ONNX operator semantics
reduce duplicated hand-written operator tests
catch edge cases that are easy to miss with random-input tests
align frontend correctness testing more closely with the ONNX specification
keep TVM-specific frontend tests only for behavior that ONNX Backend Tests do not cover, such as importer options, parameter handling, name sanitization, and Relax-specific integration
Contributions, suggestions, or alternative ideas would be very welcome.
This issue is intended to collect thoughts and discuss whether this direction makes sense before working out a detailed design.
This will really clean up the relax/frontend/onnx workflow. By hooking into the official suite, we can focus entirely on the actual lowering logic and avoid spending time hand-writing tests and making up fake data.
I’d love to take this on and submit a PoC PR for the basic runner.
I've started working on this and have a preliminary PoC ready.
What it does:
Introduces a test runner that feeds ONNX Backend Test node-level cases into relax.frontend.onnx.from_onnx
Compiles the imported Relax module with the VM and compares against ONNX's expected protobuf outputs
Restricts the runner to NodeModel tests only (filters out real/simple/PyTorch model tests via BackendTest._test_items with layout validation)
Adds onnx_backend pytest marker and SKIP_SLOW_TESTS support
Current status:
2406 node tests collected
Representative subset (add, relu, gemm, conv, top_k, optional_get_element) passes; 1 xfail on test_top_k_cpu (dynamic k not yet supported)
Full suite will be run in CI; known xfails are documented per importer gap category
Approach note: ONNX does not expose a public API to select only node tests, so the runner localizes _test_items access in one helper with assertions that fail collection if ONNX changes the internal layout.
I'll submit a Draft PR tonight for early feedback on the integration strategy. The PR will intentionally not fix importer gaps—those will be addressed in follow-ups so each change stays reviewable.
Activity
Aharrypotter commentedon May 5, 2026
Completely agree.
This will really clean up the relax/frontend/onnx workflow. By hooking into the official suite, we can focus entirely on the actual lowering logic and avoid spending time hand-writing tests and making up fake data.
I’d love to take this on and submit a PoC PR for the basic runner.
cc @KJlaccHoeUM9l @junrushao
[Relax][ONNX] Add ONNX Backend Test runner for frontend coverage
Aharrypotter commentedon May 6, 2026
I've started working on this and have a preliminary PoC ready.
What it does:
relax.frontend.onnx.from_onnxNodeModeltests only (filters out real/simple/PyTorch model tests viaBackendTest._test_itemswith layout validation)onnx_backendpytest marker andSKIP_SLOW_TESTSsupportCurrent status:
test_top_k_cpu(dynamic k not yet supported)Approach note: ONNX does not expose a public API to select only node tests, so the runner localizes
_test_itemsaccess in one helper with assertions that fail collection if ONNX changes the internal layout.I'll submit a Draft PR tonight for early feedback on the integration strategy. The PR will intentionally not fix importer gaps—those will be addressed in follow-ups so each change stays reviewable.
cc @KJlaccHoeUM9l @junrushao
[Relax][Frontend][ONNX] Add ONNX Backend Tests runner for systematic …
[Relax][Frontend][ONNX] Add ONNX Backend Tests runner for systematic …
Aharrypotter commentedon May 6, 2026
Update: PR #19515 is up with a working implementation.
What it does
relax.frontend.onnx.from_onnxonnx.backend.base.Backendinterface: import →DecomposeOpsForInference()→LegalizeOps()→detach_params()→tvm.compile()→ VM executionCurrent numbers
Key design points
NodeModeltests only; real/simple/PyTorch model tests filtered outtest_frontend_onnx.pyuntouched — backend tests complement, not replace, TVM-specific testsFeedback welcome.
[Relax][ONNX] Add ONNX Backend Tests for systematic frontend coverage (…
[Relax][ONNX] Support dynamic k in Trilu and expand backend allowlist
[Relax][ONNX] Support dynamic k in Trilu and expand backend allowlist
[Relax][ONNX] Add CastLike support and unblock Relu backend tests
[Relax][ONNX] Support dynamic k in Trilu and expand backend allowlist
[Relax][ONNX] Add CastLike support and unblock Relu backend tests
[Relax][ONNX] Support dynamic k in Trilu and expand backend allowlist
[Relax][ONNX] Add CastLike support and unblock Relu backend tests
[Relax][ONNX] Support dynamic k in Trilu and expand backend allowlist
[Relax][ONNX] Add CastLike support and dynamic-k Trilu to expand back…