Skip to content

[Relax][ONNX] Add LpNormalization converter - #20818

Open
hiyufan wants to merge 1 commit into
apache:mainfrom
hiyufan:feat/onnx-lp-normalization-20124
Open

hiyufan wants to merge 1 commit into
apache:mainfrom
hiyufan:feat/onnx-lp-normalization-20124

Conversation

@hiyufan

@hiyufan hiyufan commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

The Relax ONNX frontend rejects checker-valid LpNormalization models because no converter is registered.

Compose existing Relax operators for L1 and L2 normalization. Honor the default axis=-1 and p=2, use absolute values for L1, and return zero for zero-norm slices. Float16/bfloat16 inputs accumulate and divide in float32 before casting back, avoiding overflow when squaring ordinary float16 values. Other input dtypes are preserved. Reject unsupported values of p.

Related to #20124 (LpNormalization only).

Validation on main e345029c, Python 3.11, LLVM 21.1.8, ONNX 1.23.2 and ONNX Runtime 1.31.0:

  • Before the converter: all 144 valid matrix cases fail to import.
  • After the converter: 150 passed across LpNormalization, InstanceNormalization and MeanVarianceNormalization.
  • The LpNormalization matrix covers opsets 13/22, explicit/default p and axes, float16/float32/float64, static/symbolic shapes, negative values and zero-norm slices. Values and output dtypes are checked against both NumPy and ONNX Runtime. Two additional bfloat16 VM cases use an independent NumPy reference; two cases check invalid p.
  • File-scoped Ruff, ASF header/file-type and whitespace checks passed.

The NumPy L1 reference uses absolute values; ONNX 1.23.2's Python ReferenceEvaluator uses a signed sum for p=1, so it is not used as the oracle.

Prepared with OpenAI Codex assistance. The LLVM build and validation above were executed locally using the pinned TIRx/FFI sources.

CI status: Windows fails during Conda environment setup, before compilation or tests, with the same conda init/Miniforge installation errors on unchanged main. This remains an outstanding validation gap; Jenkins checks are still pending.

@hiyufan
hiyufan marked this pull request as ready for review October 25, 2026 11:27

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

Development

Successfully merging this pull request may close these issues.

1 participant