Skip to content

Commit

Permalink
[pytorch/tensorexpr] Create LLJIT instance with an ObjectLinkingLayer (
Browse files Browse the repository at this point in the history
…pytorch#103824)

- Upstream LLVM switched LLJIT's default JIT linker for ELF/x86-64 to JITLink: [commit](llvm/llvm-project@b92839c). This commit mandates clients to use JITLink plugins, following the example in "llvm/examples/OrcV2Examples/LLJITWithCustomObjectLinkingLayer".

- Current change updates PytorchLLVMJITImpl to set ObjectLinkingLayer on LLJIT creation.
- If setObjectLinkingLayerCreator not set, RTDyldObjectLinkingLayer will be constructed. This is currently causing "Symbols not found: [ llvm_orc_registerEHFrameSectionWrapper ]" error for tests in test_quantization.py when pytorch is built to use latest LLVM.

Pull Request resolved: pytorch#103824
Approved by: https://github.com/jeffdaily, https://github.com/davidberard98
  • Loading branch information
skc7 authored and pytorchmergebot committed Jun 22, 2023
1 parent f818036 commit d2d3394
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions torch/csrc/jit/tensorexpr/llvm_jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,19 @@ class TORCH_API PytorchLLVMJITImpl {
c10::optional<std::string> attrs)
: TM(assertSuccess(makeTargetMachineBuilder(triple, cpu, attrs)
.createTargetMachine())),
LLJ(assertSuccess(LLJITBuilder()
.setJITTargetMachineBuilder(
makeTargetMachineBuilder(triple, cpu, attrs))
.create())) {
LLJ(assertSuccess(
LLJITBuilder()
.setJITTargetMachineBuilder(
makeTargetMachineBuilder(triple, cpu, attrs))
#if LLVM_VERSION_MAJOR >= 17
.setObjectLinkingLayerCreator([&](ExecutionSession& ES,
const Triple& TT) {
return std::make_unique<ObjectLinkingLayer>(
ES,
assertSuccess(jitlink::InProcessMemoryManager::Create()));
})
#endif
.create())) {
auto ProcSymbolsGenerator =
assertSuccess(DynamicLibrarySearchGenerator::GetForCurrentProcess(
LLJ->getDataLayout().getGlobalPrefix()));
Expand Down

0 comments on commit d2d3394

Please sign in to comment.