You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add fixed-point IR rewrites before TileArray program replacement - #10
The rewrite packs overlapping windows into patches and creates matrix views of the filter and output. Tests compare the rewritten IR with expected IR and cover stride, dilation, dtype, and configurable GEMM dimensions.
explain the diff between rewrite_patterns and replace_patterns?
rewrite_patterns transform the computation IR (e.g., CONV → im2col + matmul). replace_patterns select a TileArray program/kernel implementation for a matching computation (e.g., matmul → a GEMM template kernel). Rewrites run to a fixed point before template replacement at each source level.
how input and patches become patches and weights? Is it a 1D conv? plz elaborate on the math.
The operand correspondence is:
CONV(input, filter, output)
↓
patches = im2col(input)
weights = matrix view of filter
C = matrix view of output
↓
C += patches @ weights
So patches comes from input, while weights comes from filter. Only the input windows are copied; the filter and output use views.
Yes, this example is 1D convolution: the kernel has height 1 and width 3, with one input channel and three output channels.
For input X = [a, b, c, d, e], unit stride and dilation produce three windows:
patches = [[a, b, c],
[b, c, d],
[c, d, e]]
Let weights[k,j] = filter[0,k,0,j]. Each column contains the three weights for output channel j.
The original convolution computes:
output[0,0,x,j] += Σ_k X[x+k] × filter[0,k,0,j]
Since patches[x,k] = X[x+k], this becomes:
C[x,j] += Σ_k patches[x,k] × weights[k,j]
That is exactly C += patches @ weights. Here x, j, and k each range from 0 to 2, giving a 3×3 GEMM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Python IR rewrites before TileArray program replacement at both the
LinalgandAffinestages.IRRewritePatterntransforms computation IR. Rules repeat until a complete round makes no changes.TileArrayProgramReplacePatternselects TileArray kernel implementations.compile()accepts customrewrite_patternsandreplace_patterns.A configurable test example rewrites CONV into im2col + matmul. For a length-5 input and three length-3 filters:
The rewrite packs overlapping windows into
patchesand creates matrix views of the filter and output. Tests compare the rewritten IR with expected IR and cover stride, dilation, dtype, and configurable GEMM dimensions.