llvm / llvm/llvm-project

[mlir][xegpu](xegpu-vector-linearize) mlir-opt crashes at VectorOps.cpp:1212 with assertion `resDimIndex >= 0' failed.

Open
#204,713 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: 15fa0c72562fbeb569c81352b55f3914f9e512d2

MLIR Program:
```mlir
#map = affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>
#map1 = affine_map<(d0, d1, d2, d3) -> (d0, d2, d3)>
#map2 = affine_map<(d0, d1, d2, d3) -> (d1, d2)>
module {
func.func @cast_away_contraction_does_not_transpose_leading_unit_dims(%arg0: vector<1x1x8xi32>, %arg1: vector<1x8x8xi32>, %arg2: vector<1x8xi32>) -> vector<1x8xi32> {
%0 = vector.contract {indexing_maps = [#map, #map1, #map2], iterator_types = ["parallel", "parallel", "parallel", "reduction"], kind = #vector.kind} %arg0, %arg1, %arg2 : vector<1x1x8xi32>, vector<1x8x8xi32> into vector<1x8xi32>
return %0 : vector<1x8xi32>
}
}
```

Reproduce Command: `mlir-opt -xegpu-vector-linearize a.mlir`

StackTrace:
```
mlir-opt: /data2/dependency/dev/llvm-project/mlir/lib/Dialect/Vector/IR/VectorOps.cpp:1212: void mlir::vector::ContractionOp::getIterationBounds(llvm::SmallVectorImpl&): Assertion `resDimIndex >= 0' 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 -xegpu-vector-linearize a.mlir
#0 0x0000557f91e03f9f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25c5f9f)
#1 0x0000557f91e0076c llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25c276c)
#2 0x0000557f91e00907 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007fd8ae50e420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007fd8adff900b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007fd8adfd8859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007fd8adfd8729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007fd8adfe9fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x0000557f994f16af mlir::vector::ContractionOp::getIterationBounds(llvm::SmallVectorImpl&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x9cb36af)
#9 0x0000557f99539cb4 mlir::detail::VectorUnrollOpInterfaceInterfaceTraits::Model::getShapeForUnroll(mlir::detail::VectorUnrollOpInterfaceInterfaceTraits::Concept const*, mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x9cfbcb4)
#10 0x0000557f995a7889 mlir::VectorUnrollOpInterface::getShapeForUnroll() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x9d69889)
#11 0x0000557f98dc8dfb getTargetShape(mlir::vector::UnrollVectorOptions const&, mlir::Operation*) VectorUnroll.cpp:0:0
#12 0x0000557f98dd7c4f (anonymous namespace)::UnrollContractionPattern::matchAndRewrite(mlir::vector::ContractionOp, mlir::PatternRewriter&) const VectorUnroll.cpp:0:0
#13 0x0000557f9678f0f0 mlir::detail::OpOrInterfaceRewritePatternBase::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x6f510f0)
#14 0x0000557f9abb0372 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref, llvm::function_ref, llvm::function_ref)::'lambda'()::operator()() const PatternApplicator.cpp:0:0
#15 0x0000557f9abb1868 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+0xb373868)
#16 0x0000557f9ab7ba37 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#17 0x0000557f9ab7fd46 mlir::applyPatternsGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb341d46)
#18 0x0000557f969fd357 (anonymous namespace)::XeGPUVectorLinearizePass::runOnOperation() XeGPUVectorLinearize.cpp:0:0
#19 0x0000557f9ac1c4c1 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb3de4c1)
#20 0x0000557f9ac1c850 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+0xb3de850)
#21 0x0000557f9ac1e904 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb3e0904)
#22 0x0000557f9ac1f991 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb3e1991)
#23 0x0000557f91ec99fb performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#24 0x0000557f91eca4a3 processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#25 0x0000557f91eca72b 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
#26 0x0000557f9aff7415 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+0xb7b9415)
#27 0x0000557f91ec0834 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#28 0x0000557f91ecac47 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x268cc47)
#29 0x0000557f91ecae83 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x268ce83)
#30 0x0000557f91d30b2c main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x24f2b2c)
#31 0x00007fd8adfda083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#32 0x0000557f91de06ae _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25a26ae)
Aborted (core dumped)
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the crash with the supplied MLIR program using mlir-opt -xegpu-vector-linearize. Start at VectorOps.cpp:1212 and follow the unroll path through VectorUnroll.cpp and XeGPUVectorLinearize.cpp to understand why getIterationBounds reaches the assertion. Done means this input no longer aborts and regression coverage preserves the corrected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.