llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[mlir](convert-xegpu-to-xevm) mlir-opt crashes at XeGPUToXeVM.cpp:722 with assertion `llvm::count_if(vecType.getShape(), [](int64_t d) { return d != 1; }) <= 1 && "Expected either 1D vector or nD with unit dimensions"' failed.

Open Aran-414 opened this issue 4 months ago • 3 comments

git version: e2223e665eccd0580c3f1c9d4d31b2262a8ca823

MLIR Program:

module {
  func.func @m(%arg0: index) {
    %alloca = memref.alloca() : memref<4x8xf32, 3>
    %0 = xegpu.create_mem_desc %alloca : memref<4x8xf32, 3> -> !xegpu.mem_desc<4x8xf32>
    %1 = xegpu.load_matrix %0[0, 0] : !xegpu.mem_desc<4x8xf32> -> vector<4x8xf32>
    return
  }
}

Reproduce Command: mlir-opt -convert-xegpu-to-xevm a.mlir

StackTrace:

mlir-opt: /data2/dependency/dev/llvm-project/mlir/lib/Conversion/XeGPUToXeVM/XeGPUToXeVM.cpp:722: llvm::LogicalResult {anonymous}::LoadStoreMatrixToXeVMPattern<OpType, <template-parameter-1-2> >::matchAndRewrite(OpType, typename OpType::Adaptor, mlir::ConversionPatternRewriter&) const [with OpType = mlir::xegpu::LoadMatrixOp; <template-parameter-1-2> = void; typename OpType::Adaptor = mlir::xegpu::LoadMatrixOpAdaptor]: Assertion `llvm::count_if(vecType.getShape(), [](int64_t d) { return d != 1; }) <= 1 && "Expected either 1D vector or nD with unit dimensions"' 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 -convert-xegpu-to-xevm a.mlir
 #0 0x00005618caed07ef llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x1fc57ef)
 #1 0x00005618caeccf8c llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x1fc1f8c)
 #2 0x00005618caecd12f SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007f5f2d4b3420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f5f2cf9e00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007f5f2cf7d859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007f5f2cf7d729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #7 0x00007f5f2cf8efd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #8 0x00005618cfaa3a5d (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x6b98a5d)
 #9 0x00005618cfa97c95 llvm::LogicalResult mlir::ConversionPattern::dispatchTo1To1<mlir::OpConversionPattern<mlir::xegpu::LoadMatrixOp>, mlir::xegpu::LoadMatrixOp>(mlir::OpConversionPattern<mlir::xegpu::LoadMatrixOp> const&, mlir::xegpu::LoadMatrixOp, mlir::xegpu::LoadMatrixOp::GenericAdaptor<llvm::ArrayRef<mlir::ValueRange>>, mlir::ConversionPatternRewriter&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x6b8cc95)
#10 0x00005618cfa97e05 mlir::OpConversionPattern<mlir::xegpu::LoadMatrixOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::ValueRange>, mlir::ConversionPatternRewriter&) const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x6b8ce05)
#11 0x00005618d3d64d28 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xae59d28)
#12 0x00005618d3dabc02 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>)::'lambda'()::operator()() const PatternApplicator.cpp:0:0
#13 0x00005618d3dad168 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xaea2168)
#14 0x00005618d3d5f86b (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*) DialectConversion.cpp:0:0
#15 0x00005618d3d5fd56 mlir::OperationConverter::convert(mlir::Operation*, bool) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xae54d56)
#16 0x00005618d3d6ad2a mlir::OperationConverter::applyConversion(llvm::ArrayRef<mlir::Operation*>) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xae5fd2a)
#17 0x00005618d3d6c5e8 applyConversion(llvm::ArrayRef<mlir::Operation*>, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig, (anonymous namespace)::OpConversionMode) DialectConversion.cpp:0:0
#18 0x00005618d3d6c7c6 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xae617c6)
#19 0x00005618cfa951d9 (anonymous namespace)::ConvertXeGPUToXeVMPass::runOnOperation() XeGPUToXeVM.cpp:0:0
#20 0x00005618d3e17721 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xaf0c721)
#21 0x00005618d3e17ab0 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+0xaf0cab0)
#22 0x00005618d3e19b64 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xaf0eb64)
#23 0x00005618d3e1abe1 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xaf0fbe1)
#24 0x00005618caf966db performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#25 0x00005618caf9721f processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#26 0x00005618caf9744b llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, 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&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#27 0x00005618d41e7015 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::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb2dc015)
#28 0x00005618caf8d494 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#29 0x00005618caf97967 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x208c967)
#30 0x00005618caf97ba3 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x208cba3)
#31 0x00005618cae158ac main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x1f0a8ac)
#32 0x00007f5f2cf7f083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#33 0x00005618caeacdbe _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x1fa1dbe)
Aborted (core dumped)

Aran-414 avatar Jul 11 '26 10:07 Aran-414

@llvm/issue-subscribers-mlir

Author: Aran-414

git version: e2223e665eccd0580c3f1c9d4d31b2262a8ca823

MLIR Program:

module {
  func.func @<!-- -->m(%arg0: index) {
    %alloca = memref.alloca() : memref&lt;4x8xf32, 3&gt;
    %0 = xegpu.create_mem_desc %alloca : memref&lt;4x8xf32, 3&gt; -&gt; !xegpu.mem_desc&lt;4x8xf32&gt;
    %1 = xegpu.load_matrix %0[0, 0] : !xegpu.mem_desc&lt;4x8xf32&gt; -&gt; vector&lt;4x8xf32&gt;
    return
  }
}

Reproduce Command: mlir-opt -convert-xegpu-to-xevm a.mlir

StackTrace:

mlir-opt: /data2/dependency/dev/llvm-project/mlir/lib/Conversion/XeGPUToXeVM/XeGPUToXeVM.cpp:722: llvm::LogicalResult {anonymous}::LoadStoreMatrixToXeVMPattern&lt;OpType, &lt;template-parameter-1-2&gt; &gt;::matchAndRewrite(OpType, typename OpType::Adaptor, mlir::ConversionPatternRewriter&amp;) const [with OpType = mlir::xegpu::LoadMatrixOp; &lt;template-parameter-1-2&gt; = void; typename OpType::Adaptor = mlir::xegpu::LoadMatrixOpAdaptor]: Assertion `llvm::count_if(vecType.getShape(), [](int64_t d) { return d != 1; }) &lt;= 1 &amp;&amp; "Expected either 1D vector or nD with unit dimensions"' 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 -convert-xegpu-to-xevm a.mlir
 #<!-- -->0 0x00005618caed07ef llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x1fc57ef)
 #<!-- -->1 0x00005618caeccf8c llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x1fc1f8c)
 #<!-- -->2 0x00005618caecd12f SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #<!-- -->3 0x00007f5f2d4b3420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #<!-- -->4 0x00007f5f2cf9e00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #<!-- -->5 0x00007f5f2cf7d859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #<!-- -->6 0x00007f5f2cf7d729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #<!-- -->7 0x00007f5f2cf8efd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #<!-- -->8 0x00005618cfaa3a5d (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x6b98a5d)
 #<!-- -->9 0x00005618cfa97c95 llvm::LogicalResult mlir::ConversionPattern::dispatchTo1To1&lt;mlir::OpConversionPattern&lt;mlir::xegpu::LoadMatrixOp&gt;, mlir::xegpu::LoadMatrixOp&gt;(mlir::OpConversionPattern&lt;mlir::xegpu::LoadMatrixOp&gt; const&amp;, mlir::xegpu::LoadMatrixOp, mlir::xegpu::LoadMatrixOp::GenericAdaptor&lt;llvm::ArrayRef&lt;mlir::ValueRange&gt;&gt;, mlir::ConversionPatternRewriter&amp;) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x6b8cc95)
#<!-- -->10 0x00005618cfa97e05 mlir::OpConversionPattern&lt;mlir::xegpu::LoadMatrixOp&gt;::matchAndRewrite(mlir::Operation*, llvm::ArrayRef&lt;mlir::ValueRange&gt;, mlir::ConversionPatternRewriter&amp;) const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x6b8ce05)
#<!-- -->11 0x00005618d3d64d28 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&amp;) const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xae59d28)
#<!-- -->12 0x00005618d3dabc02 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&amp;, llvm::function_ref&lt;bool (mlir::Pattern const&amp;)&gt;, llvm::function_ref&lt;void (mlir::Pattern const&amp;)&gt;, llvm::function_ref&lt;llvm::LogicalResult (mlir::Pattern const&amp;)&gt;)::'lambda'()::operator()() const PatternApplicator.cpp:0:0
#<!-- -->13 0x00005618d3dad168 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&amp;, llvm::function_ref&lt;bool (mlir::Pattern const&amp;)&gt;, llvm::function_ref&lt;void (mlir::Pattern const&amp;)&gt;, llvm::function_ref&lt;llvm::LogicalResult (mlir::Pattern const&amp;)&gt;) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xaea2168)
#<!-- -->14 0x00005618d3d5f86b (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*) DialectConversion.cpp:0:0
#<!-- -->15 0x00005618d3d5fd56 mlir::OperationConverter::convert(mlir::Operation*, bool) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xae54d56)
#<!-- -->16 0x00005618d3d6ad2a mlir::OperationConverter::applyConversion(llvm::ArrayRef&lt;mlir::Operation*&gt;) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xae5fd2a)
#<!-- -->17 0x00005618d3d6c5e8 applyConversion(llvm::ArrayRef&lt;mlir::Operation*&gt;, mlir::ConversionTarget const&amp;, mlir::FrozenRewritePatternSet const&amp;, mlir::ConversionConfig, (anonymous namespace)::OpConversionMode) DialectConversion.cpp:0:0
#<!-- -->18 0x00005618d3d6c7c6 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&amp;, mlir::FrozenRewritePatternSet const&amp;, mlir::ConversionConfig) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xae617c6)
#<!-- -->19 0x00005618cfa951d9 (anonymous namespace)::ConvertXeGPUToXeVMPass::runOnOperation() XeGPUToXeVM.cpp:0:0
#<!-- -->20 0x00005618d3e17721 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xaf0c721)
#<!-- -->21 0x00005618d3e17ab0 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&amp;, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xaf0cab0)
#<!-- -->22 0x00005618d3e19b64 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xaf0eb64)
#<!-- -->23 0x00005618d3e1abe1 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xaf0fbe1)
#<!-- -->24 0x00005618caf966db performActions(llvm::raw_ostream&amp;, std::shared_ptr&lt;llvm::SourceMgr&gt; const&amp;, mlir::MLIRContext*, mlir::MlirOptMainConfig const&amp;) MlirOptMain.cpp:0:0
#<!-- -->25 0x00005618caf9721f processBuffer(llvm::raw_ostream&amp;, std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&amp;, mlir::DialectRegistry&amp;, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#<!-- -->26 0x00005618caf9744b llvm::LogicalResult llvm::function_ref&lt;llvm::LogicalResult (std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::MemoryBufferRef const&amp;, llvm::raw_ostream&amp;)&gt;::callback_fn&lt;mlir::MlirOptMain(llvm::raw_ostream&amp;, std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, mlir::DialectRegistry&amp;, mlir::MlirOptMainConfig const&amp;)::'lambda'(std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::MemoryBufferRef, llvm::raw_ostream&amp;)&gt;(long, std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::MemoryBufferRef const&amp;, llvm::raw_ostream&amp;) MlirOptMain.cpp:0:0
#<!-- -->27 0x00005618d41e7015 mlir::splitAndProcessBuffer(std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::function_ref&lt;llvm::LogicalResult (std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::MemoryBufferRef const&amp;, llvm::raw_ostream&amp;)&gt;, llvm::raw_ostream&amp;, llvm::StringRef, llvm::StringRef) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb2dc015)
#<!-- -->28 0x00005618caf8d494 mlir::MlirOptMain(llvm::raw_ostream&amp;, std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, mlir::DialectRegistry&amp;, mlir::MlirOptMainConfig const&amp;) (.part.0) MlirOptMain.cpp:0:0
#<!-- -->29 0x00005618caf97967 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&amp;) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x208c967)
#<!-- -->30 0x00005618caf97ba3 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&amp;) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x208cba3)
#<!-- -->31 0x00005618cae158ac main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x1f0a8ac)
#<!-- -->32 0x00007f5f2cf7f083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#<!-- -->33 0x00005618caeacdbe _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x1fa1dbe)
Aborted (core dumped)

hi, i'd like to try this

Naaz30 avatar Jul 12 '26 09:07 Naaz30

I confirmed that this crash is fixed by #228638.

Men-cotton avatar Nov 06 '26 19:11 Men-cotton