Repository navigation
[Codegen][GPU] Canonicalize to remove the empty extract slice in combineLayoutTransformation pass - #21395
Merged
jerryyin merged 1 commit intoJul 17, 2025
Conversation
jerryyin
requested review from
Groverkss,
MaheshRavishankar,
hanhanW,
kuhar and
qedawkins
as code owners
July 16, 2025 21:21
jerryyin
force-pushed
the
users/zyin/canonicalize-extract-slice-from-empty-after-combinelayout
branch
from
July 16, 2025 21:28
d58c69c to
b83003c
Compare
hanhanW
reviewed
Jul 16, 2025
jerryyin
force-pushed
the
users/zyin/canonicalize-extract-slice-from-empty-after-combinelayout
branch
5 times, most recently
from
July 17, 2025 13:00
6901b13 to
914d8ac
Compare
Signed-off-by: jerryyin <[email protected]>
jerryyin
deleted the
users/zyin/canonicalize-extract-slice-from-empty-after-combinelayout
branch
July 17, 2025 13:23
IanWood1
pushed a commit
to IanWood1/iree
that referenced
this pull request
Jul 18, 2025
…ineLayoutTransformation pass (iree-org#21395) Credit to @Max191 for pointing out the this canonicalization patterns that fix performance degrade in convolution. ```mlir %12 = tensor.empty() : tensor<2x21x64xbf16> %13:2 = scf.forall (%arg3, %arg4, %arg5, %arg6) in (1, 1, 4, 64) shared_outs(%arg7 = %11, %arg8 = %12) -> (tensor<2x2x16x4x16xbf16>, tensor<2x21x64xbf16>) { ... %extracted_slice = tensor.extract_slice %arg8[0, 0, %15, %arg5, %14#2] [2, 2, 4, 1, 1] [1, 1, 1, 1, 1] : tensor<2x2x16x4x16xbf16> to tensor<2x2x4x1x1xbf16> %transposed = linalg.transpose ins(%20 : tensor<2x2x1x4x1xbf16>) outs(%extracted_slice : tensor<2x2x4x1x1xbf16>) permutation = [0, 1, 3, 2, 4] ``` Here `%12` is an empty tensor, so that extract_slice can be folded into a new empty tensor. Now without the canonicalization patterns, this will results in a huge private allocation ` %alloca = memref.alloca() : memref<2x2x16x4x16xbf16, #gpu.address_space<private>>` that eventually results in register spills that kills the performance. Note that this will only happen when input IR has two level nested `scf.forall`, this make it challenging to cleanly put it in as a combine layout transformation pass test. Therefore I'm putting it as a pipeline test instead. Signed-off-by: jerryyin <[email protected]>
AWoloszyn
pushed a commit
that referenced
this pull request
Dec 1, 2025
…ineLayoutTransformation pass (#21395) Credit to @Max191 for pointing out the this canonicalization patterns that fix performance degrade in convolution. ```mlir %12 = tensor.empty() : tensor<2x21x64xbf16> %13:2 = scf.forall (%arg3, %arg4, %arg5, %arg6) in (1, 1, 4, 64) shared_outs(%arg7 = %11, %arg8 = %12) -> (tensor<2x2x16x4x16xbf16>, tensor<2x21x64xbf16>) { ... %extracted_slice = tensor.extract_slice %arg8[0, 0, %15, %arg5, %14#2] [2, 2, 4, 1, 1] [1, 1, 1, 1, 1] : tensor<2x2x16x4x16xbf16> to tensor<2x2x4x1x1xbf16> %transposed = linalg.transpose ins(%20 : tensor<2x2x1x4x1xbf16>) outs(%extracted_slice : tensor<2x2x4x1x1xbf16>) permutation = [0, 1, 3, 2, 4] ``` Here `%12` is an empty tensor, so that extract_slice can be folded into a new empty tensor. Now without the canonicalization patterns, this will results in a huge private allocation ` %alloca = memref.alloca() : memref<2x2x16x4x16xbf16, #gpu.address_space<private>>` that eventually results in register spills that kills the performance. Note that this will only happen when input IR has two level nested `scf.forall`, this make it challenging to cleanly put it in as a combine layout transformation pass test. Therefore I'm putting it as a pipeline test instead. Signed-off-by: jerryyin <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Credit to @Max191 for pointing out the this canonicalization patterns that fix performance degrade in convolution.
Here
%11is an empty tensor, so that extract_slice can be folded into a new empty tensor. Now without the canonicalization patterns, this will results in a huge private allocation%alloca = memref.alloca() : memref<2x2x16x4x16xbf16, #gpu.address_space<private>>that eventually results in register spills that kills the performance.Note that this will only happen when input IR has two level nested
scf.forall, this make it challenging to cleanly put it in as a combine layout transformation pass test. Therefore I'm putting it as a pipeline test instead.