[Mlir-commits] [mlir] [mlir] Improve mlir-query by adding matcher combinators (PR #141423)
Denzel-Brian Budii
llvmlistbot at llvm.org
Sun Jun 15 04:01:19 PDT 2025
================
@@ -68,6 +69,7 @@ static Operation *extractFunction(std::vector<Operation *> &ops,
// Clone operations and build function body
std::vector<Operation *> clonedOps;
std::vector<Value> clonedVals;
+ // TODO: Handle extraction of operations containing block arguments.
----------------
chios202 wrote:
Looking at it again, I don't think I've outlined the issue correctly. The issues seems to arise whenever an operation's operands are mapped to block arguments like in the following snippet:
```mlir
func.func @slice_use_from_above(%arg0: tensor<5x5xf32>, %arg1: tensor<5x5xf32>) {
%0 = linalg.generic {indexing_maps = [#map, #map], iterator_types = ["parallel", "parallel"]} ins(%arg0 : tensor<5x5xf32>) outs(%arg1 : tensor<5x5xf32>) {
^bb0(%in: f32, %out: f32):
%2 = arith.addf %in, %in : f32
linalg.yield %2 : f32
} -> tensor<5x5xf32>
%collapsed = tensor.collapse_shape %0 [[0, 1]] : tensor<5x5xf32> into tensor<25xf32>
```
In contrast, an extraction similar to this file:
```mlir
func.func @slicing_linalg_op(%arg0 : index, %arg1 : index, %arg2 : index) {
%a = memref.alloc(%arg0, %arg2) : memref<?x?xf32>
%b = memref.alloc(%arg2, %arg1) : memref<?x?xf32>
%c = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
%d = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
linalg.matmul ins(%a, %b : memref<?x?xf32>, memref<?x?xf32>)
outs(%c : memref<?x?xf32>)
linalg.matmul ins(%a, %b : memref<?x?xf32>, memref<?x?xf32>)
outs(%d : memref<?x?xf32>)
memref.dealloc %c : memref<?x?xf32>
memref.dealloc %b : memref<?x?xf32>
memref.dealloc %a : memref<?x?xf32>
memref.dealloc %d : memref<?x?xf32>
return
}
```
Works as expected, without issuing an error.
https://github.com/llvm/llvm-project/pull/141423
More information about the Mlir-commits
mailing list