Skip to content

Commit cd230ea

Browse files
author
Denis Kozlov
committed
Return clipping to the GetSubTensor but only in the middle tile branch
1 parent fdbe2f0 commit cd230ea

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

include/mli_iterator.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class IteratorCfg {
182182
MLI_ASSERT(icfg.m_first_pos_inc[i] * stride[dim] >= pre_padding[dim]);
183183
m_first_pos_inc[i] = icfg.m_first_pos_inc[i] * stride[dim] - (int32_t)pre_padding[dim];
184184
m_last_pos_inc[i] = m_count[i] > 1 ? m_pos_inc[i] * (2 - m_count[i]) - m_first_pos_inc[i] : 0;
185-
m_size[i] = MIN((icfg.m_size[i] - 1) * stride[dim] + effective_kernel_size[dim], tns_dim);
185+
m_size[i] = (icfg.m_size[i] - 1) * stride[dim] + effective_kernel_size[dim];
186186
m_first_size[i] = MIN((icfg.m_first_size[i] - 1) * stride[dim] + effective_kernel_size[dim] - pre_padding[dim], tns_dim);
187187
m_last_size[i] = tns_dim + m_last_pos_inc[i];
188188
m_diff_code[i] = CalcDiffCode(m_count[i], m_first_size[i], m_size[i], m_last_size[i]);
@@ -1028,7 +1028,9 @@ class TensorIterator {
10281028
} else if (m_tile_idx[r] == 0) { // First iteration
10291029
copysize[dim] = m_config.get_first_size(r);
10301030
} else { // Middle iteration
1031-
copysize[dim] = m_config.get_size(r);
1031+
// Clip here, since the penultimate tile can have less size due to big post-padding
1032+
// Clipping of the first/last tiles is handled in the constructor
1033+
copysize[dim] = MIN(m_full_tensor.get_dim(dim) - pos[dim], m_config.get_size(r));
10321034
}
10331035
}
10341036
return m_full_tensor.slice(pos, copysize);

0 commit comments

Comments
 (0)