<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/132961>132961</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] Redundant signed cast attribute added when building `linalg.matmul`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
andfau-amd
</td>
</tr>
</table>
<pre>
The Python bindings for constructing `linalg.matmul`, `linalg.matmul_transpose_a` and `linalg.matmul_transpose_b` add redundant `cast` attributes. For example:
```mlir
%2 = linalg.matmul_transpose_b {cast = #linalg.type_fn<cast_signed>} ins(%arg0, %arg1 : tensor<512x14336xf16>, tensor<4096x14336xf16>) outs(%1 : tensor<512x4096xf32>) -> tensor<512x4096xf32>
```
Here the `{cast = #linalg.type_fn<cast_signed>}` is meaningless because the result type is float. Moreover, at least when using the Python builder functions (`linalg.matmul()`, `linalg.matmul_transpose_a()`, `linalg.matmul_transpose_b()`), it is not possible to request that this attribute not be added.
There are a few ways to look at this issue:
- Is the problem that this builder is adding the attribute unconditionally?
- Is the problem that the assembly format is showing the attribute even when it has the default value?
I am not sure if this should be seen as purely a Python bindings issue or if it has C++ ramifications.
Please see this discussion for more context: https://github.com/nod-ai/iree-kernel-benchmark/pull/57/files#r2006203540
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUlE9v4zYQxT8NfRnYkEhJjg46bJwVuocCi2LvASWOLDYU6XJIJ_72BSmnDjZNsAvIf_n4OPPT00gifbSIHavvWf2wkTHMznfSqknGrVzUZnDq0v2YEb5fwuwsDNoqbY8Ek_MwOkvBxzFoewTWFEZbaY67RYYlGtYUjB_e_f0YvLR0coSPkjUFSKs-0wxZoxR4VNEqaUNSj5JCXgjB6yEGpB30zgO-yOVkkIkvrMhXU6zXYrRPv3nNgYkH-PA4YPv75J5VjIurMFxO-DhZJg5p8TFTU0x8ZfsH0JYYv2O8l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