Closed zzzDavid closed 9 months ago
The issue is that non-reduction loop's bound is updated, but the induction variable expressions are not. https://github.com/cornell-zhang/hcl-dialect/blob/f2f5e43a93173f9a86671c8f5004d5fb21cb329b/lib/Transforms/LoopTransformations.cpp#L1696-L1697
In binary convolution, we have a if_mac
function that checks row and column axis to skip padding values. The expression looks like this:
iv * stride + reduction_iv * dilation >= padding_left
iv * stride + reduction_iv * dilation < padded_width - padding_right
And we have updated the induction variable as:
new_iv = iv * stride + reuse_distance
which means
iv = (new_iv - reuse_distance) / stride
Therefore, we just need to replace all iv
with (new_iv - reuse_distance) / stride
.
This issue is caused by
reuse_at
implementation on stride>2 loops where the induction variable is also used in an if condition inside loop body.Example
I'll provide an example with HCL code since comparing with numpy is easier there:
edit: update golden to have the same
if_mac
behavior