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]-tosa-to-arith triggers Assertion Failure `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' #114762

Closed
xisang0 opened this issue Nov 4, 2024 · 0 comments · Fixed by #114921
Assignees
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir:tosa

Comments

@xisang0
Copy link

xisang0 commented Nov 4, 2024

Test on commit: (18f0f70)
steps to reproduce:

mlir-opt test.mlir -tosa-to-arith

test case:

func.func @pad_determine_val_i32(%arg0: tensor<?x?xi32> {bufferization.access = "read"}, %arg1: tensor<2x2xi32> {bufferization.access = "none"}) -> tensor<?x?xi32> {
    %0 = "tosa.const"() <{value = dense_resource<__elided__> : tensor<2x2xi32>}> : () -> tensor<2x2xi32>
    %1 = tosa.pad %arg0, %0 {__inplace_operands_attr__ = ["false", "false"]} : (tensor<?x?xi32>, tensor<2x2xi32>) -> tensor<?x?xi32>
    return {__inplace_operands_attr__ = ["true"]} %1 : tensor<?x?xi32>
}

crash trace:

mlir-opt: /home/workdir/llvm-project-19/llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(const From &) [To = mlir::DenseElementsAttr, From = mlir::Attribute]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible 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: ./mlir-opt /home/workdir/test5.mlir -tosa-to-arith
 #0 0x000060b08d7e8098 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./mlir-opt+0x1062098)
 #1 0x000060b08d7e5bbe llvm::sys::RunSignalHandlers() (./mlir-opt+0x105fbbe)
 #2 0x000060b08d7e8aa8 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007aaf68eaf520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007aaf68f039fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007aaf68eaf476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007aaf68e957f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007aaf68e9571b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007aaf68ea6e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x000060b08fd34ea5 mlir::tosa::PadOp::fold(mlir::tosa::PadOpGenericAdaptor<llvm::ArrayRef<mlir::Attribute>>) (./mlir-opt+0x35aeea5)
#10 0x000060b08fcfe5c5 llvm::LogicalResult mlir::Op<mlir::tosa::PadOp, mlir::OpTrait::ZeroRegions, mlir::OpTrait::OneResult, mlir::OpTrait::OneTypedResult<mlir::RankedTensorType>::Impl, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::AtLeastNOperands<2u>::Impl, mlir::OpTrait::OpInvariants, mlir::BytecodeOpInterface::Trait, mlir::InferShapedTypeOpInterface::Trait, mlir::OpTrait::InferShapedTypeOpAdaptor, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::AlwaysSpeculatableImplTrait, mlir::MemoryEffectOpInterface::Trait, mlir::tosa::TosaOp::Trait>::foldSingleResultHook<mlir::tosa::PadOp>(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (./mlir-opt+0x35785c5)
#11 0x000060b08fcfd585 mlir::RegisteredOperationName::Model<mlir::tosa::PadOp>::foldHook(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (./mlir-opt+0x3577585)
#12 0x000060b090bb115d mlir::Operation::fold(llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (./mlir-opt+0x442b15d)
#13 0x000060b090bb14f3 mlir::Operation::fold(llvm::SmallVectorImpl<mlir::OpFoldResult>&) (./mlir-opt+0x442b4f3)
#14 0x000060b090af509b mlir::OpBuilder::tryFold(mlir::Operation*, llvm::SmallVectorImpl<mlir::Value>&) (./mlir-opt+0x436f09b)
#15 0x000060b090a6f264 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#16 0x000060b090a6e677 mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) (./mlir-opt+0x42e8677)
#17 0x000060b090a6f81f mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>) (./mlir-opt+0x42e981f)
#18 0x000060b090a7712b mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (./mlir-opt+0x42f112b)
#19 0x000060b0903b4d06 (anonymous namespace)::TosaToArith::runOnOperation() TosaToArithPass.cpp:0:0
#20 0x000060b090a1179f mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./mlir-opt+0x428b79f)
#21 0x000060b090a11f82 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (./mlir-opt+0x428bf82)
#22 0x000060b090a1472e mlir::PassManager::run(mlir::Operation*) (./mlir-opt+0x428e72e)
#23 0x000060b090a0d252 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#24 0x000060b090a0cebb llvm::LogicalResult llvm::function_ref<llvm::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&)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#25 0x000060b090ab6725 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (./mlir-opt+0x4330725)
#26 0x000060b090a080b2 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (./mlir-opt+0x42820b2)
#27 0x000060b090a08363 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x4282363)
#28 0x000060b090a08572 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x4282572)
#29 0x000060b08d7c72e7 main (./mlir-opt+0x10412e7)
#30 0x00007aaf68e96d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#31 0x00007aaf68e96e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#32 0x000060b08d7c6e55 _start (./mlir-opt+0x1040e55)
Aborted (core dumped)
@github-actions github-actions bot added the mlir label Nov 4, 2024
@CoTinker CoTinker self-assigned this Nov 4, 2024
@EugeneZelenko EugeneZelenko added the crash Prefer [crash-on-valid] or [crash-on-invalid] label Nov 4, 2024
@EugeneZelenko EugeneZelenko changed the title [MLIR]-tosa-to-arithtriggers Assertion Failure `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' [MLIR]-tosa-to-arith triggers Assertion Failure `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' Nov 4, 2024
PhilippRados pushed a commit to PhilippRados/llvm-project that referenced this issue Nov 6, 2024
This PR fixes a crash when padding of `tosa.pad` is not dense elements.
Fixes llvm#114762.
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.

3 participants