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

LLVM ERROR: pattern '(anonymous namespace)::AdjustCallingConventionForReturn' does not support 1:N conversion #4018

Open
AnaT246 opened this issue Feb 12, 2025 · 2 comments
Assignees

Comments

@AnaT246
Copy link

AnaT246 commented Feb 12, 2025

There's an error with this code
torch-mlir-opt -pass-pipeline='builtin.module(torchscript-module-to-torch-backend-pipeline)' ~/tmp/torch_raw.mlir | tee ~/tmp/torch.mlir
This is the torch_raw.mlir file:

`module` attributes {torch.debug_module_name = "SimpleModule"} {
  func.func private @__torch__.SimpleModule.forward(%arg0: !torch.nn.Module<"__torch__.SimpleModule">, %arg1: !torch.tensor {torch.type_bound = !torch.vtensor<[3,4,4],f32>}) -> !torch.tuple<tensor, tensor> {
    %sign, %logabsdet = torch.aten.linalg_slogdet %arg1 : !torch.tensor -> !torch.tensor, !torch.tensor
    %1 = torch.prim.TupleConstruct %sign, %logabsdet : !torch.tensor, !torch.tensor -> !torch.tuple<tensor, tensor>
    return %1 : !torch.tuple<tensor, tensor>
  }
  torch.class_type @__torch__.SimpleModule {
    torch.attr private "training" : !torch.bool
    torch.attr private "_is_full_backward_hook" : !torch.optional<bool>
    torch.method "forward", @__torch__.SimpleModule.forward
  }
  %false = torch.constant.bool false
  %none = torch.constant.none
  %0 = torch.nn_module {
    torch.slot "training", %false : !torch.bool
    torch.slot "_is_full_backward_hook", %none : !torch.none
  } : !torch.nn.Module<"__torch__.SimpleModule">
}

And this is the error I get:

LLVM ERROR: pattern '(anonymous namespace)::AdjustCallingConventionForReturn' does not support 1:N conversion
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: torch-mlir-opt -pass-pipeline=builtin.module(torchscript-module-to-torch-backend-pipeline) /home/ana_todorovic/tmp/torch_raw.mlir
 #0 0x000055fc16d93928 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0x28eb928)
 #1 0x000055fc16d9156e llvm::sys::RunSignalHandlers() (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0x28e956e)
 #2 0x000055fc16d93fb8 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f3d8a386330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #4 0x00007f3d8a3dfb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
 #5 0x00007f3d8a38627e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
 #6 0x00007f3d8a3698ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #7 0x000055fc16d5d82c llvm::report_fatal_error(llvm::Twine const&, bool) (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0x28b582c)
 #8 0x000055fc167384b7 (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0x22904b7)
 #9 0x000055fc154f839e mlir::OpConversionPattern<mlir::func::ReturnOp>::matchAndRewrite(mlir::func::ReturnOp, mlir::func::ReturnOpGenericAdaptor<llvm::ArrayRef<mlir::ValueRange>>, mlir::ConversionPatternRewriter&) const AdjustCallingConventions.cpp:0:0
#10 0x000055fc154f7b25 mlir::OpConversionPattern<mlir::func::ReturnOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::ValueRange>, mlir::ConversionPatternRewriter&) const AdjustCallingConventions.cpp:0:0
#11 0x000055fc16738656 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0x2290656)
#12 0x000055fc16775c8e 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 0x000055fc1677250b 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&)>) (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0x22ca50b)
#14 0x000055fc167398bb (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#15 0x000055fc16738777 mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0x2290777)
#16 0x000055fc16739aff mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>) (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0x2291aff)        
#17 0x000055fc1673ed9b mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0x2296d9b)
#18 0x000055fc154f1803 (anonymous namespace)::AdjustCallingConventionsPass::runOnOperation() AdjustCallingConventions.cpp:0:0
#19 0x000055fc167c8d72 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0x2320d72)
#20 0x000055fc167c9760 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0x2321760)
#21 0x000055fc167cbe1c mlir::PassManager::run(mlir::Operation*) (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0x2323e1c)
#22 0x000055fc14fc9e1b performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0      
#23 0x000055fc14fc9a7f 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 0x000055fc16d2bc65 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) (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0x2883c65)
#25 0x000055fc14fc10e5 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0xb190e5)
#26 0x000055fc14fc1393 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0xb19393)
#27 0x000055fc14fc15a2 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0xb195a2)
#28 0x000055fc14fbf862 main (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0xb17862)
#29 0x00007f3d8a36b1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#30 0x00007f3d8a36b28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#31 0x000055fc14fbf495 _start (/home/ana_todorovic/torch-mlir/build/bin/torch-mlir-opt+0xb17495)
@vivekkhandelwal1
Copy link
Collaborator

@praveen-g-ctt, if you have some cycles, can you please take a look at this?

@praveen-g-ctt praveen-g-ctt self-assigned this Feb 20, 2025
@praveen-g-ctt
Copy link
Contributor

I see a PR related to this #4034 . This should fix the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants