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)
set(CMAKE_CXX_STANDARD 14)
add_subdirectory(src/builder)
add_subdirectory(src/compiler)
add_subdirectory(src/runtime)
add_subdirectory(src)
add_subdirectory(test)

View File

@ -153,10 +153,10 @@ set(MLIRWholeArchiveLibs
function(whole_archive_link target lib_dir)
get_property(link_flags TARGET ${target} PROPERTY LINK_FLAGS)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(link_flags "${link_flags} -L${lib_dir} ")
set(link_flags "${link_flags} -L${lib_dir} ")
foreach(LIB ${ARGN})
string(CONCAT link_flags ${link_flags}
"-Wl,-force_load ${lib_dir}/lib${LIB}.a ")
"-Wl,-force_load, ${lib_dir}/lib${LIB}.a ")
endforeach(LIB)
elseif(MSVC)
foreach(LIB ${ARGN})
@ -177,9 +177,9 @@ function(whole_archive_link_mlir target)
endfunction(whole_archive_link_mlir)
function(whole_archive_link_onnf target)
foreach(LIB ${ARGN})
add_dependencies(${target} ${LIB})
endforeach(LIB)
foreach(lib_target ${ARGN})
add_dependencies(${target} ${lib_target})
endforeach(lib_target)
whole_archive_link(${target} ${CMAKE_BINARY_DIR}/lib ${ARGN})
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)
target_link_libraries(onnf builder compiler ${MLIRLibs} onnf_transform)
whole_archive_link_mlir(onnf ${MLIRWholeArchiveLibs})
target_link_libraries(onnf builder ${MLIRLibs} onnf_transform)
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_BINARY_DIR})

View File

@ -35,7 +35,7 @@
#include "llvm/ADT/ScopedHashTable.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"

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/IR/AffineExpr.h"
#include "src/compiler/dialect/krnl/krnl_ops.hpp"
#include "src/dialect/krnl/krnl_ops.hpp"
#include "krnl_helper.hpp"

View File

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

View File

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

View File

@ -33,7 +33,7 @@ ONNXOpsDialect::ONNXOpsDialect(mlir::MLIRContext *ctx)
: mlir::Dialect(getDialectNamespace(), ctx) {
addOperations<
#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
#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/StandardTypes.h"
#include "src/compiler/pass/shape_inference_interface.hpp"
#include "src/pass/shape_inference_interface.hpp"
namespace mlir {
@ -32,7 +32,7 @@ class ONNXOpsDialect : public Dialect {
/// Include the auto-generated header file containing the declarations of the
/// ONNX operations.
#define GET_OP_CLASSES
#include "src/compiler/onnx.hpp.inc"
#include "src/onnx.hpp.inc"
} // end namespace mlir

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
add_library(onnf_transform
lower_krnl.cpp
lower_to_llvm.cpp)
lower_krnl.cpp
lower_to_llvm.cpp)
target_include_directories(onnf_transform
PRIVATE ${ONNF_SRC_ROOT} ${ONNF_BIN_ROOT}

View File

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

View File

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