Skip to content

[MLIR] SymbolOpInterface pass crashes on module that does not define a symbol #134586

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

Closed
piyushhingu opened this issue Apr 7, 2025 · 6 comments
Closed
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Comments

@piyushhingu
Copy link

piyushhingu commented Apr 7, 2025

  1. Program arguments: mlir-opt mlirs/linalg.mlir --linalg-generalize-named-ops --test-memref-stride-calculation
 #0 0x000058e0bd4ed8c9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /workspace/docker/torch-mlir/externals/llvm-project/llvm/lib/Support/Unix/Signals.inc:804:11
 #1 0x000058e0bd4edd7b PrintStackTraceSignalHandler(void*) /workspace/docker/torch-mlir/externals/llvm-project/llvm/lib/Support/Unix/Signals.inc:880:1
 #2 0x000058e0bd4ebf7f llvm::sys::RunSignalHandlers() /workspace/docker/torch-mlir/externals/llvm-project/llvm/lib/Support/Signals.cpp:105:5
 #3 0x000058e0bd4ee479 SignalHandler(int, siginfo_t*, void*) /workspace/docker/torch-mlir/externals/llvm-project/llvm/lib/Support/Unix/Signals.inc:418:7
 #4 0x00007f4f5d8be520 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #5 0x00007f4f5d9129fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x00007f4f5d9129fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #7 0x00007f4f5d9129fc pthread_kill ./nptl/pthread_kill.c:89:10
 #8 0x00007f4f5d8be476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #9 0x00007f4f5d8a47f3 abort ./stdlib/abort.c:81:7
#10 0x00007f4f5d8a471b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#11 0x00007f4f5d8b5e96 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#12 0x000058e0c1bc5754 decltype(auto) llvm::cast<mlir::SymbolOpInterface, mlir::Operation>(mlir::Operation*) /workspace/docker/torch-mlir/externals/llvm-project/llvm/include/llvm/Support/Casting.h:579:39
#13 0x000058e0c2cc1d1d mlir::InterfacePass<mlir::SymbolOpInterface>::getOperation() /workspace/docker/torch-mlir/externals/llvm-project/mlir/include/mlir/Pass/Pass.h:443:38
#14 0x000058e0c2cc7655 (anonymous namespace)::TestMemRefStrideCalculation::runOnOperation() /workspace/docker/torch-mlir/externals/llvm-project/mlir/test/lib/Analysis/TestMemRefStrideCalculation.cpp:33:34
#15 0x000058e0c28998c4 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1::operator()() const /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:0:17
#16 0x000058e0c2899865 void llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1>(long) /workspace/docker/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:5
#17 0x000058e0bd512309 llvm::function_ref<void ()>::operator()() const /workspace/docker/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:69:5
#18 0x000058e0c289d1db void mlir::MLIRContext::executeAction<mlir::PassExecutionAction, mlir::Pass&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, mlir::Pass&) /workspace/docker/torch-mlir/externals/llvm-project/mlir/include/mlir/IR/MLIRContext.h:281:3
#19 0x000058e0c28954a7 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:532:17
#20 0x000058e0c28959c7 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:592:16
#21 0x000058e0c2897338 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:905:10
#22 0x000058e0c2897273 mlir::PassManager::run(mlir::Operation*) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:885:60
#23 0x000058e0c2888945 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:474:17
#24 0x000058e0c2888536 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPoolInterface*) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:542:12
#25 0x000058e0c28882fc mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:625:12
#26 0x000058e0c2888296 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&) /workspace/docker/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:12
#27 0x000058e0c2a08472 llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /workspace/docker/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:69:12
#28 0x000058e0c2a07a85 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) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Support/ToolUtilities.cpp:27:12
#29 0x000058e0c2884833 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:628:10
#30 0x000058e0c2884bd5 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:669:14
#31 0x000058e0c2884da8 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:685:10
#32 0x000058e0bd464ad3 main /workspace/docker/torch-mlir/externals/llvm-project/mlir/tools/mlir-opt/mlir-opt.cpp:329:33
#33 0x00007f4f5d8a5d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#34 0x00007f4f5d8a5e40 call_init ./csu/../csu/libc-start.c:128:20
#35 0x00007f4f5d8a5e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#36 0x000058e0bd4646d5 _start (/usr/local/bin/mlir-opt+0x29e16d5)
@frederick-vs-ja frederick-vs-ja added mlir crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Apr 7, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 7, 2025

@llvm/issue-subscribers-mlir

Author: Hingu piyush (piyushhingu)

0. Program arguments: mlir-opt mlirs/linalg.mlir --linalg-generalize-named-ops --test-memref-stride-calculation ``` #0 0x000058e0bd4ed8c9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /workspace/docker/torch-mlir/externals/llvm-project/llvm/lib/Support/Unix/Signals.inc:804:11 #1 0x000058e0bd4edd7b PrintStackTraceSignalHandler(void*) /workspace/docker/torch-mlir/externals/llvm-project/llvm/lib/Support/Unix/Signals.inc:880:1 #2 0x000058e0bd4ebf7f llvm::sys::RunSignalHandlers() /workspace/docker/torch-mlir/externals/llvm-project/llvm/lib/Support/Signals.cpp:105:5 #3 0x000058e0bd4ee479 SignalHandler(int, siginfo_t*, void*) /workspace/docker/torch-mlir/externals/llvm-project/llvm/lib/Support/Unix/Signals.inc:418:7 #4 0x00007f4f5d8be520 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x42520) #5 0x00007f4f5d9129fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76 #6 0x00007f4f5d9129fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10 #7 0x00007f4f5d9129fc pthread_kill ./nptl/pthread_kill.c:89:10 #8 0x00007f4f5d8be476 gsignal ./signal/../sysdeps/posix/raise.c:27:6 #9 0x00007f4f5d8a47f3 abort ./stdlib/abort.c:81:7 #10 0x00007f4f5d8a471b _nl_load_domain ./intl/loadmsgcat.c:1177:9 #11 0x00007f4f5d8b5e96 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x39e96) #12 0x000058e0c1bc5754 decltype(auto) llvm::cast<mlir::SymbolOpInterface, mlir::Operation>(mlir::Operation*) /workspace/docker/torch-mlir/externals/llvm-project/llvm/include/llvm/Support/Casting.h:579:39 #13 0x000058e0c2cc1d1d mlir::InterfacePass<mlir::SymbolOpInterface>::getOperation() /workspace/docker/torch-mlir/externals/llvm-project/mlir/include/mlir/Pass/Pass.h:443:38 #14 0x000058e0c2cc7655 (anonymous namespace)::TestMemRefStrideCalculation::runOnOperation() /workspace/docker/torch-mlir/externals/llvm-project/mlir/test/lib/Analysis/TestMemRefStrideCalculation.cpp:33:34 #15 0x000058e0c28998c4 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1::operator()() const /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:0:17 #16 0x000058e0c2899865 void llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1>(long) /workspace/docker/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:5 #17 0x000058e0bd512309 llvm::function_ref<void ()>::operator()() const /workspace/docker/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:69:5 #18 0x000058e0c289d1db void mlir::MLIRContext::executeAction<mlir::PassExecutionAction, mlir::Pass&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, mlir::Pass&) /workspace/docker/torch-mlir/externals/llvm-project/mlir/include/mlir/IR/MLIRContext.h:281:3 #19 0x000058e0c28954a7 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:532:17 #20 0x000058e0c28959c7 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:592:16 #21 0x000058e0c2897338 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:905:10 #22 0x000058e0c2897273 mlir::PassManager::run(mlir::Operation*) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:885:60 #23 0x000058e0c2888945 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:474:17 #24 0x000058e0c2888536 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPoolInterface*) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:542:12 #25 0x000058e0c28882fc mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:625:12 #26 0x000058e0c2888296 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&) /workspace/docker/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:12 #27 0x000058e0c2a08472 llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /workspace/docker/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:69:12 #28 0x000058e0c2a07a85 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) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Support/ToolUtilities.cpp:27:12 #29 0x000058e0c2884833 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:628:10 #30 0x000058e0c2884bd5 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:669:14 #31 0x000058e0c2884da8 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) /workspace/docker/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:685:10 #32 0x000058e0bd464ad3 main /workspace/docker/torch-mlir/externals/llvm-project/mlir/tools/mlir-opt/mlir-opt.cpp:329:33 #33 0x00007f4f5d8a5d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16 #34 0x00007f4f5d8a5e40 call_init ./csu/../csu/libc-start.c:128:20 #35 0x00007f4f5d8a5e40 __libc_start_main ./csu/../csu/libc-start.c:379:5 #36 0x000058e0bd4646d5 _start (/usr/local/bin/mlir-opt+0x29e16d5) ```

@joker-eph
Copy link
Collaborator

Can you provide the IR to reproduce the issue?

@piyushhingu
Copy link
Author

llvm_mlir.txt
this is an LLVM IR of an Inception-v3 converted into ONNX and than using
"torch-mlir-import-onnx" converted into torch-onnx-mlir formate and than using
"torch-mlir-opt --torch-onnx-to-torch-backend-pipeline --torch-backend-to-linalg-on-tensors-backend-pipeline"
converted into linalg mlir

@joker-eph
Copy link
Collaborator

The problem is that the pass is attached to the module instead of the function, and the module is carrying a symbol "optionally", so it may or may not be casted.
You can work around this problem by defining the pass pipeline explicitly:
--pipeline="builtin.module(func.func(test-memref-stride-calculation))"

@joker-eph joker-eph changed the title con't remove/convert an arith.constant oprations for coonverting into llvm using mlir-opt [MLIR] SymbolOpInterface pass crashes on module that does not define a symbol Apr 7, 2025
@piyushhingu
Copy link
Author

Yes, now its working
but now for the same linalg mlir file if we convert into LLVM MLIR
"mlir-opt mlirs/linalg.mlir --sparsifier"
and than convert this llvm MLIR into LLVM IR using
"mlir-translate --mlir-to-llvmir"
than
mlir-translate --mlir-to-llvmir mlirs/llvm_mlir.txt
mlirs/llvm_mlir.txt:859:12: error: Dialect `bufferization' not found for custom op 'bufferization.to_tensor'
%637 = bufferization.to_tensor %606 : memref<1x1x299x299xf32> to tensor<1x1x299x299xf32>
^
mlirs/llvm_mlir.txt:859:12: note: Registered dialects: acc, amx, arm_neon, arm_sme, arm_sve, builtin, dlti, func, gpu, llvm, nvvm, omp, rocdl, spirv, vcix, x86vector ; for more info on dialect registration see https://mlir.llvm.org/getting_started/Faq/#registered-loaded-dependent-whats-up-with-dialects-management

and for other like lenet-5 or small CNN model its give LLVM IR
can you give an pipeline that work for this Inceptions-v3 to convet into LLVM IR that can run using
LLC or LLI

@joker-eph
Copy link
Collaborator

Please use Discourse for this kind of questions, this is not related to the bug tracked here anymore.

@EugeneZelenko EugeneZelenko added the question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! label Apr 23, 2025
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 question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Projects
None yet
Development

No branches or pull requests

6 participants