Skip to content

[Feature][Relax][ONNX] Support QLinearAdd operator in Relax ONNX frontend #20961

Open

Description

@Chaitanya140904

Description

The ONNX QLinearAdd operator is currently unsupported in TVM Relax's ONNX frontend (python/tvm/relax/frontend/onnx/onnx_frontend.py).

QLinearAdd performs element-wise binary addition on 8-bit quantized tensors with independent scale and zero-point parameters for each input and the output:

C = clip(round(((A - a_zp) * s_a + (B - b_zp) * s_b) / s_c) + c_zp, min_val, max_val)

Key Requirements

  • Support multidirectional numpy-style broadcasting between A and B.
  • Support uint8 and int8 input and output quantization types.
  • Widen to floating-point or fixed-point arithmetic before requantization to avoid intermediate truncation.
  • Output clipping according to the output zero-point type ([0, 255] for uint8, [-128, 127] for int8).
  • Unit tests in tests/python/relax/test_frontend_onnx.py validating against ONNX Runtime.

Triage

  • needs-triage
  • frontend:onnx

Activity

  1. PengYoun9 commented on Nov 18, 2026

    @PengYoun9
    Contributor

    Should we consider distinguishing between symmetric and asymmetric quantization during ONNX frontend parsing, particularly regarding zero-point handling?

    As discussed in [my comment on #20959](#20959 (comment)), when a zero point is statically known to be zero, the corresponding correction operation is mathematically unnecessary.

    For QLinearAdd, this means:

    • The subtraction A - a_zero_point can be omitted when a_zero_point == 0.
    • The subtraction B - b_zero_point can be omitted when b_zero_point == 0.
    • The addition of c_zero_point after requantization can be omitted when c_zero_point == 0.

    Handling both symmetric and asymmetric quantization through the same generic parsing logic may introduce redundant operations into the generated Relax IR, especially for common symmetric INT8 quantization cases.

    It might be worth checking the actual zero-point values during ONNX frontend parsing and generating a simplified expression whenever they are compile-time constants equal to zero, while retaining the general implementation for non-zero or runtime zero points.

    Would it be preferable to handle this optimization directly in the ONNX frontend, or should we rely on subsequent Relax optimization passes to eliminate these redundant operations?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions