Fix the bug of misaligned address in vectorization. #72106
Merged
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.
PR Category
CINN
PR Types
Bug fixes
Description
Pcard-89071
向量化索引中包含

a % b,但是b % factor != 0的场景存在索引越界,例子:该patch删除了tensor_is_continuous的代码:
paddle/cinn/ir/group_schedule/config/group_tile_util.cc的GetGroupVectorizeInfo保证,“存在非连续的变量,can_vectorize就为false”,不需要在后续代码中再次判断非连续了,故删除旧代码。
CheckTensorAddrLegalCastToVectorize的逻辑:
[a, b, c, d, e] + [a, 1, c, 1, e](shape为1的维度做broadcast)
这俩者相加,计算索引的代码会出现
%e,/(d*e)等(包括%(c*d*e),但只需要找到最小的除余或除号后面的数)。对于offset_is_zero:
1)CheckTensorAddrLegalCastToVectorize能处理最低维做广播的情况:
shape为[a, b, c, d] + [a, b, 1, 1]的场景,能通过判断
flattened_value % vectorize_factor != 0,剔除这个情况。2)CheckTensorAddrLegalCastToVectorize无法处理
shape.size() = 1的情况:shape为[b]和[a, b, c, d]两个tensor发生计算关系,无法处理。所以保留了旧代码CheckTensorOffsetZero。