Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MLIR]--pass-pipeline="builtin.module(func.func(test-match-reduction))" triggers Assertion Failure `Index < this->size() && "Invalid index!"' #114769

Open
xisang0 opened this issue Nov 4, 2024 · 1 comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir

Comments

@xisang0
Copy link

xisang0 commented Nov 4, 2024

Test on commit: c3edeaa61bf0e7faed6c26f693b4fcd9102ba1ec
steps to reproduce:

mlir-opt test.mlir --pass-pipeline="builtin.module(func.func(test-match-reduction))"

test case:

#map1 = affine_map<(d0, d1, d2, d3) -> (d3)>
#map2 = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>
module {
  func.func @main(%arg0: tensor<13x21x3xbf16>, %arg1: tensor<1x32x32x8xf32>, %arg2: tensor<16x2x2x8xf32>, %arg3: tensor<16xf32>){
    %cst = arith.constant 0.000000e+00 : f32
    %2 = tensor.empty() : tensor<1x8226x33x8xf32>
    %3 = linalg.fill ins(%cst : f32) outs(%2 : tensor<1x8226x33x8xf32>) -> tensor<1x8226x33x8xf32>
    %inserted_slice = tensor.insert_slice %arg1 into %3[0, 8193, 0, 0] [1, 32, 32, 8] [1, 1, 1, 1] : tensor<1x32x32x8xf32> into tensor<1x8226x33x8xf32>
    %4 = tensor.empty() : tensor<1x32x32x16xf32>
    %5 = linalg.generic {indexing_maps = [#map1, #map2], iterator_types = ["parallel", "parallel", "parallel", "parallel"]} ins(%arg3 : tensor<16xf32>) outs(%4 : tensor<1x32x32x16xf32>) {
    ^bb0(%in: f32, %out: f32):
      linalg.yield %in : f32
    } -> tensor<1x32x32x16xf32>
    %6 = linalg.conv_2d_nhwc_fhwc {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>} ins(%inserted_slice, %arg2 : tensor<1x8226x33x8xf32>, tensor<16x2x2x8xf32>) outs(%5 : tensor<1x32x32x16xf32>) -> tensor<1x32x32x16xf32>
    return
  }
}

crash trace:

mlir-opt: /home/workdir/llvm-project-19/llvm/include/llvm/ADT/ArrayRef.h:446: T &llvm::MutableArrayRef<mlir::OpOperand>::operator[](size_t) const [T = mlir::OpOperand]: Assertion `Index < this->size() && "Invalid index!"' 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/test9.mlir --pass-pipeline=builtin.module(func.func(test-match-reduction))
 #0 0x000064f72867d228 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./mlir-opt+0x1062228)
 #1 0x000064f72867ad4e llvm::sys::RunSignalHandlers() (./mlir-opt+0x105fd4e)
 #2 0x000064f72867dc38 SignalHandler(int) Signals.cpp:0:0
 #3 0x0000793393543520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007933935979fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x0000793393543476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007933935297f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000079339352971b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x000079339353ae96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x000064f728a959cb (./mlir-opt+0x147a9cb)
#10 0x000064f72b882afa mlir::matchReduction(llvm::ArrayRef<mlir::BlockArgument>, unsigned int, llvm::SmallVectorImpl<mlir::Operation*>&) (./mlir-opt+0x4267afa)
#11 0x000064f72b35a055 void llvm::function_ref<void (mlir::Operation*)>::callback_fn<(anonymous namespace)::TestMatchReductionPass::runOnOperation()::'lambda'(mlir::Operation*)>(long, mlir::Operation*) TestMatchReduction.cpp:0:0
#12 0x000064f728783a06 void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (./mlir-opt+0x1168a06)
#13 0x000064f728783a9e void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (./mlir-opt+0x1168a9e)
#14 0x000064f72b359e49 (anonymous namespace)::TestMatchReductionPass::runOnOperation() TestMatchReduction.cpp:0:0
#15 0x000064f72b8a5e9f mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./mlir-opt+0x428ae9f)
#16 0x000064f72b8a6682 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (./mlir-opt+0x428b682)
#17 0x000064f72b8abd9e 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
#18 0x000064f72b8a7e8b mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (./mlir-opt+0x428ce8b)
#19 0x000064f72b8a5ffc mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./mlir-opt+0x428affc)
#20 0x000064f72b8a6682 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (./mlir-opt+0x428b682)
#21 0x000064f72b8a8e2e mlir::PassManager::run(mlir::Operation*) (./mlir-opt+0x428de2e)
#22 0x000064f72b8a1952 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#23 0x000064f72b8a15bb 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
#24 0x000064f72b94b2a5 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+0x43302a5)
#25 0x000064f72b89c7b2 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (./mlir-opt+0x42817b2)
#26 0x000064f72b89ca63 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x4281a63)
#27 0x000064f72b89cc72 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x4281c72)
#28 0x000064f72865c477 main (./mlir-opt+0x1041477)
#29 0x000079339352ad90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#30 0x000079339352ae40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#31 0x000064f72865bfe5 _start (./mlir-opt+0x1040fe5)
Aborted (core dumped)
@github-actions github-actions bot added the mlir label Nov 4, 2024
@EugeneZelenko EugeneZelenko added the crash Prefer [crash-on-valid] or [crash-on-invalid] label Nov 4, 2024
@cxy-1993
Copy link
Contributor

cxy-1993 commented Nov 6, 2024

This is because the test file defaults to having only one input(

auto outputs = args.drop_front();
), while your example (linalg.conv_2d_nhwc_fhwc) has two inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir
Projects
None yet
Development

No branches or pull requests

3 participants