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

    <tr>
        <th>Summary</th>
        <td>
            mlir-opt --tosa-to-linalg-pipeline fails in validation: element type 'f32' is not legal
        </td>
    </tr>

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

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

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

<pre>
    It seems `mlir-opt --tosa-to-linalg-pipeline` unconditionally uses the Basic Inference profile, and therefore only allows integer types.

The help-text for `--tosa-to-linalg-pipeline` says

> The default pipeline for converting TOSA operators to the equivalent operations using the tensor operations in LinAlg as well as LinAlg named operations.

so I would have assumed it should be usable also for floating point tensors.

I could not find any tests using `--tosa-to-linalg-pipeline` except tests that are supposed to fail. Other tests seems build a stripped down version of `--tosa-to-linalg-pipeline` using explicit `--pass-pipeline`.

The symptom is:
```
$ cat ../bad_tosa.mlir
module attributes {llvm.data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", llvm.target_triple = "x86_64-unknown-linux-gnu"} {
  func.func @main_graph() -> (tensor<1xf32>) {
    %0 = "tosa.const"() <{value = dense<0.000000e+00> : tensor<1xf32>}> : () -> tensor<1xf32>
    return %0 : tensor<1xf32>
  }
}

$ build/bin/mlir-opt --tosa-to-linalg-pipeline ../bad_tosa.mlir
../bad_tosa.mlir:3:10: error: 'tosa.const' op is not profile-aligned: element type 'f32' is not legal
 %0 = "tosa.const"() <{value = dense<0.000000e+00> : tensor<1xf32>}> : () -> tensor<1xf32>
         ^
../bad_tosa.mlir:3:10: note: see current operation: %0 = "tosa.const"() <{value = dense<0.000000e+00> : tensor<1xf32>}> : () -> tensor<1xf32>
../bad_tosa.mlir:4:5: error: 'func.return' op is not profile-aligned: element type 'f32' is not legal
 return %0 : tensor<1xf32>
    ^
../bad_tosa.mlir:4:5: note: see current operation: "func.return"(%0) : (tensor<1xf32>) -> ()
```
Commit 2bcbe40f8a1c6cc9a256711261d8aa8fde50f7b3.

I have attached a full transcript.

[bad_tosa.txt](https://github.com/llvm/llvm-project/files/15094963/bad_tosa.txt)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVk2P4jgT_jXmUgpKnC84cKCbQWrpfTUrzdxbxqmAdx07a5dp-PcrO8DS0z3bvdIeBiHHcX34earK5Qjv1d4grlj9wOrNTAQ6WLf6Dd3_le4MutnOdufVE4FHHDywJh-0cpkdCbKMrBcZ2UwrI_Q-G9WIWhlkTQ7BSGs6RcoaofUZgkcPdEB4EF5JeDI9OjQSYXS2VxoZfwRhuqjisLcOwRp9BqG1ffGgDOEeHdB5RD9n-Ybl62n8fkA4oB4zwhNBb12E-I_IvDj7ew-s_ALRS4e9CJrgqpucSWuO6EiZPXz_-m0NdkQnyDoPZBMd_DOoo9Bo6CJT1ngIPlpEOaHx1t3LlIH_KbPWexAeXlDr-LysGDFgd6f8iqq38AQvNugODuKIILwPUV0R-ENa3iEEL3YaQWhvE4FeW5Hgj1YZusB57fcJZLI2lqBXpgNhzkDo6crjo4jiSeJIFxM6CALhEHwYR-uxi5HqhdJz-BqTe1GbymkXlO5AgCenxhE76OyLgSM6r6wB23-49QQQT6NWUtGkPgrv75Xe1Is_DyPZAZRn5bUImvzyn155BVIQzOeMb3eie44Q5rHyJ_lguxCjTOTULhB6YO2D1sdh3gkSz1qcbSBg5QYY55gNrFxjNvI2Z-W65GmIr8Xr1zhrqjRk6jYp-IKV64Ivsn6RX2YmLTVX86bKvkU1zuMxSjhIuD3Sc4yrxiuS06J5bqosmD-MfTExnuGU7U2Ihu0mcpjoAfTByHkcgFX5IJR53jsxHljcZAlZPDOML6ZqYuVjceojkC9ReOcFgPE6v-6eYiit8ZSAJk-sfGTtw1HoMIHs0Hhk5WM-z9MPGX_I87RduYa3-7Wbq-we2lu9G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