[Bug][TIRx][S-TIR] LoopPartition fails when unrolling an int64 loop with extent one`

Đang mở
#20,879 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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ó
3/5
Thời gian dự kiến
Nửa ngày
Mức phù hợp với người mới
42/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp, python
Lĩnh vực
compilers

Hướng nghiên cứu

Start by running the reproducer in the issue, which calls s_tir.transform.LoopPartition with partition_const_loop=True on an int64 loop of extent one. The failing check is a structural type-equality assertion that fails when substituting i:T.int64 with 0:T.int32, so look at where LoopPartition substitutes the loop variable with its constant bound. Done means the reproducer runs without the InternalError and the loop variable keeps its integer type, and the existing int32 behaviour is unchanged.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

s_tir.transform.LoopPartition should successfully partition this well-formed function when partition_const_loop=True, preserving the loop variable's integer type or otherwise handling the unit-extent loop without an internal error.

Actual behavior

The input passes tirx.analysis.verify_well_formed, but applying LoopPartition raises:

InternalError: Check failed: (ffi::StructuralEqual()(ret.value()->ty, var->ty)) is false: substituting i:T.int64 -> 0:T.int32

Changing the loop variable and bounds to int32 makes the same pass invocation succeed.

Environment

Operating System: Ubuntu 26.04.1 LTS (WSL2), x86_64
Python: 3.10.22
Build: local LLVM build (21.1.8)
TVM version: 0.26.0

Steps to reproduce
import tvm
from tvm import tirx
from tvm.script import tirx as T


@T.prim_func(s_tir=True)
def main(A: T.Buffer((2,), "float32"), B: T.Buffer((2,), "float32")):
    for i in T.serial(T.int64(2)):
        if T.likely(i < T.int64(1)):
            B[i] = A[i]
        else:
            B[i] = A[i]


assert tirx.analysis.verify_well_formed(main)
mod = tvm.IRModule({"main": main})
with tvm.transform.PassContext(
    config={"s_tir.LoopPartition": {"partition_const_loop": True}}
):
    tvm.s_tir.transform.LoopPartition()(mod)
Triage

Please refer to the list of label tags here to find the relevant tags and add them below in a bullet format (example below).

  • needs-triage
Ngôn ngữ chính
Python
Star
13.9k
Fork
4k
Merge trung bình
8 giờ 5 phút
Pull request đã merge (30 ngày)
170

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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/tvm

Tất cả issue của apache/tvm

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.