[Bug][Relax][ONNX] Runtime Tile repeats with a zero-extent input fail in from_onnx with Divide by zero

Abierto
#21,058 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

@tandede ya está trabajando en esto.

Desde el 25/11/2026.

  • #21059 de @tandede — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
40/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
compilers

Línea de trabajo

Start by running the reproducer, which calls from_onnx with shape_dict={"X": (0, 3)} and a runtime repeats input and fails with Divide by zero. The Tile converter in the Relax ONNX frontend calls topi.dyn_tile, defined in include/tvm/topi/transform.h, where the empty-output check misses a literal zero input extent and builds an indexmod by that extent. Done means import succeeds and yields an empty R.Tensor((0, 3)) result matching the expected shapes in the table.

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

Descripción

needs-triage type: bug

Thanks for participating in the TVM community! We use https://discuss.tvm.apache.org/ for any general usage questions and discussions. The issue tracker is used for actionable items such as feature proposals discussion, roadmaps, and bug tracking. You are always welcomed to post on the forum first 😸

Issues that are inactive for a period of time may get closed. We adopt this policy so that we won't lose track of actionable issues that may fall at the bottom of the pile. Feel free to reopen a new one if you feel there is an additional problem that needs attention when an old one gets closed.

Expected behavior

With float32 input X of shape [0, 3] and repeats supplied as an int64 graph input, Tile should produce an empty tensor. Each output dimension is the corresponding input dimension multiplied by its repeat count. ONNX Tile-13 specification

Independent controls for this exact model and input confirm the legal expected results (exact shape and dtype, float32):

repeats expected numpy.tile ONNX ReferenceEvaluator ORT CPU
[1, 1] (0, 3) (0, 3) (0, 3) (0, 3)
[2, 1] (0, 3) (0, 3) (0, 3) (0, 3)
[1, 0] (0, 0) (0, 0) (0, 0) (0, 0)
Actual behavior

The model passes onnx.checker.check_model(model, full_check=True). When the static extent is made visible to the importer with shape_dict={"X": (0, 3)}, from_onnx aborts before any compilation:

RuntimeError: Check failed: pb->value != 0 (0 vs. 0) : Divide by zero

The failure occurs during import. Two controls isolate the combination of a static zero extent and runtime repeats.

Case X shape in Relax IR from_onnx
runtime repeats + shape_dict={'X': (0,3)} not produced (fails) FAILED: Divide by zero
runtime repeats, no shape_dict R.Tensor((v, 3)), v a shape var OK
constant repeats initializer + shape_dict={'X': (0,3)} R.Tensor((0, 3)) OK

The same exception was reproduced in two fresh Python processes.

Environment
  • TVM 0.28.dev0, commit 3d89c4991c5a37492f470800231a5ea8f57a95c6, LLVM 21.1.8, CPU
  • Linux x86-64 (WSL2), Python 3.10
  • ONNX 1.21.0, ONNX Runtime 1.23.2, NumPy 1.26.4
  • ONNX opset 13, IR version 8
Steps to reproduce
import numpy as np
import onnx
from onnx import TensorProto as T, helper as h
from onnx.reference import ReferenceEvaluator
from tvm.relax.frontend.onnx import from_onnx

node = h.make_node("Tile", ["X", "S"], ["Y"])
x = h.make_tensor_value_info("X", T.FLOAT, [0, 3])
s = h.make_tensor_value_info("S", T.INT64, [2])       # runtime repeats
y = h.make_tensor_value_info("Y", T.FLOAT, ["N", "M"])
graph = h.make_graph([node], "tile_zero", [x, s], [y])
model = h.make_model(graph, opset_imports=[h.make_opsetid("", 13)], ir_version=8)
onnx.checker.check_model(model, full_check=True)

X = np.zeros((0, 3), dtype=np.float32)
S = np.array([1, 1], dtype=np.int64)
print(ReferenceEvaluator(model).run(None, {"X": X, "S": S})[0].shape)  # (0, 3)
# Forces the static zero extent to survive import instead of becoming a shape var:
from_onnx(model, shape_dict={"X": (0, 3)}, keep_params_in_input=False)  # RuntimeError: Divide by zero
Additional context

The dynamic Tile converter calls topi.dyn_tile with symbolic output dimensions. Its empty-output check cannot resolve these dimensions to zero. It then constructs indexmod(indices[i], x->shape[i]), where the first input extent is the literal zero. The traceback ends in constant folding of this modulo expression. dyn_tile at the tested commit

Related issues
  • #18752 concerns support for runtime Tile repeats. This reproducer reaches topi.dyn_tile and fails when the input has a static zero extent.
  • #19922 also reports divide-by-zero with a zero-sized dimension, during compilation of a reshape from the PyTorch frontend. This reproducer fails while constructing the Tile expression during ONNX import.
Triage
  • needs-triage
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.