Commit 75a9b69e authored by pengcheng888's avatar pengcheng888
Browse files

issue/1042 - fix address misaligned error of rearrange

parent b2f915cb
...@@ -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