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

Abierto
#20,971 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Start with python/tvm/relax/frontend/onnx/onnx_frontend.py and read how the Relax ONNX frontend translates operators using slicing and padding. Check the ONNX CenterCropPad specification for opset 18+, especially axes defaults and symmetric crop or pad behavior. Done means the frontend handles the operator and produces the requested output shape for both cropping and padding.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Feature Description

Support the ONNX CenterCropPad operator in the Apache TVM Relax ONNX frontend (python/tvm/relax/frontend/onnx/onnx_frontend.py).

Motivation

CenterCropPad crops and/or pads input tensors centered along specified axes to reach a desired spatial shape. It is a standard building block in computer vision data pipelines and end-to-end vision inference models where image preprocessing is embedded directly into the ONNX graph.

Standardized in ONNX opset 18+, CenterCropPad is currently not supported in the Relax ONNX frontend, resulting in:

NotImplementedError: The following operators are not supported: ['CenterCropPad']

This operator was also highlighted in the ONNX operator coverage RFC tracking issue #20124 under Cropping / Sequence operators.

Operator Specification (ONNX Opset 18+)
  • Inputs:
    1. input_data: N-D input tensor (float32, float16, uint8, etc.).
    2. shape: 1D integer tensor specifying the target shape along the specified axes.
  • Attributes:
    • axes: list of ints (optional) - the axes along which to crop/pad (defaults to [-2, -1] for spatial dims).
  • Outputs:
    1. output_data: Cropped and/or padded tensor matching the target shape.
Expected Behavior

The Relax ONNX frontend should implement CenterCropPad by comparing input dimensions with target dimensions:

  1. For dimensions where target < input: compute symmetric start/end indices and apply relax.op.strided_slice.
  2. For dimensions where target > input: compute symmetric left/right pad widths and apply relax.op.pad.
Lenguaje dominante
Python
Estrellas
13.9k
Forks
4.1k
Merge medio
4 d 22 h
PR fusionados (30 d)
22

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/tvm

Todos los issues de apache/tvm

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.