mirror of https://github.com/llvm/torch-mlir
[RefBackend] Move runtime related code under npcomp/RefBackend/
Other than the dialect definitions (which will live in standard Dialect/ subdirectory), the goal here is to keep RefBackend-related code nested in {include/npcomp,lib,test}/RefBackend.pull/73/head
parent
51d51241b4
commit
83ad70ef54
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "mlir/ExecutionEngine/ExecutionEngine.h"
|
||||
#include "mlir/IR/Module.h"
|
||||
#include "npcomp/runtime/UserAPI.h"
|
||||
#include "npcomp/RefBackend/Runtime/UserAPI.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
|
@ -0,0 +1,14 @@
|
|||
RefBackendRt (namespace `refbackrt`) is the runtime support library for the
|
||||
RefBackend backend. It is best practice to keep compiler and runtime code
|
||||
totally firewalled.
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
As such, this directory should have NO DEPENDENCIES ON COMPILER CODE (no
|
||||
LLVM libSupport, etc.).
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
This will cause some duplication, but history has shown that this
|
||||
firewalling pays big dividends. In particular, compiler code very
|
||||
frequently has binary sizes that are simply unacceptable in runtime
|
||||
scenarios, such as MByte-sized dependencies like LLVM libSupport.
|
||||
Runtime code should fit in kBytes.
|
|
@ -13,15 +13,15 @@
|
|||
// even if things superficially look similar, remember that there are no
|
||||
// LLVM utilities here, memory allocation should be kept to a minimum, etc.
|
||||
//
|
||||
// npcomp/runtime/Support.h provides some minimal LLVM-like support code to keep
|
||||
// the API familiar.
|
||||
// npcomp/RefBackend/Runtime/Support.h provides some minimal LLVM-like support
|
||||
// code to keep the API familiar.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef NPCOMP_RUNTIME_USERAPI_H
|
||||
#define NPCOMP_RUNTIME_USERAPI_H
|
||||
|
||||
#include "npcomp/runtime/Support.h"
|
||||
#include "npcomp/RefBackend/Runtime/Support.h"
|
||||
#include <atomic>
|
||||
#include <cstdlib>
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
This directory is named `runtime` instead of `Runtime` in order to be a
|
||||
slight reminder that it is a totally separate codebase from the compiler
|
||||
code. (There is no difference in naming conventions other than this one
|
||||
directory though)
|
||||
|
||||
It is best practice to keep compiler and runtime code totally firewalled.
|
||||
Right now, we don't have a good place to put the runtime code that fits in
|
||||
nicely with #include paths and stuff (we would like users to use something
|
||||
like `npcomp/runtime/UserAPI.h` to be the include path).
|
||||
|
||||
We could have a top-level `runtime` directory with
|
||||
`runtime/include/npcomp/runtime/UserAPI.h` but that just felt too
|
||||
heavyweight right now.
|
|
@ -16,7 +16,7 @@ target_link_libraries(NPCOMPBackendRefJITPythonModule
|
|||
MLIRTargetLLVMIR
|
||||
|
||||
NPCOMPPythonCommon
|
||||
NPCOMPJITRuntime
|
||||
NPCOMPRefBackendJITHelpers
|
||||
)
|
||||
|
||||
npcomp_python_target_compile_options(NPCOMPBackendRefJITPythonModule)
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
#include "pybind11/numpy.h"
|
||||
|
||||
#include "npcomp/JITRuntime/JITModule.h"
|
||||
#include "npcomp/Python/MlirIr.h"
|
||||
#include "npcomp/Python/MlirPass.h"
|
||||
#include "npcomp/RefBackend/JITHelpers/JITModule.h"
|
||||
|
||||
using llvm::SmallVector;
|
||||
using llvm::StringRef;
|
||||
|
|
|
@ -2,10 +2,8 @@ add_subdirectory(CAPI)
|
|||
add_subdirectory(Conversion)
|
||||
add_subdirectory(Dialect)
|
||||
add_subdirectory(RefBackend)
|
||||
add_subdirectory(JITRuntime)
|
||||
add_subdirectory(Python)
|
||||
add_subdirectory(Typing)
|
||||
add_subdirectory(runtime)
|
||||
|
||||
if(NPCOMP_ENABLE_REFJIT)
|
||||
add_subdirectory(Backend/RefJIT)
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
add_subdirectory(Runtime)
|
||||
add_subdirectory(JITHelpers)
|
||||
|
||||
add_mlir_library(NPCOMPRefBackend
|
||||
BypassShapes.cpp
|
||||
RefBackend.cpp
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
add_mlir_library(NPCOMPJITRuntime
|
||||
add_mlir_library(NPCOMPRefBackendJITHelpers
|
||||
JITModule.cpp
|
||||
|
||||
ADDITIONAL_HEADER_DIRS
|
||||
${PROJECT_SRC_DIR}/include/npcomp/JITRuntime
|
||||
${PROJECT_SRC_DIR}/include/npcomp/RefBackend/JITHelpers
|
||||
|
||||
LINK_COMPONENTS
|
||||
Core
|
|
@ -6,7 +6,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "npcomp/JITRuntime/JITModule.h"
|
||||
#include "npcomp/RefBackend/JITHelpers/JITModule.h"
|
||||
#include "mlir/ExecutionEngine/CRunnerUtils.h"
|
||||
#include "mlir/ExecutionEngine/OptUtils.h"
|
||||
#include "npcomp/RefBackend/RefBackend.h"
|
|
@ -11,9 +11,6 @@ set(LLVM_OPTIONAL_SOURCES
|
|||
add_mlir_library(NPCOMPRuntime
|
||||
Runtime.cpp
|
||||
|
||||
LINK_LIBS
|
||||
MLIRExecutionEngine
|
||||
|
||||
EXCLUDE_FROM_LIBMLIR
|
||||
)
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
#include <iostream>
|
||||
|
||||
#include "CompilerDataStructures.h"
|
||||
#include "npcomp/runtime/UserAPI.h"
|
||||
#include "npcomp/RefBackend/Runtime/UserAPI.h"
|
||||
|
||||
using namespace npcomprt;
|
||||
|
||||
|
@ -121,4 +121,4 @@ __npcomp_compiler_rt_get_global(GlobalDescriptor *global) {
|
|||
ArrayRef<std::int32_t>(global->extents, global->numExtents),
|
||||
global->data);
|
||||
return UnrankedMemref{global->numExtents, descriptor};
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "npcomp/runtime/UserAPI.h"
|
||||
#include "npcomp/RefBackend/Runtime/UserAPI.h"
|
||||
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
@ -122,4 +122,4 @@ LogicalResult npcomprt::getMetadata(ModuleDescriptor *moduleDescriptor,
|
|||
outMetadata.numInputs = descriptor->numInputs;
|
||||
outMetadata.numOutputs = descriptor->numOutputs;
|
||||
return success();
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ target_link_libraries(mnist-playground PRIVATE
|
|||
MLIRTargetLLVMIR
|
||||
MLIRSupport
|
||||
NPCOMPInitAll
|
||||
NPCOMPJITRuntime
|
||||
NPCOMPRefBackendJITHelpers
|
||||
${conversion_libs}
|
||||
${dialect_libs}
|
||||
${TORCH_LIBRARIES}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "mlir/Parser.h"
|
||||
#include "mlir/Pass/PassManager.h"
|
||||
#include "npcomp/InitAll.h"
|
||||
#include "npcomp/JITRuntime/JITModule.h"
|
||||
#include "npcomp/RefBackend/JITHelpers/JITModule.h"
|
||||
#include "llvm/Support/InitLLVM.h"
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ target_link_libraries(npcomp-run-mlir PRIVATE
|
|||
MLIRTargetLLVMIR
|
||||
MLIRSupport
|
||||
NPCOMPInitAll
|
||||
NPCOMPJITRuntime
|
||||
NPCOMPRefBackendJITHelpers
|
||||
${conversion_libs}
|
||||
${dialect_libs}
|
||||
)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "mlir/Parser.h"
|
||||
#include "mlir/Pass/PassManager.h"
|
||||
#include "npcomp/InitAll.h"
|
||||
#include "npcomp/JITRuntime/JITModule.h"
|
||||
#include "npcomp/RefBackend/JITHelpers/JITModule.h"
|
||||
#include "llvm/Support/InitLLVM.h"
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue