Skip to content

Commit

Permalink
Update caffe2 with LLVM-18 API change (pytorch#109408)
Browse files Browse the repository at this point in the history
Summary: llvm/llvm-project#66295 modified some internal LLVM APIs, update these places with the changes under LLVM version guard

Test Plan: CI

Differential Revision: D49340871

Pull Request resolved: pytorch#109408
Approved by: https://github.com/Skylion007
  • Loading branch information
modiking authored and pruthvistony committed Oct 6, 2023
1 parent ff9084e commit 308bd89
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion torch/csrc/jit/tensorexpr/llvm_codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,9 @@ void LLVMCodeGenImpl::emitKernel(
PM,
asmStream,
nullptr,
#if LLVM_VERSION_MAJOR >= 10
#if LLVM_VERSION_MAJOR >= 18
llvm::CodeGenFileType::AssemblyFile);
#elif LLVM_VERSION_MAJOR >= 10
llvm::CodeGenFileType::CGFT_AssemblyFile);
#else
llvm::TargetMachine::CodeGenFileType::CGFT_AssemblyFile);
Expand Down
4 changes: 4 additions & 0 deletions torch/csrc/jit/tensorexpr/llvm_jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ static llvm::orc::JITTargetMachineBuilder makeTargetMachineBuilder(
c10::optional<std::string> attrs) {
auto JTMB = triple ? makeJTMBFromTriple(*triple, cpu, attrs)
: makeJTMBFromHost(cpu, attrs);
#if LLVM_VERSION_MAJOR >= 18
JTMB.setCodeGenOptLevel(llvm::CodeGenOptLevel::Default);
#else
JTMB.setCodeGenOptLevel(llvm::CodeGenOpt::Default);
#endif
JTMB.getOptions().AllowFPOpFusion = llvm::FPOpFusion::Fast;
return JTMB;
}
Expand Down

0 comments on commit 308bd89

Please sign in to comment.