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

    <tr>
        <th>Summary</th>
        <td>
            Slice Op folding failing for valid case
        </td>
    </tr>

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

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

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

<pre>
    Hi, I am working on the [Torch-MLIR](https://github.com/llvm/torch-mlir) project. The code crashes while folding of `tosa.Slice` op. Particularly for this case:
```
//===-------------------------------------------===//
Processing operation : 'tosa.slice'(0x7a018b0) {
  %61 = "tosa.slice"(%39) {size = [1, 7], start = [0, 0]} : (tensor<1x512xi64>) -> tensor<1x7xi64>
```
When I debugged the issue, I found out that the code is crashing at: https://github.com/llvm/llvm-project/blob/4d4ca6c9d036a06bf0723786112dd17e491b2f53/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp#L864 due to this assertion: https://github.com/llvm/llvm-project/blob/4d4ca6c9d036a06bf0723786112dd17e491b2f53/mlir/lib/IR/BuiltinAttributes.cpp#L1030-L1031  The reason is that the input element type from torch tensor is si64 while the assertion compares that with i64, hence it crashes. If we disable this assertion, then it folds the slice op. Can someone let me know what could be the reason behind this and how to fix this?

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzFVE1v5SYU_TV4g2Jh8Mfzwoskb0aNNFVHbaRZY3P9TIONBTgvmV_fC3Zep1KltqtalgHfDw73nEtv1Xv3kyb8kT5ROdOrdS96uVC70DABJdXDs3XDdPfzl6dfSXUm_DSFsHoi7gn_jO9Fh2nr88HOuDDmNQ4hRcxGO8Jbujr7Owwhp8-Yb7AKP076CTy9TtoAHa1RaceRkpoF62X-m9ED4ILaNadfpQt62Ix05h2dHeLSng7SQwTBzoTdo-vx7suEjIjz_t79--cWc6RI6b46O4D3CeMKTga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