Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Data Type Mismatch (int64 vs int32) in T.match_buffer when Working with Scalar Buffers in TIR #17392

Open
Thrsu opened this issue Sep 19, 2024 · 0 comments
Labels
needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug

Comments

@Thrsu
Copy link
Contributor

Thrsu commented Sep 19, 2024

I encountered an issue when trying to build a TIR-based module. The following error occurs when using T.match_buffer for a scalar element:

File "/software/tvm/src/tir/transforms/lower_match_buffer.cc", line 222
TVMError: Check failed: arg.dtype() == value.dtype() (int64 vs. int32) : The data type mismatched: int64 vs. int32

If I replace the line C1 = T.match_buffer(C0[jj], ()) with direct assignment using C0[jj] = T.float32(0), the error goes away, and the code builds successfully without any issues.

Steps to reproduce

import tvm
from tvm import tir, relax
from tvm.script import ir as I
from tvm.script import tir as T

@I.ir_module
class Module:
    @T.prim_func
    def main():
        # with T.block("root"):
        C = T.alloc_buffer((128, 128))
        for i in range(128):
            with T.block(""):
                vi = T.axis.spatial(128, i)
                T.reads()
                T.writes(C[vi, 0:128])
                C0 = T.match_buffer(C[vi, 0:128], (128))
                for j in range(128):
                    with T.block(""):
                        jj = T.axis.spatial(128, j)
                        T.reads()
                        T.writes(C0[jj])
                        C1 = T.match_buffer(C0[jj], ())
                        C1[()] = T.float32(0)
mod = Module
ex = relax.build(mod, target='llvm')

CC @Lunderberg @tqchen @junrushao

@Thrsu Thrsu added needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug labels Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug
Projects
None yet
Development

No branches or pull requests

1 participant