[Mlir-commits] [mlir] [MLIR] Add pattern to bubble up tensor.extract_slice (PR #126898)

Andrzej WarzyƄski llvmlistbot at llvm.org
Sun Feb 23 09:28:10 PST 2025


================
@@ -0,0 +1,74 @@
+// RUN: mlir-opt -split-input-file -transform-interpreter  %s | FileCheck %s
+
+// CHECK-LABEL:   func.func @bubble_up_extract_slice_through_expand_shape(
+// CHECK-SAME:                                                    %[[ARG0:.*]]: tensor<60xf32>) -> tensor<1x1x5xf32> {
+// CHECK:           %[[C1:.+]] = arith.constant 5 : index
+// CHECK:           %[[EXTRACT:.*]] = tensor.extract_slice %[[ARG0]]{{\[}}%[[C1]]] [5] [1] : tensor<60xf32> to tensor<5xf32>
----------------
banach-space wrote:

```suggestion
// CHECK:           %[[EXTRACT:.*]] = tensor.extract_slice %[[ARG0]][%[[C1]]] [5] [1] : tensor<60xf32> to tensor<5xf32>
```

Similar suggestion elsewhere. IIRC, regex matching would be required if it was `[[` rather than `[`.

https://github.com/llvm/llvm-project/pull/126898


More information about the Mlir-commits mailing list