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
[Feature][Relax][ONNX] Support LpNormalization operator in Relax ONNX frontend #20969
Support the ONNX LpNormalization operator in the Apache TVM Relax ONNX frontend (python/tvm/relax/frontend/onnx/onnx_frontend.py).
Motivation
LpNormalization computes $ vector normalization (most commonly $ or $ norm) along a specified axis. It is universally used as the final projection layer in text embedding, multi-modal embedding, and vector retrieval models (such as BGE, E5, OpenAI CLIP, and sentence-transformers) to normalize feature vectors onto the unit sphere for cosine similarity and vector search.
Importing embedding models containing LpNormalization currently fails in the Relax ONNX frontend with:
NotImplementedError: The following operators are not supported: ['LpNormalization']
This operator was also highlighted in the ONNX operator coverage RFC tracking issue #20124 under Activations / Math operators.
Operator Specification (ONNX Opset 1+)
Inputs:
input: N-D input tensor of floating-point type (float32, float16, bfloat16).
Attributes:
axis: int (default -1) - the axis along which the norm is computed.
p: int (default 2) - the order of the norm (=1$ for $, =2$ for $).
Outputs:
output: Normalized tensor with identical shape and dtype as input.
Expected Behavior
The Relax ONNX frontend should implement LpNormalization using Relax arithmetic operations:
For =2$: compute norm = relax.op.sqrt(relax.op.sum(relax.op.square(input), axis=axis, keepdims=True)) and return relax.op.divide(input, norm) (with safe numerical epsilon).
For =1$: compute norm = relax.op.sum(relax.op.abs(input), axis=axis, keepdims=True) and return relax.op.divide(input, norm).
Activity