Skip to content

[Bug] assert_structural_equal fails when comparing identical IRModule #18228

@guocju

Description

@guocju

Expected behavior

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

@I.ir_module
class Module:
    @T.prim_func
    def add_one(A: T.handle, B: T.handle):
        A_buf = T.match_buffer(A, (32,), "float32")
        B_buf = T.match_buffer(B, (32,), "float32")
        for i in range(32):
            B_buf[i] = A_buf[i] + T.float32(1.0)

mod = Module
# Expect: no error
tvm.ir.assert_structural_equal(mod, mod)

Expect: no error

Actual behavior

ValueError: StructuralEqual check failed, caused by lhs at .functions[I.GlobalVar("add_one")].params[0].dtype:
and rhs at .functions[I.GlobalVar("add_one")].params[0].dtype:

# from tvm.script import ir as I
# from tvm.script import tir as T

@I.ir_module
class Module:
    @T.prim_func
    ^^^^^^^^^^^^
    def add_one(A: T.handle, B: T.handle):
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        A_buf = T.match_buffer(A, (32,))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        B_buf = T.match_buffer(B, (32,))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        for i in range(32):
        ^^^^^^^^^^^^^^^^^^^
            B_buf[i] = A_buf[i] + T.float32(1.0)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Environment

TVM version: a7a0168 [FFI][REFACTOR] Establish tvm_ffi python module (#18226)
Python version: 3.10.12
OS: (Linux/Ubuntu 22.04 )

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triagePRs or issues that need to be investigated by maintainers to find the right assignees to address ittype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions