Closed zzzDavid closed 9 months ago
test/Transforms/memory/strided_reuse_iv_update.mlir
This issue is caused by reuse_at implementation on stride > 1 loops where the induction variable is also used in an if condition inside the loop body.
reuse_at
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:
if_mac
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.
iv
(new_iv - reuse_distance) / stride
I will add the HeteroCL program test after this PR is merged
Any updates on this PR? It also requires rebasing to enable the latest CI.
@zzzDavid Can this PR be merged?
Summary
test/Transforms/memory/strided_reuse_iv_update.mlir
This issue is caused by
reuse_at
implementation on stride > 1 loops where the induction variable is also used in an if condition inside the loop body.Explanation
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:And we have updated the induction variable as:
which means
Therefore, we just need to replace all
iv
with(new_iv - reuse_distance) / stride
.