[Bug][Relax][ONNX] Runtime Tile repeats with a zero-extent input fail in from_onnx with Divide by zero
I maintainer di solito rispondono entro 3 giorni
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 40/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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, commit3d89c4991c5a37492f470800231a5ea8f57a95c6, 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_tileand 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
- Lingua principale
- Python
- Stelle
- 13.9k
- Fork
- 4.1k
- Merge medio
- 4g 22h
- PR unite (30g)
- 22
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/tvm
-
[Bug] [Relax] `relax.op.unique(return_inverse=True)` returns an input-shaped inverse for N-D input when `axis` is NoneForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 3 giorni
-
[Bug][TOPI] `topi.scanop` (`cumsum` / `cumprod`) performs out-of-bounds write/read on empty tensorsApertaneeds-triage type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 3 giorni
-
[Bug] [Relax] take_backward does not normalize negative axis causing heap OOB write and wrong gradientsForse già presa @pierceluu10 l’ha presa 4 giorni fa. Apertaneeds-triage type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 3 giorni
-
[Bug][Relax][ONNX] NonZero returns the wrong output shape for scalar inputsForse già presa @tandede l’ha presa 9 giorni fa. Apertaneeds-triage type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 3 giorni
-
needs-triage type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
apache/tvm#21043 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
Issue simili
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 78/100
web-push-libs/pywebpush#216 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
AgriciDaniel/claude-seo#572 ·
I maintainer di solito rispondono entro 5 giorni
-
area:print-dispatch
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
I maintainer di solito rispondono entro 1 giorno
-
area: docs domain: technical-writing good first issue type: documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
Deepak3699/Ai_Mentor#919 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno