Skip to content

[FIX][Relax][ONNX] Honor schema defaults and attributes - #20511

Open
Yuhx141 wants to merge 4 commits into
apache:mainfrom
Yuhx141:yuhx/fix-onnx-schema-attrs-20261001
Open

Yuhx141 wants to merge 4 commits into
apache:mainfrom
Yuhx141:yuhx/fix-onnx-schema-attrs-20261001

Conversation

@Yuhx141

@Yuhx141 Yuhx141 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

This aligns three Relax ONNX import paths with the corresponding ONNX schemas:

  • honor ConvTranspose.output_shape by deriving the required spatial padding;
  • use the ONNX default IoU threshold of zero for NonMaxSuppression, and allow zero in the shared TOPI NMS loop;
  • accept Constant's numeric value_float, value_floats, value_int, and value_ints encodings.

Each change has a value-level regression against ONNX Runtime, in addition to the existing structural coverage.

Closes #20505
Closes #20506
Closes #20507

Tests:

  • pytest tests/python/relax/test_frontend_onnx.py -k "conv_transpose or nms or constant_value_attributes" -q (32 passed)

@Yuhx141

Yuhx141 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Hi @tlopex, could you take a look at these Relax/ONNX schema default and attribute fixes when you have a chance? Please let me know if any further changes are needed. Thanks!

@Yuhx141

Yuhx141 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

@tqchen @mshr-h

Could one of you take a look at these ONNX schema-default and attribute correctness fixes when you have a chance, or point me to the right reviewer? I am keen to help get these fixes into TVM and happy to address feedback, add further regression tests, rebase, or split the changes if that would make review easier.

The GitHub Actions checks also seem to need maintainer help with fork-workflow approval or a restart. I would appreciate any guidance on getting the appropriate checks running. Thank you for your time!

@Yuhx141

Yuhx141 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

The five Jenkins checks passed on this head. Could someone take a look at the ONNX schema defaults and attribute fixes when they have a chance?

@mshr-h
mshr-h requested a max review from Copilot November 18, 2026 13:07
@mshr-h mshr-h self-assigned this Nov 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical correctness bugs remain in output_shape padding and zero-threshold NMS, causing shifted output values and incorrect suppression of disjoint boxes.

3 open issues
What changed in this PR

Aligns Relax’s ONNX importer with ONNX schema defaults and attribute encodings, with value-level regression checks against ONNX Runtime.

Changes:

  • Derives ConvTranspose padding from output_shape.
  • Defaults omitted NMS IoU thresholds to zero and enables zero-threshold processing in TOPI.
  • Supports numeric Constant attribute encodings and adds regression tests.
File Description
tests/​python/​relax/​test_frontend_onnx.py Adds numerical regressions and updates structural NMS expectations.
python/​tvm/​topi/​vision/​nms.py Allows zero IoU thresholds into the shared suppression loop.
python/​tvm/​relax/​frontend/​onnx/​onnx_frontend.py Handles output shapes, NMS defaults, and numeric constant attributes.

Review effort: Max

Comment on lines +2285 to +2288
elif auto_pad == "SAME_LOWER" or "pads" not in attr:
pads_begin = [value - value // 2 for value in total_padding]
else:
pads_begin = list(attr.get("pads", [0] * (2 * spatial_dims)))[:spatial_dims]
)

with T.if_(tvm_tirx.tirx.all(iou_threshold > te.const(0), valid_count[i] > te.const(0))):
with T.if_(tvm_tirx.tirx.all(iou_threshold >= te.const(0), valid_count[i] > te.const(0))):
Comment on lines +2506 to +2507
elif "value_floats" in attr:
np_value = _np.asarray(attr.pop("value_floats"), dtype="float32")
Signed-off-by: Yuhx141 <155034285+Yuhx141@users.noreply.github.com>
Signed-off-by: Yuhx141 <155034285+Yuhx141@users.noreply.github.com>
@Yuhx141

Yuhx141 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Hi @mshr-h, thanks for reviewing #20510. Could you take a look at these ONNX attribute and operator fixes too? All eight checks passed on the latest revision. Thanks!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants