[mlir] Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
git version: 5492d06d4fb99795b3b7247be374cdcb47f5ac03
system: `Ubuntu 18.04.6 LTS`
reproduce with: `mlir-opt -convert-vector-to-gpu a.mlir`
a.mlir:
```mlir
module {
func.func @scf_if_inplace2(%arg0: memref, %arg1: vector<5xf32>, %arg2: vector<5xf32>, %arg3: index) -> (vector<5xf32>, vector<5xf32>) {
%c0 = arith.constant 0 : index
%c1 = arith.constant 1 : index
%0:2 = scf.while (%arg4 = %arg3, %arg5 = %arg1) : (index, vector<5xf32>) -> (index, vector<5xf32>) {
%2 = arith.cmpi slt, %arg4, %c1 : index
scf.condition(%2) %arg4, %arg5 : index, vector<5xf32>
} do {
^bb0(%arg4: index, %arg5: vector<5xf32>):
%2 = arith.addf %arg5, %arg5 : vector<5xf32>
scf.yield %arg4, %2 : index, vector<5xf32>
}
%1:2 = scf.while (%arg4 = %arg3, %arg5 = %arg2) : (index, vector<5xf32>) -> (index, vector<5xf32>) {
%2 = arith.cmpi slt, %arg4, %c1 : index
scf.condition(%2) %arg4, %arg5 : index, vector<5xf32>
} do {
^bb0(%arg4: index, %arg5: vector<5xf32>):
%2 = arith.addf %arg5, %arg5 : vector<5xf32>
scf.yield %arg4, %2 : index, vector<5xf32>
}
return %0#1, %1#1 : vector<5xf32>, vector<5xf32>
}
}
```
stack trace:
```
mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/llvm/include/llvm/Support/Casting.h:572: decltype(auto) llvm::cast(From *) [To = mlir::scf::ForOp, From = mlir::Operation]: Assertion `isa(Val) && "cast() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -convert-vector-to-gpu 49.mlir
#0 0x000055a31dcff0f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20300f8)
#1 0x000055a31dcfbf91 llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x202cf91)
#2 0x000055a31dd00216 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007ff349714420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007ff348d5100b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#5 0x00007ff348d30859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
#6 0x00007ff348d30729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
#7 0x00007ff348d30729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
#8 0x00007ff348d41fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#9 0x000055a3224509be (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x67819be)
#10 0x000055a32244d887 mlir::convertVectorToMMAOps(mlir::RewriterBase&, mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x677e887)
#11 0x000055a32245b63d (anonymous namespace)::ConvertVectorToGPUPass::runOnOperation() VectorToGPU.cpp:0:0
#12 0x000055a3266aa502 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa9db502)
#13 0x000055a3266ab344 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa9dc344)
#14 0x000055a3266b225a mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa9e325a)
#15 0x000055a3266b1b8f mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa9e2b8f)
#16 0x000055a31ddae3d0 performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#17 0x000055a31ddad606 llvm::LogicalResult llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>::callback_fn>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0>(long, std::unique_ptr>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#18 0x000055a3269fe8a5 mlir::splitAndProcessBuffer(std::unique_ptr>, llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xad2f8a5)
#19 0x000055a31dda4666 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20d5666)
#20 0x000055a31dda4a45 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20d5a45)
#21 0x000055a31dda4da5 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20d5da5)
#22 0x000055a31dce4b82 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x2015b82)
#23 0x00007ff348d32083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#24 0x000055a31dce46be _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20156be)
Aborted (core dumped)
```
Contributor guide
Research direction
Run mlir-opt -convert-vector-to-gpu with the supplied a.mlir reproducer and inspect VectorToGPU.cpp, especially convertVectorToMMAOps where the stack trace reaches the failing cast. Trace how the scf.while operations are handled and add a regression test for this input; done means the pass no longer aborts on the reproducer.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100