[Bug] [Relax][ONNX] Resize drops axes-scoped sizes before constructing resize2d
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start from the Resize converter in the Relax ONNX frontend, where sizes[2:] is sliced without applying the axes mapping. Run the provided repro.py to confirm the ValueError for axes=[2, 3] while full-rank sizes still import. Done when the axes-scoped case yields a 2-dim size and the output matches the full-rank result [1, 1, 4, 4].
由索引模型根据 Issue 内容生成。
描述
Expected behavior
For Resize-18, axes=[2, 3], sizes=[4, 4] on a [1, 1, 2, 2] tensor should produce the same [1, 1, 4, 4] result as full-rank sizes=[1, 1, 4, 4].
Actual behavior
Full-rank sizes import successfully. Axes-scoped sizes pass ONNX full checking and the ONNX reference evaluation, but fail during Relax import:
ValueError: Resize2D expects the given output image size to be a 2-dim shape, while the given one has ndim 0
The converter slices sizes[2:] without expanding the axes mapping. This uses the default stretch policy; the aspect-ratio change in #20846 does not cover it.
Environment
TVM 0.28.dev0 (local build; build commit unavailable), Python 3.12.3, Linux x86_64; ONNX 1.22.0, NumPy 2.5.4.
Steps to reproduce
Run with python repro.py:
import numpy as np
import onnx
from onnx import TensorProto as T, helper as h, numpy_helper as nh
from onnx.reference import ReferenceEvaluator
from tvm.relax.frontend.onnx import from_onnx
x = np.arange(4, dtype="float32").reshape(1, 1, 2, 2)
expected = x.repeat(2, axis=2).repeat(2, axis=3)
for axes, sizes in [(None, [1, 1, 4, 4]), ([2, 3], [4, 4])]:
attrs = {} if axes is None else {"axes": axes}
node = h.make_node("Resize", ["x", "", "", "sizes"], ["y"],
mode="nearest", coordinate_transformation_mode="asymmetric",
nearest_mode="floor", **attrs)
model = h.make_model(h.make_graph([node], "resize",
[h.make_tensor_value_info("x", T.FLOAT, [1, 1, 2, 2])],
[h.make_tensor_value_info("y", T.FLOAT, [1, 1, 4, 4])],
[nh.from_array(np.array(sizes, dtype="int64"), "sizes")]),
opset_imports=[h.make_opsetid("", 18)], ir_version=10)
onnx.checker.check_model(model, full_check=True)
np.testing.assert_array_equal(ReferenceEvaluator(model).run(None, {"x": x})[0], expected)
try:
from_onnx(model, keep_params_in_input=False)
print("axes", axes, "imported")
except Exception as error:
print("axes", axes, type(error).__name__, str(error).splitlines()[-1])
Triage
- needs-triage
- 主要语言
- Python
- 星标
- 13.9k
- 派生
- 4k
- 平均合并
- 8 小时 5 分钟
- 30 天内合并 PR
- 170
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/tvm 的其他 Issue
-
needs-triage type: bug
难度 2/5 1-3 小时 新手友好度 80/100
维护者通常 1 天内回复
-
[Bug] [Relax][ONNX] OneHot does not convert floating-point depth to int64可能已有人在做 @tandede 于 2 天前认领。 未关闭needs-triage type: bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
needs-triage type: bug
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
needs-triage type: bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
[Bug][Relax] ReorderTakeAfterMatmul fails on vector dot products可能已有人在做 @hiyufan 于 12 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 64/100
FinanceFlash/unvibecode#577 · 1 条评论 ·
维护者通常 1 天内回复
-
area/test type/bug
难度 2/5 1-3 小时 新手友好度 76/100
Clodmony/starship-coop#70 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
punitarani/fli#270 ·
-
🐛 Bug 🔔 Pending processing
难度 2/5 1-3 小时 新手友好度 67/100
jumpserver/jumpserver#17980 ·
维护者通常 1 天内回复
-
community enhancement good first issue
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 1 天内回复