Skip to content
Closed
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/script/parser/core/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def add(self, var: str, value: Any, allow_shadowing: bool = False):
The options of whether variable shadowing allwed for this variable.
"""
# Skip if the key and value are equal to those in the var_table
if self.name2value[var] and self.name2value[var][-1] == value:
if self.name2value[var] and self.name2value[var][-1] is value:
return
if allow_shadowing and var in self.frames[-1].vars:
# Shadowing
Expand Down
15 changes: 15 additions & 0 deletions tests/python/unittest/test_tvmscript_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,20 @@ def test_multi_element_array_in_outmost_namespace():
tvm.ir.assert_structural_equal(func, rt_func)


def test_different_dtype_assignment_to_var():
@T.prim_func
def test_case():
a = T.alloc_buffer((10, 10), dtype="int8")

@T.prim_func
def func_ref():
a = T.alloc_buffer([10, 10], dtype="int8")
T.evaluate(0)

tvm.ir.assert_structural_equal(test_case, func_ref)


if __name__ == "__main__":
a = numpy.zeros((10, 10), dtype="int8")
test_multi_element_array_in_outmost_namespace()
test_different_dtype_assignment_to_var()