Skip to content

Commit 1263704

Browse files
asraacopybara-github
authored andcommitted
add better error message for tensor.extract/insert_slice op in layout system
Part of #2028 cc @kragall PiperOrigin-RevId: 797461798
1 parent f19b9fe commit 1263704

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/Transforms/LayoutPropagation/NewLayoutPropagation.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ LogicalResult NewLayoutPropagation::visitOperation(Operation* op) {
234234
.Case<affine::AffineForOp>([&](auto op) { return visitOperation(op); })
235235
// tensor ops
236236
.Case<tensor::ExtractOp>([&](auto op) { return visitOperation(op); })
237+
.Case<tensor::ExtractSliceOp, tensor::InsertSliceOp>([&](auto op) {
238+
// TODO(#2028): Support tensor.extract_slice and tensor.insert_slice in
239+
// layout.
240+
return op->emitError()
241+
<< "Layout propagation not supported for this op";
242+
})
237243
// tensor ops
238244
.Case<CollapseShapeOp, ExpandShapeOp>(
239245
[&](auto op) { return visitOperation(op); })
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: heir-opt --new-layout-propagation %s -verify-diagnostics
2+
3+
module {
4+
func.func @test(%arg0: !secret.secret<tensor<16xi8>>) -> !secret.secret<tensor<11x16xi8>> {
5+
%0 = tensor.empty() : tensor<11x16xi8>
6+
%1 = secret.generic(%arg0: !secret.secret<tensor<16xi8>>) {
7+
^body(%input0: tensor<16xi8>):
8+
// expected-error @+1 {{Layout propagation not supported for this op}}
9+
%extracted_slice = tensor.extract_slice %input0[0] [4] [1] : tensor<16xi8> to tensor<4xi8>
10+
%inserted_slice = tensor.insert_slice %extracted_slice into %0[0, 0] [1, 4] [1, 1] : tensor<4xi8> into tensor<11x16xi8>
11+
secret.yield %inserted_slice : tensor<11x16xi8>
12+
} -> !secret.secret<tensor<11x16xi8>>
13+
return %1 : !secret.secret<tensor<11x16xi8>>
14+
}
15+
}

0 commit comments

Comments
 (0)