-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PromotePadsToL1] Implement pass lowering
tensor.pad
(#119)
`tensor.pad`, as we produce them, can be lowered to `start_tensor_copy`. The latter will perform the L1 allocation and copy operations during bufferization. The one not-nice part of the pass is that it does so indiscriminately for all `tensor.pad` operations. I am very unsure about whether there are any guarantees by IREE that'd never encounter `tensor.pad` operations in kernels. This was also the last pass required to compile the last kernel in NsNet2
- Loading branch information
Showing
5 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
35 changes: 35 additions & 0 deletions
35
codegen/tests/Dialect/Snitch/Transforms/promote-pads-to-l1.mlir
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// RUN: quidditch-opt %s -p "builtin.module(func.func(quidditch-promote-pads-to-l1))" --allow-unregistered-dialect | FileCheck %s | ||
|
||
// CHECK-LABEL: @test_zero_f32( | ||
// CHECK-SAME: %[[A:[[:alnum:]]+]]: tensor<32x32xf32> | ||
func.func @test_zero_f32(%a : tensor<32x32xf32>) -> tensor<33x33xf32> { | ||
%c = arith.constant 0.0 : f32 | ||
// CHECK: %[[R:.*]], %[[T:.*]] = quidditch_snitch.start_tensor_copy %[[A]] | ||
// CHECK-SAME: pad with zero to [1, 1] | ||
// CHECK: %[[R2:.*]] = quidditch_snitch.wait_for_tensor_copy of %[[A]] | ||
// CHECK-SAME: to %[[R]] | ||
// CHECK-SAME: using %[[T]] | ||
%0 = tensor.pad %a low[0, 0] high[1, 1] { | ||
^bb0(%arg0: index, %arg1: index): | ||
tensor.yield %c : f32 | ||
} : tensor<32x32xf32> to tensor<33x33xf32> | ||
// CHECK: return %[[R2]] | ||
return %0 : tensor<33x33xf32> | ||
} | ||
|
||
// CHECK-LABEL: @test_poison( | ||
// CHECK-SAME: %[[A:[[:alnum:]]+]]: tensor<32x32xf32> | ||
func.func @test_poison(%a : tensor<32x32xf32>) -> tensor<33x33xf32> { | ||
%c = ub.poison : f32 | ||
// CHECK: %[[R:.*]], %[[T:.*]] = quidditch_snitch.start_tensor_copy %[[A]] | ||
// CHECK-SAME: pad with zero to [1, 1] | ||
// CHECK: %[[R2:.*]] = quidditch_snitch.wait_for_tensor_copy of %[[A]] | ||
// CHECK-SAME: to %[[R]] | ||
// CHECK-SAME: using %[[T]] | ||
%0 = tensor.pad %a low[0, 0] high[1, 1] { | ||
^bb0(%arg0: index, %arg1: index): | ||
tensor.yield %c : f32 | ||
} : tensor<32x32xf32> to tensor<33x33xf32> | ||
// CHECK: return %[[R2]] | ||
return %0 : tensor<33x33xf32> | ||
} |