[Bug][TOPI] rsqrt with uint16 input fails during LLVM code generation
Maintainer thường phản hồi trong vòng 3 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Read python/tvm/topi/math.py around the rsqrt implementation linked in the issue and compare its dtype promotion guard with the signed integer case. Reproduce the failure using the provided uint16 example and check nearby TOPI tests for reciprocal square root coverage. Done means uint16 either compiles with the expected floating point results or reports the unsupported dtype during operator construction; an open linked pull request is already addressing this issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Expected behavior
If topi.rsqrt supports unsigned integer inputs, I would expect it to promote
uint16 to a floating-point type as it does for int16. For the input
[1, 4, 16, 64], the expected reciprocal square roots are exactly
[1, 0.5, 0.25, 0.125]. If unsigned inputs are unsupported, could TOPI report
the unsupported dtype when constructing the operator?
Actual behavior
TOPI accepts all three inputs below and generates TIR. Only the direct
uint16 case fails at tvm.compile(..., target="llvm").
Input to rsqrt |
Generated TIR | LLVM CPU result |
|---|---|---|
int16 |
Casts to float32 before T.rsqrt |
[1, 0.5, 0.25, 0.125] (float32) |
uint16 explicitly cast to float32 |
Applies T.rsqrt to the cast value |
Same values and dtype |
uint16 |
Emits T.rsqrt(x[v_i0]) with a uint16 output buffer |
Compilation fails |
RuntimeError: Check failed: (f) is false: Cannot find intrinsic declaration, possible type mismatch: llvm.sqrt
The earlier report used an int16 input. Its fix added promotion for signed
integers. At the commit tested here, the promotion guard in rsqrt checks
DataTypeCode.INT. Issue #17952 · PR #17953 · Implementation at the tested commit
Environment
- TVM
0.28.dev0, built and tested at commit84657c01e5d3672cfd299bd3d5c77bff3888a1a9. - Ubuntu 26.04.1 LTS on WSL2, Linux 6.18.58.1, x86_64.
- Intel Core i7-14700KF, LLVM 21.1.8, target
llvm. - Python 3.10.22, NumPy 1.26.4.
Steps to reproduce
Save as repro.py and run python repro.py in a TVM environment with LLVM enabled.
The first two calls print their outputs. The third raises the error above.
import numpy as np
import tvm
import tvm_tirx
from tvm import te, topi
from tvm.s_tir import Schedule
def run(dtype, explicit_cast=False):
values = np.array([1, 4, 16, 64], dtype=dtype)
x = te.placeholder(values.shape, dtype=dtype, name="x")
operand = x
if explicit_cast:
operand = te.compute(x.shape, lambda i: x[i].astype("float32"), name="cast_f32")
y = topi.rsqrt(operand)
mod = Schedule(te.create_function([x, y])).mod
print(f"input={dtype}, explicit_cast={explicit_cast}, output={y.dtype}", flush=True)
exe = tvm.compile(mod, target="llvm")
output = tvm_tirx.runtime.tensor(np.empty(values.shape, dtype=str(y.dtype)))
exe.jit()["main"](tvm_tirx.runtime.tensor(values), output)
print(output.numpy().tolist(), flush=True)
run("int16")
run("uint16", explicit_cast=True)
run("uint16")
Triage
- needs-triage
- Ngôn ngữ chính
- Python
- Star
- 13.9k
- Fork
- 4.1k
- Merge trung bình
- 4 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 22
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
-
[Bug] [Relax] `relax.op.unique(return_inverse=True)` returns an input-shaped inverse for N-D input when `axis` is NoneCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 3 ngày
-
[Bug][TOPI] `topi.scanop` (`cumsum` / `cumprod`) performs out-of-bounds write/read on empty tensorsĐang mởneeds-triage type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 3 ngày
-
[Bug] [Relax] take_backward does not normalize negative axis causing heap OOB write and wrong gradientsCó thể đã có người làm @pierceluu10 đã nhận 5 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 78/100
Maintainer thường phản hồi trong vòng 3 ngày
-
[Bug][Relax][ONNX] NonZero returns the wrong output shape for scalar inputsCó thể đã có người làm @tandede đã nhận 9 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 70/100
Maintainer thường phản hồi trong vòng 3 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
apache/tvm#21043 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
Techiebutler/freeframe#687 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug verbose GC
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
IBM/javacore-analyser#677 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
Maintainer thường phản hồi trong vòng 2 ngày
-
area/config comp/plugins P1 platform/qqbot tool/file type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
NousResearch/hermes-agent#163932 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
plugins/dsh: todayStr() computes UTC but is documented as local — journal entries written 00:00–08:00 local land in the previous day's fileCó thể đã có người làm @Beehtrix đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
zilliztech/memsearch#907 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày