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]Converting tosa to linalg crashed with Assertion Failure `isIntOrFloat() && "only integers and floats have a bitwidth"' #61383

Open
BealZephyr opened this issue Mar 13, 2023 · 1 comment
Assignees
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir:linalg mlir:tosa

Comments

@BealZephyr
Copy link

BealZephyr commented Mar 13, 2023

Test on commit: e0282cb
The same crash occurred in LLVM 16

steps to reproduce:

mlir-opt -pass-pipeline=builtin.module(func.func(tosa-to-linalg)) test.mlir

test case:

func.func @main(%arg0: tensor<13x21x3x!quant.uniform<u8:f32, 0.015655439347028732:127>>) {
    %0 = "tosa.rescale"(%arg0) {double_round = false, input_zp = 127 : i32, multiplier = array<i32: 1073741824>, output_zp = -1 : i32, per_channel = false, scale32 = true, shift = array<i32: 30>} : (tensor<13x21x3x!quant.uniform<u8:f32, 0.015655439347028732:127>>) -> tensor<13x21x3x!quant.uniform<i8:f32, 0.015655439347028732:-1>>
    return
}

crash trace:

mlir-opt: /home/verify/llvm-project/mlir/lib/IR/Types.cpp:112: unsigned int mlir::Type::getIntOrFloatBitWidth() const: Assertion `isIntOrFloat() && "only integers and floats have a bitwidth"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/verify/llvm-project/build/bin/mlir-opt -pass-pipeline=builtin.module(func.func(tosa-to-linalg)) test.mlir
 #0 0x0000560b7c6ee05a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/verify/llvm-project/build/bin/mlir-opt+0x22205a)
 #1 0x0000560b7c6eb55c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f4fe17de980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #3 0x00007f4fe08d6e87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #4 0x00007f4fe08d87f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
 #5 0x00007f4fe08c83fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0
 #6 0x00007f4fe08c8472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
 #7 0x0000560b7e1540bf mlir::Type::getIntOrFloatBitWidth() const (/home/verify/llvm-project/build/bin/mlir-opt+0x1c880bf)
 #8 0x0000560b7db4a00b (anonymous namespace)::RescaleConverter::matchAndRewrite(mlir::tosa::RescaleOp, mlir::PatternRewriter&) const::'lambda0'(mlir::OpBuilder&, mlir::Location, mlir::ValueRange)::operator()(mlir::OpBuilder&, mlir::Location, mlir::ValueRange) const TosaToLinalg.cpp:0:0
 #9 0x0000560b7cbfa184 buildGenericRegion(mlir::OpBuilder&, mlir::Location, mlir::Region&, mlir::ValueRange, mlir::ValueRange, llvm::function_ref<void (mlir::OpBuilder&, mlir::Location, mlir::ValueRange)>) LinalgOps.cpp:0:0
#10 0x0000560b7cc155d7 mlir::linalg::GenericOp::build(mlir::OpBuilder&, mlir::OperationState&, mlir::TypeRange, mlir::ValueRange, mlir::ValueRange, llvm::ArrayRef<mlir::AffineMap>, llvm::ArrayRef<mlir::utils::IteratorType>, llvm::StringRef, llvm::StringRef, llvm::function_ref<void (mlir::OpBuilder&, mlir::Location, mlir::ValueRange)>, llvm::ArrayRef<mlir::NamedAttribute>) (/home/verify/llvm-project/build/bin/mlir-opt+0x7495d7)
#11 0x0000560b7cc1576a mlir::linalg::GenericOp::build(mlir::OpBuilder&, mlir::OperationState&, mlir::TypeRange, mlir::ValueRange, mlir::ValueRange, llvm::ArrayRef<mlir::AffineMap>, llvm::ArrayRef<mlir::utils::IteratorType>, llvm::function_ref<void (mlir::OpBuilder&, mlir::Location, mlir::ValueRange)>, llvm::ArrayRef<mlir::NamedAttribute>) (/home/verify/llvm-project/build/bin/mlir-opt+0x74976a)
#12 0x0000560b7db6b170 (anonymous namespace)::RescaleConverter::matchAndRewrite(mlir::tosa::RescaleOp, mlir::PatternRewriter&) const TosaToLinalg.cpp:0:0
#13 0x0000560b7db424c8 mlir::detail::OpOrInterfaceRewritePatternBase<mlir::tosa::RescaleOp>::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/home/verify/llvm-project/build/bin/mlir-opt+0x16764c8)
#14 0x0000560b7e38a639 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&)>) (/home/verify/llvm-project/build/bin/mlir-opt+0x1ebe639)
#15 0x0000560b7e028607 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#16 0x0000560b7e0292a8 (anonymous namespace)::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>, llvm::function_ref<void (mlir::Diagnostic&)>) DialectConversion.cpp:0:0
#17 0x0000560b7e02ce7f mlir::applyFullConversion(mlir::Operation*, mlir::ConversionTarget&, mlir::FrozenRewritePatternSet const&) (/home/verify/llvm-project/build/bin/mlir-opt+0x1b60e7f)
#18 0x0000560b7db3942b (anonymous namespace)::TosaToLinalg::runOnOperation() TosaToLinalgPass.cpp:0:0
#19 0x0000560b7dfabea9 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/verify/llvm-project/build/bin/mlir-opt+0x1adfea9)
#20 0x0000560b7dfac1ca mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/home/verify/llvm-project/build/bin/mlir-opt+0x1ae01ca)
#21 0x0000560b7dfac548 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::'lambda'(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&)::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const Pass.cpp:0:0
#22 0x0000560b7dfab685 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/home/verify/llvm-project/build/bin/mlir-opt+0x1adf685)
#23 0x0000560b7dfabe1a mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/verify/llvm-project/build/bin/mlir-opt+0x1adfe1a)
#24 0x0000560b7dfacd03 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (.constprop.495) Pass.cpp:0:0
#25 0x0000560b7dfad3ed mlir::PassManager::run(mlir::Operation*) (/home/verify/llvm-project/build/bin/mlir-opt+0x1ae13ed)
#26 0x0000560b7dfa03f3 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#27 0x0000560b7dfa0b29 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
#28 0x0000560b7dfa0e51 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
#29 0x0000560b7e066c80 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) (/home/verify/llvm-project/build/bin/mlir-opt+0x1b9ac80)
#30 0x0000560b7df9db33 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/home/verify/llvm-project/build/bin/mlir-opt+0x1ad1b33)
#31 0x0000560b7dfa1238 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) (/home/verify/llvm-project/build/bin/mlir-opt+0x1ad5238)
#32 0x0000560b7c6ba470 main (/home/verify/llvm-project/build/bin/mlir-opt+0x1ee470)
#33 0x00007f4fe08b9c87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#34 0x0000560b7c6cd10a _start (/home/verify/llvm-project/build/bin/mlir-opt+0x20110a)
@EugeneZelenko EugeneZelenko added mlir:linalg crash Prefer [crash-on-valid] or [crash-on-invalid] mlir:tosa and removed new issue labels Mar 13, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 13, 2023

@llvm/issue-subscribers-mlir-linalg

@CoTinker CoTinker self-assigned this Sep 4, 2024
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:linalg mlir:tosa
Projects
None yet
Development

No branches or pull requests

4 participants