Unverified Commit a9503148 authored by thatPepe's avatar thatPepe Committed by GitHub
Browse files

Merge pull request #1044 from InfiniTensor/issue/1042

issue/1042 - fix address misaligned error of rearrange
parents 83e28ec3 75a9b69e
...@@ -144,11 +144,14 @@ void rearrange( ...@@ -144,11 +144,14 @@ void rearrange(
utils::Result<RearrangeMeta> RearrangeMeta::distributeUnit(const std::vector<size_t> &candidates) const { utils::Result<RearrangeMeta> RearrangeMeta::distributeUnit(const std::vector<size_t> &candidates) const {
// 获取当前的unit大小 // 获取当前的unit大小
size_t current_unit = _meta[0]; size_t current_unit = _meta[0];
const size_t ndim = this->ndim();
const ptrdiff_t dst_strides_0 = _meta[2 + ndim];
const ptrdiff_t src_strides_0 = _meta[2 + ndim + ndim];
// 寻找满足条件的unit值:当前unit能被其整除 // 寻找满足条件的unit值:当前unit能被其整除
size_t new_unit = 0; size_t new_unit = 0;
for (size_t candidate : candidates) { for (const size_t &candidate : candidates) {
if (current_unit % candidate == 0) { if ((current_unit % candidate == 0) && 0 == (dst_strides_0 & (candidate - 1)) && 0 == (src_strides_0 & (candidate - 1))) {
new_unit = candidate; new_unit = candidate;
break; break;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment