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

    <tr>
        <th>Summary</th>
        <td>
            [mlir][TOSAToTensor] --tosa-to-tensor crashed with assertion failure "cannot query rank of unranked shaped type"
        </td>
    </tr>

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

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

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

<pre>
    git version: 3a3b84b180278207731451dfac24f47d02b50e84

system: ```Ubuntu 20.04.6 LTS (Focal Fossa)```

reproduced with: ```mlir-opt --tosa-to-tensor a.mlir```

a.mlir:

```
func.func @func2() {
  %true = arith.constant true
  %from_elements = tensor.from_elements %true, %true, %true, %true, %true, %true, %true, %true, %true, %true, %true, %true, %true, %true, %true, %true, %true, %true, %true, %true, %true : tensor<21xi1>
  %90 = tosa.slice %from_elements {size = array<i64>, start = array<i64>} : (tensor<21xi1>) -> tensor<*xi1>
  return 
}
```

trace:
```
mlir-opt: /data/bin/llvm-project/build/tools/mlir/include/mlir/IR/BuiltinTypeInterfaces.h.inc:156: int64_t mlir::ShapedType::getRank() const: Assertion `(*this).hasRank() && "cannot query rank of unranked shaped type"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /data/bin/llvm-project/build/bin/mlir-opt --tosa-to-tensor a.mlir
 #0 0x0000559c397e733f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/bin/llvm-project/build/bin/mlir-opt+0x159633f)
 #1 0x0000559c397e43d4 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f2de8adb420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f2de85c600b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f2de85a5859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007f2de85a5729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007f2de85b6fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #7 0x0000559c3bbea3a9 (anonymous namespace)::SliceConverter::matchAndRewrite(mlir::tosa::SliceOp, mlir::tosa::SliceOpAdaptor, mlir::ConversionPatternRewriter&) const TosaToTensor.cpp:0:0
 #8 0x0000559c3bbe4f98 mlir::OpConversionPattern<mlir::tosa::SliceOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::Value>, mlir::ConversionPatternRewriter&) const (/data/bin/llvm-project/build/bin/mlir-opt+0x3993f98)
 #9 0x0000559c3c307b9a mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data/bin/llvm-project/build/bin/mlir-opt+0x40b6b9a)
#10 0x0000559c3ef33038 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) (/data/bin/llvm-project/build/bin/mlir-opt+0x6ce2038)
#11 0x0000559c3c316c59 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#12 0x0000559c3c3175e7 (anonymous namespace)::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>, llvm::function_ref<void (mlir::Diagnostic&)>) DialectConversion.cpp:0:0
#13 0x0000559c3c319a54 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>*) (/data/bin/llvm-project/build/bin/mlir-opt+0x40c8a54)
#14 0x0000559c3bbe386b (anonymous namespace)::TosaToTensor::runOnOperation() TosaToTensorPass.cpp:0:0
#15 0x0000559c3c26ee1e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x401de1e)
#16 0x0000559c3c26f2fa mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/bin/llvm-project/build/bin/mlir-opt+0x401e2fa)
#17 0x0000559c3c26fb24 mlir::PassManager::run(mlir::Operation*) (/data/bin/llvm-project/build/bin/mlir-opt+0x401eb24)
#18 0x0000559c3c2603eb performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#19 0x0000559c3c2618a4 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) MlirOptMain.cpp:0:0
#20 0x0000559c3c261a54 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#21 0x0000559c3c35fce4 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/data/bin/llvm-project/build/bin/mlir-opt+0x410ece4)
#22 0x0000559c3c25ad27 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/bin/llvm-project/build/bin/mlir-opt+0x4009d27)
#23 0x0000559c3c261d7b mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x4010d7b)
#24 0x0000559c3972023b main (/data/bin/llvm-project/build/bin/mlir-opt+0x14cf23b)
#25 0x00007f2de85a7083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#26 0x0000559c397b7ede _start (/data/bin/llvm-project/build/bin/mlir-opt+0x1566ede)
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWVtv2zgW_jXMCxGDInV9yINzMbZAgwRJdl8NijqyuZVJDUm1SX_9gpJsS7KTOE13dnYG09gWD8_lO1eK3Fq5UgAXKLpE0fUZb9xamwuutHrZ6MbeXj2e5bp4uVhJh7-DsVIrxOaYcZanYR6khCYpJUnCgjAKipILGpZhUhCaRwTSEJFrRObdX_tiHWz8bhST7v9_5o1yDaZkRsJZjL8-PWJE04UWvMILbS1HNNsRD3kZqI0uGgEF_iHdesR0U0lzrmuHz8-dtvzc6XMHymqD-cyvHWXYL7H58OGEsmyUmPk_GIXEf1JEU0QzjJLLjgJjRCNnGsCIXWNupFvPhFbWceWwfz4gK43eLKGCDShnW_pOy9lkoWOI6NXf9iv27uuMR-yKBs8yQOxmAFVGOny05TNbSQFH8Esurfy5xd3wF8SuZBx6PvQKW8eNO7aWXLfCEU0P5dMMnyN2s9cM0flYNQOuMQr3wZJcH42a7q8zXMA-vMYk24jtVFkU3HFEF7lUiC6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