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]Crashed on '-normalize-memrefs' pass with assertion failure `other.getNumSymbols() == getNumSymbolVars() && "symbol mismatch"' ' #61345

Closed
BealZephyr opened this issue Mar 11, 2023 · 4 comments
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir

Comments

@BealZephyr
Copy link

BealZephyr commented Mar 11, 2023

Test on commit: 3b4cb1e
The same crash occurred in LLVM 16

steps to reproduce:

mlir-opt -normalize-memrefs test.mlir

test case:

module {
  func.func @main(%arg0: tensor<128x512xf32>, %arg1: index, %arg2: index) -> tensor<16x512xf32> attributes {llvm.emit_c_interface} {
    %c0 = arith.constant 0 : index
    %0 = bufferization.to_memref %arg0 : memref<128x512xf32, strided<[?, ?], offset: ?>>
    %subview = memref.subview %0[%arg2, 0] [%arg1, 512] [1, 1] : memref<128x512xf32, strided<[?, ?], offset: ?>> to memref<?x512xf32, strided<[?, ?], offset: ?>>
    %cast = memref.cast %subview : memref<?x512xf32, strided<[?, ?], offset: ?>> to memref<16x512xf32, strided<[?, ?], offset: ?>>
    %1 = bufferization.to_tensor %cast : memref<16x512xf32, strided<[?, ?], offset: ?>>
    return %1 : tensor<16x512xf32>
  }
}

crash trace:

mlir-opt: /home/verify/llvm-project-3b4cb1e96c645bb833fe710856479c31383859bb/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp:465: mlir::LogicalResult mlir::FlatAffineValueConstraints::composeMatchingMap(mlir::AffineMap): Assertion `other.getNumSymbols() == getNumSymbolVars() && "symbol mismatch"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/verify/llvm-project-3b4cb1e96c645bb833fe710856479c31383859bb/build/bin/mlir-opt -normalize-memrefs test.mlir
 #0 0x000055e1fe15bf1a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/verify/llvm-project-3b4cb1e96c645bb833fe710856479c31383859bb/build/bin/mlir-opt+0x221f1a)
 #1 0x000055e1fe15941c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f49986a2980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #3 0x00007f499779ae87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #4 0x00007f499779c7f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
 #5 0x00007f499778c3fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0
 #6 0x00007f499778c472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
 #7 0x000055e1ff9a6cfa mlir::FlatAffineValueConstraints::composeMatchingMap(mlir::AffineMap) (/home/verify/llvm-project-3b4cb1e96c645bb833fe710856479c31383859bb/build/bin/mlir-opt+0x1a6ccfa)
 #8 0x000055e1fe279eb2 mlir::normalizeMemRefType(mlir::MemRefType, unsigned int) (/home/verify/llvm-project-3b4cb1e96c645bb833fe710856479c31383859bb/build/bin/mlir-opt+0x33feb2)
 #9 0x000055e1feb2cae2 (anonymous namespace)::NormalizeMemRefs::createOpResultsNormalized(mlir::func::FuncOp, mlir::Operation*) (.isra.233) NormalizeMemRefs.cpp:0:0
#10 0x000055e1feb2d30b void llvm::function_ref<void (mlir::Operation*)>::callback_fn<(anonymous namespace)::NormalizeMemRefs::normalizeFuncOpMemRefs(mlir::func::FuncOp, mlir::ModuleOp)::'lambda1'(mlir::Operation*)>(long, mlir::Operation*) NormalizeMemRefs.cpp:0:0
#11 0x000055e1feb31c5d (anonymous namespace)::NormalizeMemRefs::normalizeFuncOpMemRefs(mlir::func::FuncOp, mlir::ModuleOp) NormalizeMemRefs.cpp:0:0
#12 0x000055e1feb3359d (anonymous namespace)::NormalizeMemRefs::runOnOperation() NormalizeMemRefs.cpp:0:0
#13 0x000055e1ffa13759 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/verify/llvm-project-3b4cb1e96c645bb833fe710856479c31383859bb/build/bin/mlir-opt+0x1ad9759)
#14 0x000055e1ffa145b3 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (.constprop.495) Pass.cpp:0:0
#15 0x000055e1ffa14c9d mlir::PassManager::run(mlir::Operation*) (/home/verify/llvm-project-3b4cb1e96c645bb833fe710856479c31383859bb/build/bin/mlir-opt+0x1adac9d)
#16 0x000055e1ffa07ca3 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#17 0x000055e1ffa083d9 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) MlirOptMain.cpp:0:0
#18 0x000055e1ffa08701 mlir::LogicalResult llvm::function_ref<mlir::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&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#19 0x000055e1ffacd380 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/home/verify/llvm-project-3b4cb1e96c645bb833fe710856479c31383859bb/build/bin/mlir-opt+0x1b93380)
#20 0x000055e1ffa053e3 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/home/verify/llvm-project-3b4cb1e96c645bb833fe710856479c31383859bb/build/bin/mlir-opt+0x1acb3e3)
#21 0x000055e1ffa08ae8 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) (/home/verify/llvm-project-3b4cb1e96c645bb833fe710856479c31383859bb/build/bin/mlir-opt+0x1aceae8)
#22 0x000055e1fe128330 main (/home/verify/llvm-project-3b4cb1e96c645bb833fe710856479c31383859bb/build/bin/mlir-opt+0x1ee330)
#23 0x00007f499777dc87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#24 0x000055e1fe13afca _start (/home/verify/llvm-project-3b4cb1e96c645bb833fe710856479c31383859bb/build/bin/mlir-opt+0x200fca)
@EugeneZelenko EugeneZelenko added mlir crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Mar 11, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 11, 2023

@llvm/issue-subscribers-mlir

@BealZephyr
Copy link
Author

Hi, @Lewuathe, this issue is still reproducible at main branch (38007dd). Could you please have a look at it?

@Lewuathe
Copy link
Member

I submitted a patch under review to fix this issue.
https://reviews.llvm.org/D150250

Lewuathe added a commit that referenced this issue Jun 29, 2023
Memref normalization fails to recognize the non-zero symbols used in the memref type itself with strided, offset information. It causes the crash with the type like `memref<128x512xf32, strided<[?, ?], offset: ?>>`. The original issue is here. #61345

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D150250
@Lewuathe
Copy link
Member

Lewuathe commented Jul 9, 2023

The fix for this issue has been merged.

@Lewuathe Lewuathe closed this as completed Jul 9, 2023
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

4 participants