[Feature][IR] Make implicit conversions for binary arithmetic operations optional#462
Draft
Fangtangtang wants to merge 6 commits intocornell-zhang:mainfrom
Draft
[Feature][IR] Make implicit conversions for binary arithmetic operations optional#462Fangtangtang wants to merge 6 commits intocornell-zhang:mainfrom
Fangtangtang wants to merge 6 commits intocornell-zhang:mainfrom
Conversation
|
Can we discuss this in one of the Allo meetings later? |
Collaborator
Author
|
sure! |
Collaborator
Author
|
[update] Previous casting rule also seems inappropriate for aie backend. For example, Ty = int32
M = 1024
@df.region()
def top():
@df.kernel(mapping=[1])
def core(A: Ty[M], B: Ty[M], C: Ty[M]):
C[:] = A + B
A = np.random.randint(0, 100, M).astype(np.int32)
B = np.random.randint(0, 100, M).astype(np.int32)
mod = df.build(top, target="aie")
C = np.zeros(M).astype(np.int32)
mod(A, B, C)
np.testing.assert_allclose(C, A + B)may produce incorrect results. The correctness even depends on the value range of |
This was referenced Dec 5, 2025
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR enable user to optionally disable casting for some binary arithmetic operations.
Problems
Previously, the constructed IR contains many casting operations, some of them are redundant.
e.g.
The constructed IR is
and for
vitis_hlsbackend, the generatedkernel.cppconstainsProposed Solutions
add simplified typing rules for binary arithmetic operations, allowing users to control with flag.
Examples
The simplified typing rules generally follows cpp implicit conversion rules and only apply to
Users can
export USE_LESS_CASTING=1to use these rules for binary arithmetic operations. Currently we don't provide fallback for unsupported data typesApplying the simplified typing rules, IR for the same program above looks like this
in
kernel.cppChecklist
Please make sure to review and check all of these items: