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

オープン
#20,969 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
67/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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).
主要言語
Python
スター
13.9k
フォーク
4.1k
平均マージ
4日 22時間
マージ済み PR(30日)
22

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/tvm のほかの issue

apache/tvm の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。