Issue 87512
Summary PDL cannot support named linalg ops.
Labels new issue
Assignees
Reporter nirvedhmeshram
    I tried a simple test pattern to convert matmul to matmul_transpose_b but got this error.
```
../matmul_dynamic.mlir:6:8: error: 'linalg.matmul_transpose_b' op requires one region
  %2 = linalg.matmul ins(%lhs, %rhs : !A_TYPE, !B_TYPE)
       ^
../matmul_dynamic.mlir:6:8: note: see current operation: %0 = "linalg.matmul_transpose_b"(%arg0, %arg1, %arg2) <{operandSegmentSizes = array<i32: 0, 0>}> : (tensor<?x?xf32>, tensor<?x?xf32>, tensor<?x?xf32>) -> tensor<?x?xf32>
```
Here is the sample and the pdl IR respectively
```
!A_TYPE = tensor<?x?xf32>
!B_TYPE = tensor<?x?xf32>
!C_TYPE = tensor<?x?xf32>
func.func @matmul_small_1(%lhs : !A_TYPE,
    %rhs : !B_TYPE, %acc : !C_TYPE) -> !C_TYPE {
  %2 = linalg.matmul ins(%lhs, %rhs : !A_TYPE, !B_TYPE)
      outs(%acc : !C_TYPE) -> !C_TYPE
  return %2 : !C_TYPE
}
```

```
pdl.pattern @mlp : benefit(1) {
  %lhs = pdl.operand
  %rhs = pdl.operand
  %acc = pdl.operand
  %matmul_type = pdl.type : tensor<?x?xf32>
  %matmul = pdl.operation "linalg.matmul" (%lhs, %rhs, %acc : !pdl.value, !pdl.value, !pdl.value) -> (%matmul_type : !pdl.type)

  pdl.rewrite %matmul {
    %matmul_transpose = pdl.operation "linalg.matmul_transpose_b" (%lhs, %rhs, %acc : !pdl.value, !pdl.value, !pdl.value) -> (%matmul_type : !pdl.type)
    pdl.replace %matmul with %matmul_transpose
  }
}
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to