<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/116043>116043</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR]-pass-pipeline="builtin.module(func.func(tosa-to-linalg-named,tosa-to-linalg))" triggers Assertion Failure `idx < size()'
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
xisang0
</td>
</tr>
</table>
<pre>
Tset on commit: https://github.com/llvm/llvm-project/commit/38fffa630ee80163dc65e759392ad29798905679
steps to reproduce:
```
mlir-opt test.mlir --pass-pipeline="builtin.module(func.func(tosa-to-linalg-named,tosa-to-linalg))"
```
test case:
```
func.func @test_broadcast_select_both_input(%arg0: tensor<1x16x16xi1>, %arg1: tensor<f32>, %arg2: tensor<f32>) -> tensor<1x16x16xf32> {
%0 = tosa.select %arg0, %arg1, %arg2 : (tensor<1x16x16xi1>, tensor<f32>, tensor<f32>) -> tensor<1x16x16xf32>
return %0 : tensor<1x16x16xf32>
}
```
crash trace:
```
mlir-opt: /home/workdir/llvm-project-19/llvm/include/llvm/ADT/SmallVector.h:291: reference llvm::SmallVectorTemplateCommon<llvm::SmallVector<long, 2>>::operator[](size_type) [T = llvm::SmallVector<long, 2>]: Assertion `idx < size()' failed.
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 /home/workdir/test.mlir --pass-pipeline=builtin.module(func.func(tosa-to-linalg-named,tosa-to-linalg))
#0 0x00005579f3b20258 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./mlir-opt+0x1068258)
#1 0x00005579f3b1dd7e llvm::sys::RunSignalHandlers() (./mlir-opt+0x1065d7e)
#2 0x00005579f3b20c68 SignalHandler(int) Signals.cpp:0:0
#3 0x00007d0072b05520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007d0072b599fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007d0072b05476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007d0072aeb7f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007d0072aeb71b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007d0072afce96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00005579f670ac15 elementwiseMatchAndRewriteHelper(mlir::Operation*, mlir::ValueRange, mlir::ConversionPatternRewriter&, mlir::TypeConverter const&) TosaToLinalg.cpp:0:0
#10 0x00005579f6721896 mlir::OpConversionPattern<mlir::tosa::SelectOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::Value>, mlir::ConversionPatternRewriter&) const (./mlir-opt+0x3c69896)
#11 0x00005579f6db0961 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (./mlir-opt+0x42f8961)
#12 0x00005579f8db821a void llvm::function_ref<void ()>::callback_fn<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&)>)::$_0>(long) PatternApplicator.cpp:0:0
#13 0x00005579f8db4e5f 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&)>) (./mlir-opt+0x62fce5f)
#14 0x00005579f6db195d (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#15 0x00005579f6db09f7 mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) (./mlir-opt+0x42f89f7)
#16 0x00005579f6db1b9f mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>) (./mlir-opt+0x42f9b9f)
#17 0x00005579f6db95be mlir::applyFullConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (./mlir-opt+0x43015be)
#18 0x00005579f66f6cc3 (anonymous namespace)::TosaToLinalg::runOnOperation() TosaToLinalgPass.cpp:0:0
#19 0x00005579f6d53b1f mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./mlir-opt+0x429bb1f)
#20 0x00005579f6d54302 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (./mlir-opt+0x429c302)
#21 0x00005579f6d59a1e auto void mlir::parallelForEach<__gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0>(mlir::MLIRContext*, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&&)::'lambda'(__gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>&&)::operator()<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&>(__gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>&&) const Pass.cpp:0:0
#22 0x00005579f6d55b0b mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (./mlir-opt+0x429db0b)
#23 0x00005579f6d53c7c mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./mlir-opt+0x429bc7c)
#24 0x00005579f6d54302 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (./mlir-opt+0x429c302)
#25 0x00005579f6d56aae mlir::PassManager::run(mlir::Operation*) (./mlir-opt+0x429eaae)
#26 0x00005579f6d4f5d2 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#27 0x00005579f6d4f23b llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, 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&)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#28 0x00005579f6df8f25 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::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (./mlir-opt+0x4340f25)
#29 0x00005579f6d4a432 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (./mlir-opt+0x4292432)
#30 0x00005579f6d4a6e3 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x42926e3)
#31 0x00005579f6d4a8f2 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x42928f2)
#32 0x00005579f3aff477 main (./mlir-opt+0x1047477)
#33 0x00007d0072aecd90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#34 0x00007d0072aece40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#35 0x00005579f3afefe5 _start (./mlir-opt+0x1046fe5)
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWt1u27gSfhrmhoghUf8XuXCdGlugQYM02FuDokYyTylSh6TaZJ_-QD-2RdlO4m67e3bRwm1qcTLzzTfD4ZAiNYZXEuAGRe9QdHtFW7tV-uaJGyor7ypXxfPNowGLlcRM1TW3KF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