<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=http://email.email.llvm.org/c/eJytVl1zmzgU_TX4RRMPSIDNAw-u3cxkpjPppN72cUeAMGqFxEgidvrr90qQYKex87G1AQOSjs45uvfKhaoe8h_cNsg2DNVKCLXncodu7oJwE4SrIA3Hwz_WvSxREIe10nuqqwAvA5xQvQsDskIBjqzSZTO_t0wapQOyDpJPSYDXMZxkPKMg2cBPTXBAPiOhSgDp5S-p9jLAGbSgATI6DxmQ6ycwvMavAGboyjWcZzfBkT_ggsWnQTlytEIUkA0aYCjAzNtezLceDj0aMQlAHzRlgHiv8I-LfBSome21fNR5ifqrYMFi82L8bJWhqKDlLyYrtFe9qNCOSabBzPfH2xOr5BAfCHyjw9uiapJDrv0wfH7gGD1Hcw2DyDTopRgJMLag1QUI3B7xPmIC2DDUNLy2fszgOgfQxWZcgOVZjQ7orI630D636q8OObe2cNMKrq9UZ9GVEw-XK8ElFTs0eAGt0Glc91JT06C9Kz3UGKbBgzQslTQWbYFNKsR9C3zgWGlNH-5YDZyEkjtHxL9XnQsc4AqJ4SJwafhv9q914gccaNh6Z_0w6ALyVn4uriS6kRU7QPMafWFyBzRgUjjc0t3Ieyp4hbjrAmngl3CBasoFq-ZPil0gW01L5vi8aAkmUYjCQ_j0WWSkJhn6gLheGr6TrBrEPGn0SPiay1L0FYO78cVqs3XXEX3eAKRLmsVELDomhsOIVTFFNUi-kZbpllUcsvJbQztAXV4kDKH49vZvLRXiOyutD7JBzBqlve-YuvtCKeEEujFXnVY_oTNo8eED-ngB17WS90wbWEd4cFVlq774UHv2OC-7DibNYpf4-GhZ8Kl6HNZJ5hKOSiUfWtUbJGnLTOdWF-qAp37HjLNjmBs8WsN2STvDPh86KquhT0tt2axkdcf2mltnneft21wWnCDddk7vxQ6rinbOqpN-k_qv1AIROc6mvYPHofGX_IsisnA2Tv6RU_9iKB_hEcPb7g-OsNqXrXgM_UsW3vq08LRXZ-Nu6v6dip6NIfh37JsSbXyx1VQa2J9aAw8bTgV0nybwiRfj2HmIJ_fiE_doVJQluUTw_cZMLR8NkRNh_1guXhY4BsgidBkWhc_q4KzKSZWRjM5obxul85La5uF388BnvRZ5Y21nHE0Mfyiud7AZ9MW8VO1Ux54x5Mb0zBFJSBgvZ00eJdkyTpMsrYs0YylOllUWLqq0iIo0rnAxE7RgwuSujmIs2R55CFfRk83s_zPgORQPqJ5hGi3DlIRzjOu0LFkUlllJCryAfy-shY1j7nDmSu9mOveQRb8z0Ci4sWZqhL3QlXmWD4V_ZrkVLJ92Lb9hzjyJ3DP4D7tSfgo>53048</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Assertion with
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cathyzhyi
</td>
</tr>
</table>
<pre>
With the following IR
```
func @forward(%arg0: !torch.vtensor<[5,4,3,3,1],f32> loc(unknown), %arg1: !torch.vtensor<[?,3,1,2],f32> loc(unknown)) -> !torch.vtensor<[5,?,3,3,2],f32> {
%0 = torch.aten.mul.Tensor %arg0, %arg1 : !torch.vtensor<[5,4,3,3,1],f32>, !torch.vtensor<[?,3,1,2],f32> -> !torch.vtensor<[5,?,3,3,2],f32>
return %0 : !torch.vtensor<[5,?,3,3,2],f32>
}
```
Tosa backend would generate
```
func @forward(%arg0: tensor<5x4x3x3x1xf32> loc(unknown), %arg1: tensor<?x3x1x2xf32> loc(unknown)) -> tensor<5x?x3x3x2xf32> {
%0 = "tosa.mul"(%arg0, %arg1) {shift = 0 : i32} : (tensor<5x4x3x3x1xf32>, tensor<?x3x1x2xf32>) -> tensor<5x?x3x3x2xf32>
return %0 : tensor<5x?x3x3x2xf32>
}
```
`mlir-opt -tosa-to-linalg tosa.mlir` would crash with assert `const T &llvm::ArrayRef<long>::operator[](size_t) const [T = long]: Assertion Index < Length && "Invalid index!"' failed.`
backtrace:
```
#10 0x0000000000793f39 llvm::ArrayRef<long>::operator[](unsigned long) const llvm/include/llvm/ADT/ArrayRef.h:0:7
#11 0x000000000201ed4a findIntermediateShape(llvm::ArrayRef<long>, llvm::ArrayRef<long>, llvm::SmallVector<long, 6u>&, bool) llvm-project/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp:941:20
#12 0x0000000002020f59 (anonymous namespace)::ReshapeConverterCollapseExpand::matchAndRewrite(mlir::tosa::ReshapeOp, mlir::tosa::ReshapeOpAdaptor, mlir::ConversionPatternRewriter&) const llvm-project/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp:1137:9
#13 0x0000000002042500 mlir::OpConversionPattern<mlir::tosa::ReshapeOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::Value>, mlir::ConversionPatternRewriter&) const llvm-project/mlir/include/mlir/Transforms/DialectConversion.h:424:12
#14 0x0000000002a1bcc3 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:1701:10
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVltvozgY_TXkxUpkbBKSBx4yyVSqNFJXnezs48qACd4xNrJNk86v38-GlqTTpBdNQyhg-_ic811IrsvH7B_hauRqjiotpT4ItUe39xHeRngdLfBwhNuqUwWKElxpc2CmjMgyInNm9jiiaxSR2GlT1LMHx5XVJqKbaP5lHpFNAl86fONovoV_FSUR_YqkLgCkUz-VPqiIrGAE9ZDxZciI3jyDkQ15A3CFpn7gMrsRjv4GF6VfeuXI08IoolvUwzCAmTWdnO0CHHoyYhSAPmlKD_FR4Z8X-STQcNcZ9aTzGvU3waJ0-2r-7LRlKGfFT65KdNCdLNGeK27AzI_n2zOr-TE5UvjEx_dl1SiH3oRl5PLCIXtO9uoX0XHRazkSEeJAq08QuDzhfcIEsGGprUXlwpredQGg6XYIwPKiRg90Ucd7aF-K-ptLLsUWLhopzFS3Dk29eDhNpVBM7lH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