[Feature][Relax][ONNX] Support LpNormalization operator in Relax ONNX frontend

Ouverte
#20,969 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 3 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
67/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
Active
Stack technique
python

Piste de recherche

Start with python/tvm/relax/frontend/onnx/onnx_frontend.py and compare nearby ONNX operator converters to see how they handle attributes and Relax arithmetic. Implement the specified p and axis behavior for supported norm orders, then add or locate frontend tests covering defaults, axes, and output shape and dtype. Done means ONNX models using LpNormalization import and produce the expected normalized values.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Feature Description

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:
    1. 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:
    1. output: Normalized tensor with identical shape and dtype as input.
Expected Behavior

The Relax ONNX frontend should implement LpNormalization using Relax arithmetic operations:

  1. 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).
  2. For =1$: compute norm = relax.op.sum(relax.op.abs(input), axis=axis, keepdims=True) and return relax.op.divide(input, norm).
Langage dominant
Python
Étoiles
13.9k
Forks
4.1k
Merge moyen
4 j 22 h
PR mergées (30 j)
22

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de apache/tvm

Toutes les issues de apache/tvm

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.