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

[TIR] Fix dtype mismatch error due to LetStmt #13710

Merged
merged 5 commits into from
Jan 7, 2023

Conversation

masahi
Copy link
Member

@masahi masahi commented Jan 5, 2023

Previously, even if the dtype of the rhs of LetStmt is casted to int64, the bound variable doesn't get updated. This results in the following invalid IR to be generated:

p0_red_temp_v0 = T.alloc_buffer([T.int64(1), T.int64(56), T.int64(56)], dtype="int32")
...
for ax0, ax1, ax2, k3 in T.grid(T.int64(1), T.int64(56), T.int64(56), T.int64(64)):
   with T.block("p0_red_temp"):
        ...
        v_p0_red_temp_v0: T.int32 = T.Select(p0_red_temp_v1[v_ax0, v_ax1, v_ax2] > p0[v_ax0, v_ax1, v_ax2, v_k3] or (p0_red_temp_v1[v_ax0, v_ax1, v_ax2] == p0[v_ax0, v_ax1, v_ax2, v_k3] and T.Cast("int64", p0_red_temp_v0[v_ax0, v_ax1, v_ax2]) < v_k3), T.Cast("int64", p0_red_temp_v0[v_ax0, v_ax1, v_ax2]), v_k3)
        p0_red_temp_v0[v_ax0, v_ax1, v_ax2] = v_p0_red_temp_v0

cc @vinx13

@tvm-bot
Copy link
Collaborator

tvm-bot commented Jan 5, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@masahi masahi changed the title Dtype legalize fix let [TIR] Fix dtype mismatch error due to LetStmt Jan 5, 2023
@github-actions github-actions bot requested a review from vinx13 January 6, 2023 04:21
@masahi masahi force-pushed the dtype-legalize-fix-let branch from e41adfa to c7e4559 Compare January 6, 2023 11:47
@masahi masahi merged commit 088bc11 into apache:main Jan 7, 2023
fzi-peccia pushed a commit to fzi-peccia/tvm that referenced this pull request Mar 27, 2023
* [TIR] Fix dtype mismatch error due to LetStmt

* add comment

* improve letstmt visitor

* remove SubstituteWithDataTypeLegalization

* consolidate vmap look up logic in the base class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants