Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mlir][TOSAToTensor] --tosa-to-tensor crashed with assertion failure "cannot query rank of unranked shaped type" #68481

Closed
ghost opened this issue Oct 7, 2023 · 0 comments · Fixed by #68578
Assignees
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir:tosa

Comments

@ghost
Copy link

ghost commented Oct 7, 2023

git version: 3a3b84b

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)
@github-actions github-actions bot added the mlir label Oct 7, 2023
@LiqinWeng LiqinWeng self-assigned this Oct 9, 2023
@EugeneZelenko EugeneZelenko added crash Prefer [crash-on-valid] or [crash-on-invalid] mlir:tosa and removed mlir labels Oct 9, 2023
LiqinWeng added a commit to LiqinWeng/llvm-project that referenced this issue Oct 10, 2023
Fixes llvm#68481, In the following scenario, the conversion fails:
1. resultType of tosa.slice is UnrankedTensorType
2. tosa.slice.getsize().size() < resultType.getRank()
LiqinWeng added a commit that referenced this issue Oct 10, 2023
…8578)

Fixes #68481, In the following scenario, the conversion fails:
1. resultType of tosa.slice is UnrankedTensorType
2. tosa.slice.getsize().size() < resultType.getRank()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir:tosa
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants