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

Đang mở
#20,969 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
67/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
machine-learning

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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).
Ngôn ngữ chính
Python
Star
13.9k
Fork
4.1k
Merge trung bình
4 ngày 22 giờ
Pull request đã merge (30 ngày)
22

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/tvm

Tất cả issue của apache/tvm

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.