llvm / llvm/llvm-project

[mlir][sparse_tensor](sparsification) mlir-opt crashes at Sparsification.cpp:204 with assertion `static_cast<Dimension>(exprs.size()) == lvlRank && "AffineMap does not have dimension-rank many results"' failed.

Open
#204,290 1 comment 0 reactions 0 assignees View on GitHub
crash mlir
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

git version: bf8b7787f96a9e6d42c5fc4f49c25352b81e90cb

MLIR Program:
```mlir
#map = affine_map<(d0, d1, d2) -> (d0, d2)>
#map1 = affine_map<(d0, d1, d2) -> (d2, d1)>
#map2 = affine_map<(d0, d1, d2) -> (d0, d1)>
#sparse1 = #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 floordiv 2 : dense, d1 floordiv 2 : compressed, d0 mod 2 : dense, d1 mod 2 : dense) }>
module {
func.func @m3(%arg0: tensor, %arg1: tensor, %arg2: tensor) -> tensor {
%0 = linalg.generic {doc = "S(i,j) += spy[S(i,j)] x SUM_k A(i,k) B(k,j)", indexing_maps = [#map, #map1, #map2], iterator_types = ["parallel", "parallel", "reduction"]} ins(%arg1, %arg2 : tensor, tensor) outs(%arg0 : tensor) {
^bb0(%in: f32, %in_0: f32, %out: f32):
%cst = arith.constant 0.000000e+00 : f32
%1 = sparse_tensor.unary %out : f32 to f32
present = {
}
absent = {
}
%2 = sparse_tensor.reduce %out, %1, %cst : f32 {
^bb0(%arg3: f32, %arg4: f32):
%3 = arith.addf %arg3, %arg4 : f32
sparse_tensor.yield %3 : f32
}
linalg.yield %2 : f32
} -> tensor
return %0 : tensor
}
}
```

Reproduce Command: `mlir-opt -sparsification a.mlir`

StackTrace:
```
mlir-opt: /data2/dependency/dev/llvm-project/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp:204: unsigned int getNumNonTrivialIdxExpOnSparseLvls(mlir::AffineMap, mlir::Value): Assertion `static_cast(exprs.size()) == lvlRank && "AffineMap does not have dimension-rank many results"' 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: /data2/dependency/dev/llvm-project/build/bin/mlir-opt -sparsification a.mlir
#0 0x000055dc9ed7cfff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25b8fff)
#1 0x000055dc9ed797cc llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25b57cc)
#2 0x000055dc9ed79967 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f911937f420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f9118e6a00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007f9118e49859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007f9118e49729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007f9118e5afd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x000055dc9fb25e03 (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x3361e03)
#9 0x000055dc9fb2efda (anonymous namespace)::GenericOpSparsifier::matchAndRewrite(mlir::linalg::GenericOp, mlir::PatternRewriter&) const Sparsification.cpp:0:0
#10 0x000055dc9ee927d0 mlir::detail::OpOrInterfaceRewritePatternBase::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x26ce7d0)
#11 0x000055dca7aee972 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref, llvm::function_ref, llvm::function_ref)::'lambda'()::operator()() const PatternApplicator.cpp:0:0
#12 0x000055dca7aefe68 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref, llvm::function_ref, llvm::function_ref) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb32be68)
#13 0x000055dca7aba037 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#14 0x000055dca7abe346 mlir::applyPatternsGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb2fa346)
#15 0x000055dc9faf7012 mlir::applyPatternsGreedily(mlir::Operation*, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (.constprop.0) SparseTensorPasses.cpp:0:0
#16 0x000055dc9fafd5e5 (anonymous namespace)::SparsificationPass::runOnOperation() SparseTensorPasses.cpp:0:0
#17 0x000055dca7b5aac1 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb396ac1)
#18 0x000055dca7b5ae50 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb396e50)
#19 0x000055dca7b5cf04 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb398f04)
#20 0x000055dca7b5df91 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb399f91)
#21 0x000055dc9ee4278b performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#22 0x000055dc9ee43233 processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#23 0x000055dc9ee434bb llvm::LogicalResult llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>::callback_fn>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::'lambda'(std::unique_ptr>, llvm::MemoryBufferRef, llvm::raw_ostream&)>(long, std::unique_ptr>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#24 0x000055dca7f35a15 mlir::splitAndProcessBuffer(std::unique_ptr>, llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb771a15)
#25 0x000055dc9ee395c4 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#26 0x000055dc9ee439d7 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x267f9d7)
#27 0x000055dc9ee43c13 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x267fc13)
#28 0x000055dc9eca9abc main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x24e5abc)
#29 0x00007f9118e4b083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#30 0x000055dc9ed5970e _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x259570e)
Aborted (core dumped)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.