[mlir] Assertion `llvm::isa<StringAttr>(attr) && "expected string value for non-DenseElementType element"' 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 -test-convert-to-spirv a.mlir`
a.mlir:
```mlir
module {
func.func @test_vectorize_copy(%arg0: tensor<8x8xvector<4xi8>>, %arg1: tensor<8x8xvector<4xi8>>) -> tensor<8x8xvector<4xi8>> {
%0 = linalg.copy ins(%arg0 : tensor<8x8xvector<4xi8>>) outs(%arg1 : tensor<8x8xvector<4xi8>>) -> tensor<8x8xvector<4xi8>>
return %0 : tensor<8x8xvector<4xi8>>
}
module attributes {transform.with_named_sequence} {
transform.named_sequence @__transform_main(%arg0: !transform.any_op {transform.readonly}) {
%0 = transform.structured.match ops{["linalg.copy"]} in %arg0 : (!transform.any_op) -> !transform.any_op
transform.structured.vectorize %0 : !transform.any_op
transform.yield
}
}
}
```
stack trace:
```
mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/mlir/lib/IR/BuiltinAttributes.cpp:881: static DenseElementsAttr mlir::DenseElementsAttr::get(ShapedType, ArrayRef): Assertion `llvm::isa(attr) && "expected string value for non-DenseElementType element"' 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 -test-convert-to-spirv 37.mlir
#0 0x000055c6d53730f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20300f8)
#1 0x000055c6d536ff91 llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x202cf91)
#2 0x000055c6d5374216 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007fca5bf5b420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007fca5b59800b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#5 0x00007fca5b577859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
#6 0x00007fca5b577729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
#7 0x00007fca5b577729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
#8 0x00007fca5b588fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#9 0x000055c6ddf7f401 mlir::DenseElementsAttr::get(mlir::ShapedType, llvm::ArrayRef) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xac3c401)
#10 0x000055c6ddf72d12 mlir::Builder::getZeroAttr(mlir::Type) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xac2fd12)
#11 0x000055c6d9d0fb3f (anonymous namespace)::FuncOpVectorUnroll::matchAndRewrite(mlir::func::FuncOp, mlir::PatternRewriter&) const SPIRVConversion.cpp:0:0
#12 0x000055c6ddcc2b5d void llvm::function_ref::callback_fn, llvm::function_ref, llvm::function_ref)::$_0>(long) PatternApplicator.cpp:0:0
#13 0x000055c6ddcbf4ba mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref, llvm::function_ref, llvm::function_ref) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa97c4ba)
#14 0x000055c6ddc97d94 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#15 0x000055c6ddc96e12 void llvm::function_ref::callback_fn<(anonymous namespace)::RegionPatternRewriteDriver::simplify(bool*) &&::$_2>(long) GreedyPatternRewriteDriver.cpp:0:0
#16 0x000055c6ddc93dfb mlir::applyPatternsGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa950dfb)
#17 0x000055c6d9d07495 mlir::spirv::unrollVectorsInSignatures(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x69c4495)
#18 0x000055c6d5b52825 (anonymous namespace)::TestConvertToSPIRVPass::runOnOperation() TestConvertToSPIRVPass.cpp:0:0
#19 0x000055c6ddd1e502 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)
#20 0x000055c6ddd1f344 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)
#21 0x000055c6ddd2625a mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa9e325a)
#22 0x000055c6ddd25b8f mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa9e2b8f)
#23 0x000055c6d54223d0 performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#24 0x000055c6d5421606 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
#25 0x000055c6de0728a5 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)
#26 0x000055c6d5418666 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)
#27 0x000055c6d5418a45 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20d5a45)
#28 0x000055c6d5418da5 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20d5da5)
#29 0x000055c6d5358b82 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x2015b82)
#30 0x00007fca5b579083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#31 0x000055c6d53586be _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20156be)
Aborted (core dumped)
```
Contributor guide
Research direction
Run mlir-opt -test-convert-to-spirv with the provided a.mlir reproducer and inspect SPIRVConversion.cpp, where the stack trace reaches FuncOpVectorUnroll::matchAndRewrite, along with BuiltinAttributes.cpp's DenseElementsAttr::get. Trace why the vectorized signature reaches Builder::getZeroAttr with an invalid element attribute, then verify the reproducer no longer asserts and add regression coverage where the existing MLIR tests for this conversion reside.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100