[Bug] [Relax][ONNX] Expand uses a symbolic requested shape without merging broadcast dimensions
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 68/100
Hướng nghiên cứu
Start with the ShapeExpr branch in python/tvm/relax/frontend/onnx/onnx_frontend.py, around lines 3453–3515, and trace how it handles the requested shape in Expand. Run the supplied reproduction with z_shape ["N", 2]; it should produce the same [3, 2] output as the constant-shape case, without dropping rows.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Expected behavior
Expanding [3,1] with requested shape [1,2] should produce [3,2] under ONNX multidirectional broadcasting, including when the requested shape comes from Shape(z).
Actual behavior
With the same actual inputs, declaring z as [1,2] gives the correct [3,2] output. Changing only its annotation to [N,2] silently produces [1,2] and drops two rows:
[1, 2] TVM (3, 2) [[1.0, 1.0], [2.0, 2.0], [3.0, 3.0]]
['N', 2] TVM (1, 2) [[1.0, 1.0]]
The ShapeExpr branch merges only constant target extents. This differs from #20873: the target here is a symbolic ShapeExpr and conversion succeeds.
Environment
TVM 0.28.dev0, LLVM 18.1.3, Linux x86_64; Python 3.12.3, NumPy 2.5.4, ONNX 1.22.0, ORT 1.29.0. The installed binary build revision is unknown; current main was inspected statically, not rebuilt.
Steps to reproduce
Run with an LLVM-enabled TVM installation:
import numpy as np
import onnx
import tvm
from onnx import TensorProto as T, helper as h
from onnx.reference import ReferenceEvaluator
from tvm import relax
from tvm.relax.frontend.onnx import from_onnx
x = np.array([[1], [2], [3]], dtype="float32")
z = np.zeros((1, 2), dtype="float32")
expected = np.repeat(x, 2, axis=1)
for z_shape in ([1, 2], ["N", 2]):
model = h.make_model(h.make_graph([
h.make_node("Shape", ["z"], ["shape"]),
h.make_node("Expand", ["x", "shape"], ["y"])], "expand",
[h.make_tensor_value_info("x", T.FLOAT, [3, 1]),
h.make_tensor_value_info("z", T.FLOAT, z_shape)],
[h.make_tensor_value_info("y", T.FLOAT, [3, 2])]),
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, "z": z})[0], expected)
try:
mod = from_onnx(model, keep_params_in_input=False)
vm = relax.VirtualMachine(relax.build(mod, target="llvm"), tvm.cpu())
actual = vm["main"](tvm.runtime.tensor(x), tvm.runtime.tensor(z)).numpy()
print(z_shape, "TVM", actual.shape, actual.tolist())
if z_shape[0] == 1:
np.testing.assert_array_equal(actual, expected)
except Exception as error:
if z_shape[0] == 1:
raise
print(z_shape, type(error).__name__, str(error).splitlines()[-1])
Triage
- needs-triage
- Ngôn ngữ chính
- Python
- Star
- 13.9k
- Fork
- 4k
- Merge trung bình
- 8 giờ 2 phút
- Pull request đã merge (30 ngày)
- 180
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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/tvm
-
needs-triage type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] [Relax][ONNX] OneHot does not convert floating-point depth to int64Có thể đã có người làm @tandede đã nhận 1 ngày trước. Đang mởneeds-triage type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug][Relax] ReorderTakeAfterMatmul fails on vector dot productsCó thể đã có người làm @hiyufan đã nhận 11 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
apache/tvm#20595 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
bug severity:low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 2 ngày
-
curriculum documentation quality
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
githubnext/gh-aw-workshop#5367 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
OAuth documentation for GET /api/v2/users/me/ appears inconsistent with required global read scopeĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Create Noise Latents ignores randomize_seed and produces the same noise every runCó thể đã có người làm @griptapeops đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
griptape-ai/griptape-nodes-library-diffusers#127 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Jenkins capacity report: metrics history is lost when archiving a month failsCó thể đã có người làm @RaphaelFakhri đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
adoptium/infrastructure#4568 ·
Maintainer thường phản hồi trong vòng 1 ngày