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

    <tr>
        <th>Summary</th>
        <td>
            [mlir][Tosa][tosa-to-linalg] Code design problem of Tosa to Linalg conversion
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    
When I use `mlir-opt -pass-pipeline="func.func(tosa-to-linalg)"` to lowering the tosa dialect,
I encounter the error failed to legalize operation `tosa.max_pool2d`.
After reading the source code, I find that this pass can only handle part ops of Tosa,
while some of the rest ops are marked as legal directly in `TosaToLinalgPass.cpp`.
``` 
    // in file TosaToLinalgPass.cpp

    target.addLegalOp<tosa::ApplyScaleOp>();
    target.addLegalOp<tosa::IfOp>();
    target.addLegalOp<tosa::ConstOp>();
    target.addLegalOp<tosa::WhileOp>();
    target.addLegalOp<tosa::SliceOp>();
``` 
but the other part is not processed, such as `tosa.max_pool2d`. 
`TosaToLinalgPass.cpp` should probably use a partial conversion or be absolutely complete in terms of defining the legality criteria.



</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVFFvnDAM_jXwEh2CUOjxwMP1bpUqVdq0VurjZIiBbCFBSWjX_fo5QddWVSdNRSgEbH_-HH-mM-K5TfJTkh8eJtTshq0OWVLns5J2ZxbPdgs4t1vkgkpqTMpTwvmw6j4LS8L33jjYebMjK6gx4Q3ZKZ55w5R5Qiv1yPyELPgxIUFh7xN-3HLeMNS9WbVHG53QWmPZAFKhiAg4gpJ_kJkFLXhpdOAWoLIZfv9YjFFc0JdsgzsMAcgiiHNWZ1bbI-uNQEpK5Q1SE_IEnhbpWCiO9aCZ0eqZTaCFQvpoPWV0zAzsnnK90H2aiBhhzhhMAd-i21zBIpvB_iLe4DbeVK2lYglXRtoB6t7cxnP6RnmzflleudNuu9n2zuhK-DXdIXwIiT8E2IJfQjzYEX0GQtwGDl-XpDyG80rKA92HZVHPdz01IRi-UPtCw8qr_42_GT4XdzTa-c-FPoQz_1zonZL9h6Hvz7pbfeymocVu7SdtaOPZYk2PzqEI6nFrP4XufixB9oL9j0YzN5lViYDZQUeyCKMGMR2NBWlUP6J1QeM0Ax2ZOmfU6pE8ezMvCj0GKZDE5yhNgSTms9C3SfHkaiV5SMjeKmNbU2yLum7qvCrLKhVtKZqygdRLr7BNqqsw80l1ol1Ufdy9G-_qxI40S5TbyVHHUhTO50EJI7uV_aaadLWqnbxfXOhKVPQo_bR2GVVFL0o9nh87wvsZ_w_X0rkVHW2qhvMqndrLoRqGHrCEct8I3oSrLqAp-4t90cGQKuhQuVAHsUxly3POi4Lv87KoyiIrLnK-vwSou6Guh2GfXOQ4048mC4kzY8fUtpFDt46OjEo6716N1EYqGPGMD6ufjG0XBL3676jTSLiNbP8CiBiySQ">