[TIR][Fix] IndexDataTypeNormalizer not unwrapping float casting #13789
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.
This PR fixes a bug of IndexDataTypeNormalizer that is used by CreatePrimFunc.
#13449 enhanced the normalizer by unwrapping unnecessary casts, by the rule that “if the value to be casted already has the target index dtype`, the cast will be omitted. However, there are cases where a cast here is for other purpose. Like in image resize operators, there are sometimes rounding operation for indices, like
is used as a final index. Note that this PrimExpr contains casts that directly operated on indices, such as
T.Cast("float32", oh)
. This cast is for division purpose, in order to have floating point division result. As a result, it is not expected to unwrap such casts, while the previous implementation did remove the casts.Therefore, this PR patches this issue by only unwrapping the casts whose target dtype is integer dtype.
cc @vinx13 @tqchen