<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/87512>87512</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            PDL cannot support named linalg ops.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          nirvedhmeshram
      </td>
    </tr>
</table>

<pre>
    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 %mat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