From da4527c9618c0a8f5ce9d8e9605ede280b5cb98b Mon Sep 17 00:00:00 2001 From: Tian Jin Date: Mon, 23 Dec 2019 00:13:52 -0500 Subject: [PATCH 1/5] flatten src directory structure --- CMakeLists.txt | 3 - src/CMakeLists.txt | 70 +++++++++++++++++ src/builder/frontend_dialect_transformer.cpp | 2 +- src/compiler/CMakeLists.txt | 75 ------------------- src/compiler/analysis/CMakeLists.txt | 5 -- .../dialect/krnl/krnl_helper.cpp | 2 +- .../dialect/krnl/krnl_helper.hpp | 0 src/{compiler => }/dialect/krnl/krnl_ops.cpp | 6 +- src/{compiler => }/dialect/krnl/krnl_ops.hpp | 6 +- src/{compiler => }/dialect/krnl/krnl_ops.td | 0 .../dialect/krnl/krnl_types.cpp | 0 .../dialect/krnl/krnl_types.hpp | 0 src/{compiler => }/dialect/onnx/gen_doc.py | 0 src/{compiler => }/dialect/onnx/onnx.td | 0 src/{compiler => }/dialect/onnx/onnx_ops.cpp | 4 +- src/{compiler => }/dialect/onnx/onnx_ops.hpp | 4 +- src/{compiler => }/dialect/onnx/onnxop.inc | 0 src/main.cpp | 6 +- .../pass/lower_frontend_to_krnl.cpp | 8 +- src/{compiler => }/pass/onnx_combine.cpp | 4 +- src/{compiler => }/pass/onnx_combine.td | 0 src/{compiler => }/pass/passes.hpp | 0 .../pass/shape_inference_interface.hpp | 2 +- .../pass/shape_inference_interface.td | 0 .../pass/shape_inference_pass.cpp | 4 +- src/runtime/CMakeLists.txt | 4 +- src/{compiler => }/tool/CMakeLists.txt | 0 .../tool/onnf_opt/CMakeLists.txt | 0 src/{compiler => }/tool/onnf_opt/onnf_opt.cpp | 6 +- src/{compiler => }/transform/CMakeLists.txt | 4 +- src/{compiler => }/transform/lower_krnl.cpp | 4 +- .../transform/lower_to_llvm.cpp | 4 +- 32 files changed, 105 insertions(+), 118 deletions(-) delete mode 100644 src/compiler/CMakeLists.txt delete mode 100644 src/compiler/analysis/CMakeLists.txt rename src/{compiler => }/dialect/krnl/krnl_helper.cpp (98%) rename src/{compiler => }/dialect/krnl/krnl_helper.hpp (100%) rename src/{compiler => }/dialect/krnl/krnl_ops.cpp (99%) rename src/{compiler => }/dialect/krnl/krnl_ops.hpp (89%) rename src/{compiler => }/dialect/krnl/krnl_ops.td (100%) rename src/{compiler => }/dialect/krnl/krnl_types.cpp (100%) rename src/{compiler => }/dialect/krnl/krnl_types.hpp (100%) rename src/{compiler => }/dialect/onnx/gen_doc.py (100%) rename src/{compiler => }/dialect/onnx/onnx.td (100%) rename src/{compiler => }/dialect/onnx/onnx_ops.cpp (99%) rename src/{compiler => }/dialect/onnx/onnx_ops.hpp (91%) rename src/{compiler => }/dialect/onnx/onnxop.inc (100%) rename src/{compiler => }/pass/lower_frontend_to_krnl.cpp (99%) rename src/{compiler => }/pass/onnx_combine.cpp (92%) rename src/{compiler => }/pass/onnx_combine.td (100%) rename src/{compiler => }/pass/passes.hpp (100%) rename src/{compiler => }/pass/shape_inference_interface.hpp (92%) rename src/{compiler => }/pass/shape_inference_interface.td (100%) rename src/{compiler => }/pass/shape_inference_pass.cpp (98%) rename src/{compiler => }/tool/CMakeLists.txt (100%) rename src/{compiler => }/tool/onnf_opt/CMakeLists.txt (100%) rename src/{compiler => }/tool/onnf_opt/onnf_opt.cpp (94%) rename src/{compiler => }/transform/CMakeLists.txt (83%) rename src/{compiler => }/transform/lower_krnl.cpp (98%) rename src/{compiler => }/transform/lower_to_llvm.cpp (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cc613d..21b5aba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index df95708..9cb0488 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,73 @@ +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) diff --git a/src/builder/frontend_dialect_transformer.cpp b/src/builder/frontend_dialect_transformer.cpp index 3547f1d..ec5057b 100644 --- a/src/builder/frontend_dialect_transformer.cpp +++ b/src/builder/frontend_dialect_transformer.cpp @@ -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" diff --git a/src/compiler/CMakeLists.txt b/src/compiler/CMakeLists.txt deleted file mode 100644 index 5d16100..0000000 --- a/src/compiler/CMakeLists.txt +++ /dev/null @@ -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) diff --git a/src/compiler/analysis/CMakeLists.txt b/src/compiler/analysis/CMakeLists.txt deleted file mode 100644 index 01a1fcb..0000000 --- a/src/compiler/analysis/CMakeLists.txt +++ /dev/null @@ -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}) \ No newline at end of file diff --git a/src/compiler/dialect/krnl/krnl_helper.cpp b/src/dialect/krnl/krnl_helper.cpp similarity index 98% rename from src/compiler/dialect/krnl/krnl_helper.cpp rename to src/dialect/krnl/krnl_helper.cpp index b1e6de1..8f76c46 100644 --- a/src/compiler/dialect/krnl/krnl_helper.cpp +++ b/src/dialect/krnl/krnl_helper.cpp @@ -1,7 +1,7 @@ #include "mlir/Dialect/AffineOps/AffineOps.h" #include "mlir/IR/AffineExpr.h" -#include "src/compiler/dialect/krnl/krnl_ops.hpp" +#include "krnl_ops.hpp" #include "krnl_helper.hpp" diff --git a/src/compiler/dialect/krnl/krnl_helper.hpp b/src/dialect/krnl/krnl_helper.hpp similarity index 100% rename from src/compiler/dialect/krnl/krnl_helper.hpp rename to src/dialect/krnl/krnl_helper.hpp diff --git a/src/compiler/dialect/krnl/krnl_ops.cpp b/src/dialect/krnl/krnl_ops.cpp similarity index 99% rename from src/compiler/dialect/krnl/krnl_ops.cpp rename to src/dialect/krnl/krnl_ops.cpp index a436d7c..b597494 100644 --- a/src/compiler/dialect/krnl/krnl_ops.cpp +++ b/src/dialect/krnl/krnl_ops.cpp @@ -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(); } @@ -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 diff --git a/src/compiler/dialect/krnl/krnl_ops.hpp b/src/dialect/krnl/krnl_ops.hpp similarity index 89% rename from src/compiler/dialect/krnl/krnl_ops.hpp rename to src/dialect/krnl/krnl_ops.hpp index b51bda0..e859dde 100644 --- a/src/compiler/dialect/krnl/krnl_ops.hpp +++ b/src/dialect/krnl/krnl_ops.hpp @@ -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 "krnl_helper.hpp" +#include "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 diff --git a/src/compiler/dialect/krnl/krnl_ops.td b/src/dialect/krnl/krnl_ops.td similarity index 100% rename from src/compiler/dialect/krnl/krnl_ops.td rename to src/dialect/krnl/krnl_ops.td diff --git a/src/compiler/dialect/krnl/krnl_types.cpp b/src/dialect/krnl/krnl_types.cpp similarity index 100% rename from src/compiler/dialect/krnl/krnl_types.cpp rename to src/dialect/krnl/krnl_types.cpp diff --git a/src/compiler/dialect/krnl/krnl_types.hpp b/src/dialect/krnl/krnl_types.hpp similarity index 100% rename from src/compiler/dialect/krnl/krnl_types.hpp rename to src/dialect/krnl/krnl_types.hpp diff --git a/src/compiler/dialect/onnx/gen_doc.py b/src/dialect/onnx/gen_doc.py similarity index 100% rename from src/compiler/dialect/onnx/gen_doc.py rename to src/dialect/onnx/gen_doc.py diff --git a/src/compiler/dialect/onnx/onnx.td b/src/dialect/onnx/onnx.td similarity index 100% rename from src/compiler/dialect/onnx/onnx.td rename to src/dialect/onnx/onnx.td diff --git a/src/compiler/dialect/onnx/onnx_ops.cpp b/src/dialect/onnx/onnx_ops.cpp similarity index 99% rename from src/compiler/dialect/onnx/onnx_ops.cpp rename to src/dialect/onnx/onnx_ops.cpp index 5b60279..4cb920c 100644 --- a/src/compiler/dialect/onnx/onnx_ops.cpp +++ b/src/dialect/onnx/onnx_ops.cpp @@ -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" diff --git a/src/compiler/dialect/onnx/onnx_ops.hpp b/src/dialect/onnx/onnx_ops.hpp similarity index 91% rename from src/compiler/dialect/onnx/onnx_ops.hpp rename to src/dialect/onnx/onnx_ops.hpp index 9903b62..1ba9669 100644 --- a/src/compiler/dialect/onnx/onnx_ops.hpp +++ b/src/dialect/onnx/onnx_ops.hpp @@ -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 diff --git a/src/compiler/dialect/onnx/onnxop.inc b/src/dialect/onnx/onnxop.inc similarity index 100% rename from src/compiler/dialect/onnx/onnxop.inc rename to src/dialect/onnx/onnxop.inc diff --git a/src/main.cpp b/src/main.cpp index eb4b8e4..427de11 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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" diff --git a/src/compiler/pass/lower_frontend_to_krnl.cpp b/src/pass/lower_frontend_to_krnl.cpp similarity index 99% rename from src/compiler/pass/lower_frontend_to_krnl.cpp rename to src/pass/lower_frontend_to_krnl.cpp index b94a269..949cf9d 100644 --- a/src/compiler/pass/lower_frontend_to_krnl.cpp +++ b/src/pass/lower_frontend_to_krnl.cpp @@ -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 "passes.hpp" using namespace mlir; diff --git a/src/compiler/pass/onnx_combine.cpp b/src/pass/onnx_combine.cpp similarity index 92% rename from src/compiler/pass/onnx_combine.cpp rename to src/pass/onnx_combine.cpp index ef75579..22960a0 100644 --- a/src/compiler/pass/onnx_combine.cpp +++ b/src/pass/onnx_combine.cpp @@ -13,13 +13,13 @@ #include "mlir/IR/PatternMatch.h" #include -#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 diff --git a/src/compiler/pass/onnx_combine.td b/src/pass/onnx_combine.td similarity index 100% rename from src/compiler/pass/onnx_combine.td rename to src/pass/onnx_combine.td diff --git a/src/compiler/pass/passes.hpp b/src/pass/passes.hpp similarity index 100% rename from src/compiler/pass/passes.hpp rename to src/pass/passes.hpp diff --git a/src/compiler/pass/shape_inference_interface.hpp b/src/pass/shape_inference_interface.hpp similarity index 92% rename from src/compiler/pass/shape_inference_interface.hpp rename to src/pass/shape_inference_interface.hpp index 8f4feb1..a964e24 100644 --- a/src/compiler/pass/shape_inference_interface.hpp +++ b/src/pass/shape_inference_interface.hpp @@ -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 diff --git a/src/compiler/pass/shape_inference_interface.td b/src/pass/shape_inference_interface.td similarity index 100% rename from src/compiler/pass/shape_inference_interface.td rename to src/pass/shape_inference_interface.td diff --git a/src/compiler/pass/shape_inference_pass.cpp b/src/pass/shape_inference_pass.cpp similarity index 98% rename from src/compiler/pass/shape_inference_pass.cpp rename to src/pass/shape_inference_pass.cpp index 0182d92..d80e042 100644 --- a/src/compiler/pass/shape_inference_pass.cpp +++ b/src/pass/shape_inference_pass.cpp @@ -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 { /*! diff --git a/src/runtime/CMakeLists.txt b/src/runtime/CMakeLists.txt index 040ae01..8be3cbb 100644 --- a/src/runtime/CMakeLists.txt +++ b/src/runtime/CMakeLists.txt @@ -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 diff --git a/src/compiler/tool/CMakeLists.txt b/src/tool/CMakeLists.txt similarity index 100% rename from src/compiler/tool/CMakeLists.txt rename to src/tool/CMakeLists.txt diff --git a/src/compiler/tool/onnf_opt/CMakeLists.txt b/src/tool/onnf_opt/CMakeLists.txt similarity index 100% rename from src/compiler/tool/onnf_opt/CMakeLists.txt rename to src/tool/onnf_opt/CMakeLists.txt diff --git a/src/compiler/tool/onnf_opt/onnf_opt.cpp b/src/tool/onnf_opt/onnf_opt.cpp similarity index 94% rename from src/compiler/tool/onnf_opt/onnf_opt.cpp rename to src/tool/onnf_opt/onnf_opt.cpp index 2bb4ed7..2311b66 100644 --- a/src/compiler/tool/onnf_opt/onnf_opt.cpp +++ b/src/tool/onnf_opt/onnf_opt.cpp @@ -14,9 +14,9 @@ #include #include -#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; diff --git a/src/compiler/transform/CMakeLists.txt b/src/transform/CMakeLists.txt similarity index 83% rename from src/compiler/transform/CMakeLists.txt rename to src/transform/CMakeLists.txt index b811513..6975bab 100644 --- a/src/compiler/transform/CMakeLists.txt +++ b/src/transform/CMakeLists.txt @@ -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} diff --git a/src/compiler/transform/lower_krnl.cpp b/src/transform/lower_krnl.cpp similarity index 98% rename from src/compiler/transform/lower_krnl.cpp rename to src/transform/lower_krnl.cpp index 6e53038..cde7854 100644 --- a/src/compiler/transform/lower_krnl.cpp +++ b/src/transform/lower_krnl.cpp @@ -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; diff --git a/src/compiler/transform/lower_to_llvm.cpp b/src/transform/lower_to_llvm.cpp similarity index 99% rename from src/compiler/transform/lower_to_llvm.cpp rename to src/transform/lower_to_llvm.cpp index fec2e03..877b5e1 100644 --- a/src/compiler/transform/lower_to_llvm.cpp +++ b/src/transform/lower_to_llvm.cpp @@ -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; From 0c41a204e4e58e451d952471b60dd57273e681c0 Mon Sep 17 00:00:00 2001 From: Tian Jin Date: Mon, 23 Dec 2019 00:22:11 -0500 Subject: [PATCH 2/5] fix include path --- src/dialect/krnl/krnl_helper.cpp | 2 +- src/dialect/krnl/krnl_ops.hpp | 4 ++-- src/pass/lower_frontend_to_krnl.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dialect/krnl/krnl_helper.cpp b/src/dialect/krnl/krnl_helper.cpp index 8f76c46..f3367bd 100644 --- a/src/dialect/krnl/krnl_helper.cpp +++ b/src/dialect/krnl/krnl_helper.cpp @@ -1,7 +1,7 @@ #include "mlir/Dialect/AffineOps/AffineOps.h" #include "mlir/IR/AffineExpr.h" -#include "krnl_ops.hpp" +#include "src/dialect/krnl/krnl_ops.hpp" #include "krnl_helper.hpp" diff --git a/src/dialect/krnl/krnl_ops.hpp b/src/dialect/krnl/krnl_ops.hpp index e859dde..5ba9cfa 100644 --- a/src/dialect/krnl/krnl_ops.hpp +++ b/src/dialect/krnl/krnl_ops.hpp @@ -15,8 +15,8 @@ #include "mlir/IR/OpDefinition.h" #include "mlir/IR/StandardTypes.h" -#include "krnl_helper.hpp" -#include "krnl_types.hpp" +#include "src/dialect/krnl/krnl_helper.hpp" +#include "src/dialect/krnl/krnl_types.hpp" namespace mlir { class KrnlOpsDialect : public Dialect { diff --git a/src/pass/lower_frontend_to_krnl.cpp b/src/pass/lower_frontend_to_krnl.cpp index 949cf9d..90954c7 100644 --- a/src/pass/lower_frontend_to_krnl.cpp +++ b/src/pass/lower_frontend_to_krnl.cpp @@ -20,7 +20,7 @@ #include "src/dialect/krnl/krnl_helper.hpp" #include "src/dialect/krnl/krnl_ops.hpp" #include "src/dialect/onnx/onnx_ops.hpp" -#include "passes.hpp" +#include "src/pass/passes.hpp" using namespace mlir; From 238c937f1b20ed8910b8c1f5201a56b21c942efe Mon Sep 17 00:00:00 2001 From: Tian Jin Date: Mon, 23 Dec 2019 01:14:35 -0500 Subject: [PATCH 3/5] rewrite cli description --- src/main.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 427de11..002bf08 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -87,10 +87,13 @@ int main(int argc, char *argv[]) { llvm::cl::opt 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); From 50ea6bed03fcf3b7fbbcf48748b4a6541800fb76 Mon Sep 17 00:00:00 2001 From: Tian Jin Date: Mon, 23 Dec 2019 02:09:11 -0500 Subject: [PATCH 4/5] fix build --- MLIR.cmake | 22 +++++++++++----------- src/CMakeLists.txt | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/MLIR.cmake b/MLIR.cmake index 7200493..f88745d 100644 --- a/MLIR.cmake +++ b/MLIR.cmake @@ -140,23 +140,23 @@ set(MLIRLibs Threads::Threads) set(MLIRWholeArchiveLibs - MLIRAffineToStandard - MLIRAffineOps - MLIRLLVMIR - MLIRStandardOps - MLIRStandardToLLVM - MLIRTransforms - MLIRLoopToStandard - MLIRVectorOps - MLIRLoopOps) + ${MLIRAffineToStandard} + ${MLIRAffineOps} + ${MLIRLLVMIR} + ${MLIRStandardOps} + ${MLIRStandardToLLVM} + ${MLIRTransforms} + ${MLIRLoopToStandard} + ${MLIRVectorOps} + ${MLIRLoopOps}) 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} ") endforeach(LIB) elseif(MSVC) foreach(LIB ${ARGN}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9cb0488..ef21d2a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -70,9 +70,9 @@ 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}) From 206fb5db67dcadb4828e3c46f426cdd8f3b446ee Mon Sep 17 00:00:00 2001 From: Tian Jin Date: Mon, 23 Dec 2019 11:40:15 -0500 Subject: [PATCH 5/5] fix whole-archive link --- MLIR.cmake | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/MLIR.cmake b/MLIR.cmake index f88745d..4cb4b08 100644 --- a/MLIR.cmake +++ b/MLIR.cmake @@ -140,15 +140,15 @@ set(MLIRLibs Threads::Threads) set(MLIRWholeArchiveLibs - ${MLIRAffineToStandard} - ${MLIRAffineOps} - ${MLIRLLVMIR} - ${MLIRStandardOps} - ${MLIRStandardToLLVM} - ${MLIRTransforms} - ${MLIRLoopToStandard} - ${MLIRVectorOps} - ${MLIRLoopOps}) + MLIRAffineToStandard + MLIRAffineOps + MLIRLLVMIR + MLIRStandardOps + MLIRStandardToLLVM + MLIRTransforms + MLIRLoopToStandard + MLIRVectorOps + MLIRLoopOps) function(whole_archive_link target lib_dir) get_property(link_flags TARGET ${target} PROPERTY LINK_FLAGS) @@ -156,7 +156,7 @@ function(whole_archive_link target lib_dir) set(link_flags "${link_flags} -L${lib_dir} ") foreach(LIB ${ARGN}) string(CONCAT link_flags ${link_flags} - "-Wl,-force_load,${LIB} ") + "-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)