<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64977>64977</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir]`linalg-fold-unit-extent-dims` pass with`use-rank-reducing-slices` option crashed with assertion failure.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Colloportus0
</td>
</tr>
</table>
<pre>
MLIR built at commit 5624e86a
Reproduced with:
`mlir-opt `
temp.mlir:
``` milr
#map4 = affine_map<(d0, d1, d2) -> (d0, d1)>
#map5 = affine_map<(d0, d1, d2) -> (d0, d1, d2)>
module {
llvm.func @_mlir_memref_to_llvm_alloc(i64) -> !llvm.ptr
func.func private @func2(%arg0: vector<4x28xf16>, %arg1: i32, %arg2: index) {
%1 = llvm.mlir.constant(112 : index) : i64
%2 = llvm.mlir.constant(28 : index) : i64
%3 = llvm.mlir.constant(4 : index) : i64
%4 = llvm.mlir.constant(0 : index) : i64
%6 = llvm.mlir.constant(1 : index) : i64
%c10 = arith.constant 10 : index
%cst_12 = arith.constant 1.14675418E+9 : f32
%15 = builtin.unrealized_conversion_cast %c10 : index to i64
%21 = bufferization.alloc_tensor() : tensor<1x28xf16>
%314 = llvm.mul %15, %1 : i64
%315 = llvm.mlir.null : !llvm.ptr
%316 = llvm.getelementptr %315[%314] : (!llvm.ptr, i64) -> !llvm.ptr, f16
%317 = llvm.ptrtoint %316 : !llvm.ptr to i64
%318 = llvm.call @_mlir_memref_to_llvm_alloc(%317) : (i64) -> !llvm.ptr
%319 = llvm.mlir.undef : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%320 = llvm.insertvalue %318, %319[0] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%321 = llvm.insertvalue %318, %320[1] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%322 = llvm.insertvalue %4, %321[2] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%323 = llvm.insertvalue %15, %322[3, 0] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%324 = llvm.insertvalue %2, %323[3, 1] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%325 = llvm.insertvalue %3, %324[3, 2] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%326 = llvm.insertvalue %1, %325[4, 0] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%327 = llvm.insertvalue %3, %326[4, 1] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%328 = llvm.insertvalue %6, %327[4, 2] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%329 = builtin.unrealized_conversion_cast %328 : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)> to memref<?x28x4xf16>
linalg.generic {indexing_maps = [#map4, #map5], iterator_types = ["parallel", "parallel", "parallel"]} ins(%21 : tensor<1x28xf16>) outs(%329 : memref<?x28x4xf16>) attrs = {__inplace_operands_attr__ = ["true", "none"]} {
^bb0(%in: f16, %out: f16):
linalg.yield %in : f16
}
return
}
}
```
trace:
```console
Assertion failed: (succeeded(rankReducingExtract) && "not a unit-extent collapse"), function collapseValue, file DropUnitDims.cpp, line 293.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: mlir-opt --linalg-fold-unit-extent-dims=use-rank-reducing-slices temp.mlir
#0 0x00000001023a7774 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/workspace/build/bin/mlir-opt+0x1002f7774)
#1 0x00000001023a5910 llvm::sys::RunSignalHandlers() (/workspace/build/bin/mlir-opt+0x1002f5910)
#2 0x00000001023a7e3c SignalHandler(int) (/workspace/build/bin/mlir-opt+0x1002f7e3c)
#3 0x00000001b0a454c4 (/usr/lib/system/libsystem_platform.dylib+0x1803414c4)
#4 0x00000001b0a2dee0 (/usr/lib/system/libsystem_pthread.dylib+0x180329ee0)
#5 0x00000001b0968340 (/usr/lib/system/libsystem_c.dylib+0x180264340)
#6 0x00000001b0967754 (/usr/lib/system/libsystem_c.dylib+0x180263754)
#7 0x000000010662fbfc mlir::linalg::dropUnitDims(mlir::RewriterBase&, mlir::linalg::GenericOp, mlir::linalg::ControlDropUnitDims const&) (.cold.34) (/workspace/build/bin/mlir-opt+0x10457fbfc)
#8 0x0000000102ed68e8 mlir::linalg::dropUnitDims(mlir::RewriterBase&, mlir::linalg::GenericOp, mlir::linalg::ControlDropUnitDims const&) (/workspace/build/bin/mlir-opt+0x100e268e8)
#9 0x00000001062754e8 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>)::$_2::operator()() const (/workspace/build/bin/mlir-opt+0x1041c54e8)
#10 0x00000001062727e4 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) (/workspace/build/bin/mlir-opt+0x1041c27e4)
#11 0x0000000104c327b4 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() (/workspace/build/bin/mlir-opt+0x102b827b4)
#12 0x0000000104c2ffe4 mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/workspace/build/bin/mlir-opt+0x102b7ffe4)
#13 0x0000000102edf684 (anonymous namespace)::LinalgFoldUnitExtentDimsPass::runOnOperation() (/workspace/build/bin/mlir-opt+0x100e2f684)
#14 0x0000000104bc4ecc mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/workspace/build/bin/mlir-opt+0x102b14ecc)
#15 0x0000000104bc55bc mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/workspace/build/bin/mlir-opt+0x102b155bc)
#16 0x0000000104bc7474 mlir::PassManager::run(mlir::Operation*) (/workspace/build/bin/mlir-opt+0x102b17474)
#17 0x0000000104bbf6d8 performActions(llvm::raw_ostream&, std::__1::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) (/workspace/build/bin/mlir-opt+0x102b0f6d8)
#18 0x0000000104bbec00 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_1>(long, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) (/workspace/build/bin/mlir-opt+0x102b0ec00)
#19 0x0000000104c4c0c8 mlir::splitAndProcessBuffer(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/workspace/build/bin/mlir-opt+0x102b9c0c8)
#20 0x0000000104bb95b4 mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/workspace/build/bin/mlir-opt+0x102b095b4)
#21 0x0000000104bb9a24 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/workspace/build/bin/mlir-opt+0x102b09a24)
#22 0x00000001020b2d40 main (/workspace/build/bin/mlir-opt+0x100002d40)
#23 0x000000010dc71088
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl9v27iy_zTKCxFDIvX3IQ-Onewt0KBBuvfeR4OSRg5PKVKHpNJ4P_0BKckWnbhpvLvZxeIURWyJnJnf_GY4HEqmWrOtALgKkusgWV_Q3jxKdbWSnMtOKtPr8KKU9e7q7vOnB1T2jBtEDapk2zKDUJLiGPKUBuE6CJcP0ClZ9xXU6DszjwFZIjSMBGnYcqYuZWdQkIbjTffXQNst7GBAlvvJw3_UMq4mDZi0tItRQNaINg0TsGlpF5BVgPM6DPAK1ZH7iwNcoMuA3CBvpAjIzVxTcramcWSvr5V1zwEF2fVwjRDnT-2i6UWFgjjcWN82LbQKmo2RGzu4oZzLKsA5S-OZkcgJdkZNiqyOQVGn2BM1YBXaaxzgPMAJVdvQsvwElZEqIKv4GefPTZRacHiFhimRncIIPtzB7o6o4dlanyFHdkLkqHFYLPZFJYU2VJgA51GEkS9rL9LYk8en5XH-tjg5LR6_LR2flg7flk5_4Prb0lUUDlmlmHncy6Jobtibr80mwq-KLKI4zZI4ym8CfD1Yawj2wzSksFuTTCx6oYBy9hvUm0qKJ1CaSbGpqDYHaCMIZOTLoEWjtqYBxX6jhkmxcGm6MSC0VC7jBiTjDbKKZunmhTCah6HnA9wx_yL0ethHfw7ki55zN_WVlTGKzOK1BQMcWhCmM2pUaIuaQxMk61FTPleGV-jUCsQrZB0bzDkl2cFWZ5SRTJgDCA_ka_ySKD_IV9R69kZtGIxOnL9dLEYzxRGLvaih8RBqo_rKDAVvdHVOxgpRpeguICuCnt2toZi8drd4EXkcHuwzoUGZJ8p7GCkYU4B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