Merge pull request #2 from doru1004/flatten-src-folder-structure

flatten src directory structure
This commit is contained in:
Tian Jin 2019-12-23 11:41:11 -05:00 committed by GitHub
commit e9e47edc9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 119 additions and 129 deletions

View File

@ -24,9 +24,6 @@ add_subdirectory(third_party/benchmark)
add_subdirectory(third_party/pybind11) add_subdirectory(third_party/pybind11)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
add_subdirectory(src/builder)
add_subdirectory(src/compiler)
add_subdirectory(src/runtime)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(test) add_subdirectory(test)

View File

@ -156,7 +156,7 @@ function(whole_archive_link target lib_dir)
set(link_flags "${link_flags} -L${lib_dir} ") set(link_flags "${link_flags} -L${lib_dir} ")
foreach(LIB ${ARGN}) foreach(LIB ${ARGN})
string(CONCAT link_flags ${link_flags} string(CONCAT link_flags ${link_flags}
"-Wl,-force_load ${lib_dir}/lib${LIB}.a ") "-Wl,-force_load, ${lib_dir}/lib${LIB}.a ")
endforeach(LIB) endforeach(LIB)
elseif(MSVC) elseif(MSVC)
foreach(LIB ${ARGN}) foreach(LIB ${ARGN})
@ -177,9 +177,9 @@ function(whole_archive_link_mlir target)
endfunction(whole_archive_link_mlir) endfunction(whole_archive_link_mlir)
function(whole_archive_link_onnf target) function(whole_archive_link_onnf target)
foreach(LIB ${ARGN}) foreach(lib_target ${ARGN})
add_dependencies(${target} ${LIB}) add_dependencies(${target} ${lib_target})
endforeach(LIB) endforeach(lib_target)
whole_archive_link(${target} ${CMAKE_BINARY_DIR}/lib ${ARGN}) whole_archive_link(${target} ${CMAKE_BINARY_DIR}/lib ${ARGN})
endfunction(whole_archive_link_onnf) endfunction(whole_archive_link_onnf)

View File

@ -1,8 +1,78 @@
add_library(compiler
dialect/krnl/krnl_ops.cpp
dialect/krnl/krnl_ops.hpp
dialect/krnl/krnl_types.cpp
dialect/krnl/krnl_types.hpp
dialect/onnx/onnx_ops.cpp
dialect/onnx/onnx_ops.hpp
dialect/krnl/krnl_helper.cpp
dialect/krnl/krnl_helper.hpp
pass/shape_inference_pass.cpp
pass/shape_inference_interface.hpp
dialect/onnx/onnxop.inc
pass/onnx_combine.cpp
pass/lower_frontend_to_krnl.cpp
pass/passes.hpp)
# Include root src directory.
target_include_directories(compiler PRIVATE ${ONNF_SRC_ROOT})
# Include tablegen generated header files.
target_include_directories(compiler PRIVATE ${ONNF_BIN_ROOT})
target_link_libraries(compiler
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_DL_LIBS}
${MLIRLibs}
curses)
set(LLVM_TARGET_DEFINITIONS pass/shape_inference_interface.td)
onnf_tablegen(shape_inference.hpp.inc -gen-op-interface-decls)
onnf_tablegen(shape_inference.cpp.inc -gen-op-interface-defs)
add_public_tablegen_target(gen_shape_inference)
add_dependencies(compiler gen_shape_inference)
set(LLVM_TARGET_DEFINITIONS pass/onnx_combine.td)
onnf_tablegen(onnx_combine.inc -gen-rewriters)
add_public_tablegen_target(gen_onnx_combine)
add_dependencies(compiler gen_onnx_combine)
set(LLVM_TARGET_DEFINITIONS dialect/onnx/onnx.td)
onnf_tablegen(onnx.hpp.inc -gen-op-decls "-I${CMAKE_SOURCE_DIR}/compiler/pass")
onnf_tablegen(onnx.cpp.inc -gen-op-defs "-I${CMAKE_SOURCE_DIR}/compiler/pass")
add_public_tablegen_target(gen_onnx)
add_dependencies(compiler gen_onnx)
set(LLVM_TARGET_DEFINITIONS dialect/krnl/krnl_ops.td)
onnf_tablegen(krnl.hpp.inc -gen-op-decls)
onnf_tablegen(krnl.cpp.inc -gen-op-defs)
add_public_tablegen_target(gen_krnl_ops)
add_dependencies(compiler gen_krnl_ops)
add_library(onnf_shape_inference pass/shape_inference_pass.cpp)
target_include_directories(onnf_shape_inference
PRIVATE ${ONNF_SRC_ROOT} ${ONNF_BIN_ROOT}
${ONNF_SRC_ROOT})
target_link_libraries(onnf_shape_inference ${MLIRLibs})
add_dependencies(onnf_shape_inference gen_krnl_ops)
add_library(onnf_lower_frontend pass/lower_frontend_to_krnl.cpp)
target_include_directories(onnf_lower_frontend
PRIVATE ${ONNF_SRC_ROOT} ${ONNF_BIN_ROOT}
${ONNF_SRC_ROOT})
target_link_libraries(onnf_lower_frontend ${MLIRLibs})
add_dependencies(onnf_lower_frontend gen_krnl_ops)
add_subdirectory(transform)
add_subdirectory(tool)
add_subdirectory(builder)
add_subdirectory(runtime)
add_executable(onnf main.cpp) add_executable(onnf main.cpp)
target_link_libraries(onnf builder compiler ${MLIRLibs} onnf_transform) target_link_libraries(onnf builder ${MLIRLibs} onnf_transform)
whole_archive_link_mlir(onnf ${MLIRWholeArchiveLibs})
set_target_properties(onnf PROPERTIES LINK_FLAGS "-lz") set_target_properties(onnf PROPERTIES LINK_FLAGS "-lz")
whole_archive_link_mlir(onnf ${MLIRWholeArchiveLibs})
target_include_directories(onnf PRIVATE ${CMAKE_SOURCE_DIR}) target_include_directories(onnf PRIVATE ${CMAKE_SOURCE_DIR})
target_include_directories(onnf PRIVATE ${CMAKE_BINARY_DIR}) target_include_directories(onnf PRIVATE ${CMAKE_BINARY_DIR})

View File

@ -35,7 +35,7 @@
#include "llvm/ADT/ScopedHashTable.h" #include "llvm/ADT/ScopedHashTable.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "src/compiler/dialect/onnx/onnx_ops.hpp" #include "src/dialect/onnx/onnx_ops.hpp"
#include "frontend_dialect_transformer.hpp" #include "frontend_dialect_transformer.hpp"

View File

@ -1,75 +0,0 @@
add_library(
compiler
dialect/krnl/krnl_ops.cpp
dialect/krnl/krnl_ops.hpp
dialect/krnl/krnl_types.cpp
dialect/krnl/krnl_types.hpp
dialect/onnx/onnx_ops.cpp
dialect/onnx/onnx_ops.hpp
dialect/krnl/krnl_helper.cpp
dialect/krnl/krnl_helper.hpp
pass/shape_inference_pass.cpp
pass/shape_inference_interface.hpp
dialect/onnx/onnxop.inc
pass/onnx_combine.cpp
pass/lower_frontend_to_krnl.cpp
pass/passes.hpp)
# Include root src directory.
target_include_directories(compiler PRIVATE ${ONNF_SRC_ROOT})
# Include third-party libraries.
target_include_directories(compiler PRIVATE ${ONNF_SRC_ROOT}/third_party/isl/include)
target_include_directories(compiler PRIVATE ${ONNF_BIN_ROOT}/third_party/isl/include)
target_include_directories(compiler PRIVATE ${ONNF_SRC_ROOT}/third_party/Linq)
target_include_directories(compiler PRIVATE ${ONNF_SRC_ROOT}/third_party/inja/src)
target_include_directories(compiler PRIVATE ${ONNF_SRC_ROOT}/third_party/fmt/include)
# Include tablegen generated header files.
target_include_directories(compiler PRIVATE ${ONNF_BIN_ROOT})
target_link_libraries(compiler
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_DL_LIBS}
${MLIRLibs}
curses)
set(LLVM_TARGET_DEFINITIONS pass/shape_inference_interface.td)
onnf_tablegen(shape_inference.hpp.inc -gen-op-interface-decls)
onnf_tablegen(shape_inference.cpp.inc -gen-op-interface-defs)
add_public_tablegen_target(gen_shape_inference)
add_dependencies(compiler gen_shape_inference)
set(LLVM_TARGET_DEFINITIONS pass/onnx_combine.td)
onnf_tablegen(onnx_combine.inc -gen-rewriters)
add_public_tablegen_target(gen_onnx_combine)
add_dependencies(compiler gen_onnx_combine)
set(LLVM_TARGET_DEFINITIONS dialect/onnx/onnx.td)
onnf_tablegen(onnx.hpp.inc -gen-op-decls "-I${CMAKE_SOURCE_DIR}/compiler/pass")
onnf_tablegen(onnx.cpp.inc -gen-op-defs "-I${CMAKE_SOURCE_DIR}/compiler/pass")
add_public_tablegen_target(gen_onnx)
add_dependencies(compiler gen_onnx)
set(LLVM_TARGET_DEFINITIONS dialect/krnl/krnl_ops.td)
onnf_tablegen(krnl.hpp.inc -gen-op-decls)
onnf_tablegen(krnl.cpp.inc -gen-op-defs)
add_public_tablegen_target(gen_krnl_ops)
add_dependencies(compiler gen_krnl_ops)
add_library(onnf_shape_inference pass/shape_inference_pass.cpp)
target_include_directories(onnf_shape_inference
PRIVATE ${ONNF_SRC_ROOT} ${ONNF_BIN_ROOT}
${ONNF_SRC_ROOT})
target_link_libraries(onnf_shape_inference ${MLIRLibs})
add_dependencies(onnf_shape_inference gen_krnl_ops)
add_library(onnf_lower_frontend pass/lower_frontend_to_krnl.cpp)
target_include_directories(onnf_lower_frontend
PRIVATE ${ONNF_SRC_ROOT} ${ONNF_BIN_ROOT}
${ONNF_SRC_ROOT})
target_link_libraries(onnf_lower_frontend ${MLIRLibs})
add_dependencies(onnf_lower_frontend gen_krnl_ops)
add_subdirectory(transform)
add_subdirectory(tool)

View File

@ -1,5 +0,0 @@
add_library(DLCAnalysis STATIC
extract_integer_set.cpp)
target_include_directories(DLCAnalysis PRIVATE ${DLC_SRC_ROOT})
target_include_directories(DLCAnalysis PRIVATE ${DLC_BIN_ROOT})

View File

@ -1,7 +1,7 @@
#include "mlir/Dialect/AffineOps/AffineOps.h" #include "mlir/Dialect/AffineOps/AffineOps.h"
#include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineExpr.h"
#include "src/compiler/dialect/krnl/krnl_ops.hpp" #include "src/dialect/krnl/krnl_ops.hpp"
#include "krnl_helper.hpp" #include "krnl_helper.hpp"

View File

@ -24,7 +24,7 @@
#include "llvm/ADT/SetVector.h" #include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallBitVector.h" #include "llvm/ADT/SmallBitVector.h"
#include "src/compiler/dialect/krnl/krnl_helper.hpp" #include "krnl_helper.hpp"
#include "krnl_ops.hpp" #include "krnl_ops.hpp"
@ -35,7 +35,7 @@ KrnlOpsDialect::KrnlOpsDialect(MLIRContext *context)
: Dialect(getDialectNamespace(), context) { : Dialect(getDialectNamespace(), context) {
addOperations< addOperations<
#define GET_OP_LIST #define GET_OP_LIST
#include "src/compiler/krnl.cpp.inc" #include "src/krnl.cpp.inc"
>(); >();
addTypes<LoopType>(); addTypes<LoopType>();
} }
@ -373,5 +373,5 @@ void KrnlEntryPointOp::build(mlir::Builder *builder, OperationState &state,
} }
#define GET_OP_CLASSES #define GET_OP_CLASSES
#include "src/compiler/krnl.cpp.inc" #include "src/krnl.cpp.inc"
} // namespace mlir } // namespace mlir

View File

@ -15,8 +15,8 @@
#include "mlir/IR/OpDefinition.h" #include "mlir/IR/OpDefinition.h"
#include "mlir/IR/StandardTypes.h" #include "mlir/IR/StandardTypes.h"
#include "src/compiler/dialect/krnl/krnl_helper.hpp" #include "src/dialect/krnl/krnl_helper.hpp"
#include "src/compiler/dialect/krnl/krnl_types.hpp" #include "src/dialect/krnl/krnl_types.hpp"
namespace mlir { namespace mlir {
class KrnlOpsDialect : public Dialect { class KrnlOpsDialect : public Dialect {
@ -43,5 +43,5 @@ public:
}; };
#define GET_OP_CLASSES #define GET_OP_CLASSES
#include "src/compiler/krnl.hpp.inc" #include "src/krnl.hpp.inc"
} // namespace mlir } // namespace mlir

View File

@ -33,7 +33,7 @@ ONNXOpsDialect::ONNXOpsDialect(mlir::MLIRContext *ctx)
: mlir::Dialect(getDialectNamespace(), ctx) { : mlir::Dialect(getDialectNamespace(), ctx) {
addOperations< addOperations<
#define GET_OP_LIST #define GET_OP_LIST
#include "src/compiler/onnx.cpp.inc" #include "src/onnx.cpp.inc"
>(); >();
} }
@ -389,4 +389,4 @@ void ONNXReshapeOp::inferShapes() {
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define GET_OP_CLASSES #define GET_OP_CLASSES
#include "src/compiler/onnx.cpp.inc" #include "src/onnx.cpp.inc"

View File

@ -16,7 +16,7 @@
#include "mlir/IR/OpDefinition.h" #include "mlir/IR/OpDefinition.h"
#include "mlir/IR/StandardTypes.h" #include "mlir/IR/StandardTypes.h"
#include "src/compiler/pass/shape_inference_interface.hpp" #include "src/pass/shape_inference_interface.hpp"
namespace mlir { namespace mlir {
@ -32,7 +32,7 @@ class ONNXOpsDialect : public Dialect {
/// Include the auto-generated header file containing the declarations of the /// Include the auto-generated header file containing the declarations of the
/// ONNX operations. /// ONNX operations.
#define GET_OP_CLASSES #define GET_OP_CLASSES
#include "src/compiler/onnx.hpp.inc" #include "src/onnx.hpp.inc"
} // end namespace mlir } // end namespace mlir

View File

@ -17,9 +17,9 @@
#include "llvm/Support/SourceMgr.h" #include "llvm/Support/SourceMgr.h"
#include "src/builder/frontend_dialect_transformer.hpp" #include "src/builder/frontend_dialect_transformer.hpp"
#include "src/compiler/dialect/krnl/krnl_ops.hpp" #include "src/dialect/krnl/krnl_ops.hpp"
#include "src/compiler/dialect/onnx/onnx_ops.hpp" #include "src/dialect/onnx/onnx_ops.hpp"
#include "src/compiler/pass/passes.hpp" #include "src/pass/passes.hpp"
#include "mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h" #include "mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h"
#include "mlir/ExecutionEngine/ExecutionEngine.h" #include "mlir/ExecutionEngine/ExecutionEngine.h"
@ -87,10 +87,13 @@ int main(int argc, char *argv[]) {
llvm::cl::opt<EmissionTargetType> emissionTarget( llvm::cl::opt<EmissionTargetType> emissionTarget(
llvm::cl::desc("Choose target to emit:"), llvm::cl::desc("Choose target to emit:"),
llvm::cl::values( llvm::cl::values(
clEnumVal(EmitONNXIR, "No optimizations, enable debugging"), clEnumVal(EmitONNXIR,
clEnumVal(EmitMLIR, "Enable trivial optimizations"), "Ingest ONNX and emit corresponding ONNX dialect."),
clEnumVal(EmitLLVMIR, "Enable default optimizations"), clEnumVal(EmitMLIR,
clEnumVal(EmitLLVMBC, "Enable expensive optimizations")), "Lower model to MLIR built-in transformation dialect."),
clEnumVal(EmitLLVMIR, "Lower model to LLVM IR (LLVM dialect)."),
clEnumVal(EmitLLVMBC, "Lower model to LLVM IR and emit (to file) "
"LLVM bitcode for model.")),
llvm::cl::init(EmitLLVMBC), llvm::cl::cat(OnnfOptions)); llvm::cl::init(EmitLLVMBC), llvm::cl::cat(OnnfOptions));
llvm::cl::HideUnrelatedOptions(OnnfOptions); llvm::cl::HideUnrelatedOptions(OnnfOptions);

View File

@ -17,10 +17,10 @@
#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Sequence.h" #include "llvm/ADT/Sequence.h"
#include "src/compiler/dialect/krnl/krnl_helper.hpp" #include "src/dialect/krnl/krnl_helper.hpp"
#include "src/compiler/dialect/krnl/krnl_ops.hpp" #include "src/dialect/krnl/krnl_ops.hpp"
#include "src/compiler/dialect/onnx/onnx_ops.hpp" #include "src/dialect/onnx/onnx_ops.hpp"
#include "src/compiler/pass/passes.hpp" #include "src/pass/passes.hpp"
using namespace mlir; using namespace mlir;

View File

@ -13,13 +13,13 @@
#include "mlir/IR/PatternMatch.h" #include "mlir/IR/PatternMatch.h"
#include <numeric> #include <numeric>
#include "src/compiler/dialect/onnx/onnx_ops.hpp" #include "src/dialect/onnx/onnx_ops.hpp"
using namespace mlir; using namespace mlir;
namespace { namespace {
/// Include the patterns defined in the Declarative Rewrite framework. /// Include the patterns defined in the Declarative Rewrite framework.
#include "src/compiler/onnx_combine.inc" #include "src/onnx_combine.inc"
} // end anonymous namespace } // end anonymous namespace
/// Register optimization patterns as "canonicalization" patterns /// Register optimization patterns as "canonicalization" patterns

View File

@ -16,6 +16,6 @@
namespace mlir { namespace mlir {
/// Include the auto-generated declarations. /// Include the auto-generated declarations.
#include "src/compiler/shape_inference.hpp.inc" #include "src/shape_inference.hpp.inc"
} // end namespace mlir } // end namespace mlir

View File

@ -14,14 +14,14 @@
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "shape_inference_interface.hpp" #include "shape_inference_interface.hpp"
#include "src/compiler/dialect/onnx/onnx_ops.hpp" #include "src/dialect/onnx/onnx_ops.hpp"
#include "passes.hpp" #include "passes.hpp"
using namespace mlir; using namespace mlir;
// Include the auto-generated definitions for the shape inference interfaces. // Include the auto-generated definitions for the shape inference interfaces.
#include "src/compiler/shape_inference.cpp.inc" #include "src/shape_inference.cpp.inc"
namespace { namespace {
/*! /*!

View File

@ -3,8 +3,8 @@ add_library(cruntime
dyn_memref.h dyn_memref.h
data_type.h) data_type.h)
target_include_directories(cruntime target_include_directories(cruntime
PRIVATE ${DLC_SRC_ROOT} ${DLC_BIN_ROOT} PRIVATE ${ONNF_SRC_ROOT} ${ONNF_BIN_ROOT}
${DLC_SRC_ROOT}) ${ONNF_SRC_ROOT})
pybind11_add_module(pyruntime pybind11_add_module(pyruntime
dyn_memref.cpp dyn_memref.cpp

View File

@ -14,9 +14,9 @@
#include <mlir/Support/FileUtilities.h> #include <mlir/Support/FileUtilities.h>
#include <mlir/Support/MlirOptMain.h> #include <mlir/Support/MlirOptMain.h>
#include "src/compiler/dialect/krnl/krnl_ops.hpp" #include "src/dialect/krnl/krnl_ops.hpp"
#include "src/compiler/dialect/onnx/onnx_ops.hpp" #include "src/dialect/onnx/onnx_ops.hpp"
#include "src/compiler/pass/passes.hpp" #include "src/pass/passes.hpp"
using namespace onnf; using namespace onnf;

View File

@ -3,8 +3,8 @@
#include "mlir/Pass/Pass.h" #include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h" #include "mlir/Transforms/DialectConversion.h"
#include "src/compiler/dialect/krnl/krnl_ops.hpp" #include "src/dialect/krnl/krnl_ops.hpp"
#include "src/compiler/pass/passes.hpp" #include "src/pass/passes.hpp"
using namespace mlir; using namespace mlir;

View File

@ -16,8 +16,8 @@
#include "mlir/Transforms/DialectConversion.h" #include "mlir/Transforms/DialectConversion.h"
#include "llvm/ADT/Sequence.h" #include "llvm/ADT/Sequence.h"
#include "src/compiler/dialect/krnl/krnl_ops.hpp" #include "src/dialect/krnl/krnl_ops.hpp"
#include "src/compiler/pass/passes.hpp" #include "src/pass/passes.hpp"
using namespace mlir; using namespace mlir;