Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/tvm/tir/op.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def tvm_struct_set(arr, index, field, value):
call : PrimExpr
The call expression.
"""
return call_intrin("handle", "tir.tvm_struct_set", arr, index, field, value)
return call_intrin("int32", "tir.tvm_struct_set", arr, index, field, value)


def address_of(buffer_load, span=None):
Expand Down
36 changes: 35 additions & 1 deletion tests/python/unittest/test_tvmscript_roundtrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import tvm
import tvm.testing
from tvm import tir
from tvm.script import tir as T
from tvm.script import tir as T, ir as I

import numpy as np

Expand Down Expand Up @@ -3692,6 +3692,39 @@ def func(
return func


def tvm_struct_set_generated_in_cpp():
"""Ensure same dtype for tvm_struct_set in Python/C++

The TVMStructSet method in C++, used internally by
LowerTVMBuiltin, and the Python method `T.tvm_struct_set`, used
when parsing TVMScript should use the same dtype "int32".
"""

@I.ir_module
class Module:
@T.prim_func
def tir_packed_call(A: T.Buffer(16)):
T.attr(0, "device_id", 0)
T.attr(0, "device_type", 0)
T.evaluate(
T.tvm_call_cpacked(
"tvm_test_cpacked",
T.tvm_stack_make_array(
A.data,
T.tvm_stack_make_shape(16, dtype="handle"),
T.reinterpret(T.uint64(0), dtype="handle"),
T.uint32(1),
T.Cast("float32", 0),
0,
dtype="handle",
),
dtype="int32",
)
)

return tvm.tir.transform.LowerTVMBuiltin()(Module)


ir_generator = tvm.testing.parameter(
launch_env_thread,
opt_gemm_normalize,
Expand Down Expand Up @@ -3757,6 +3790,7 @@ def func(
merge_shape_var_def,
if_then_else_var,
tvm_shfl_builtins,
tvm_struct_set_generated_in_cpp,
)


Expand Down