2019-12-23 13:13:52 +08:00
|
|
|
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_interface.hpp
|
|
|
|
pass/onnx_combine.cpp
|
2020-01-31 19:00:39 +08:00
|
|
|
pass/onnx_rewrite.cpp
|
2020-03-04 23:53:59 +08:00
|
|
|
pass/onnx_decompose.cpp
|
2020-03-17 17:41:59 +08:00
|
|
|
pass/passes.hpp)
|
2019-12-23 13:13:52 +08:00
|
|
|
|
|
|
|
# Include root src directory.
|
2020-03-17 21:16:33 +08:00
|
|
|
target_include_directories(compiler PRIVATE ${ONNX_MLIR_SRC_ROOT})
|
2019-12-23 13:13:52 +08:00
|
|
|
|
|
|
|
# Include tablegen generated header files.
|
2020-03-17 21:16:33 +08:00
|
|
|
target_include_directories(compiler PRIVATE ${ONNX_MLIR_BIN_ROOT})
|
2019-12-23 13:13:52 +08:00
|
|
|
|
|
|
|
target_link_libraries(compiler
|
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
|
|
|
${CMAKE_DL_LIBS}
|
|
|
|
${MLIRLibs}
|
|
|
|
curses)
|
|
|
|
|
2020-03-04 23:53:59 +08:00
|
|
|
set(LLVM_TARGET_DEFINITIONS pass/onnx_decompose.td)
|
2020-03-17 21:16:33 +08:00
|
|
|
onnx_mlir_tablegen(onnx_decompose.inc -gen-rewriters)
|
2020-03-04 23:53:59 +08:00
|
|
|
add_public_tablegen_target(gen_onnx_decompose)
|
|
|
|
add_dependencies(compiler gen_onnx_decompose)
|
|
|
|
|
2019-12-23 13:13:52 +08:00
|
|
|
set(LLVM_TARGET_DEFINITIONS pass/shape_inference_interface.td)
|
2020-03-17 21:16:33 +08:00
|
|
|
onnx_mlir_tablegen(shape_inference.hpp.inc -gen-op-interface-decls)
|
|
|
|
onnx_mlir_tablegen(shape_inference.cpp.inc -gen-op-interface-defs)
|
2019-12-23 13:13:52 +08:00
|
|
|
add_public_tablegen_target(gen_shape_inference)
|
|
|
|
add_dependencies(compiler gen_shape_inference)
|
|
|
|
|
|
|
|
set(LLVM_TARGET_DEFINITIONS pass/onnx_combine.td)
|
2020-03-17 21:16:33 +08:00
|
|
|
onnx_mlir_tablegen(onnx_combine.inc -gen-rewriters)
|
2019-12-23 13:13:52 +08:00
|
|
|
add_public_tablegen_target(gen_onnx_combine)
|
|
|
|
add_dependencies(compiler gen_onnx_combine)
|
|
|
|
|
2020-02-21 22:28:24 +08:00
|
|
|
set(LLVM_TARGET_DEFINITIONS pass/onnx_rewrite.td)
|
2020-03-17 21:16:33 +08:00
|
|
|
onnx_mlir_tablegen(onnx_rewrite.inc -gen-rewriters)
|
2020-02-21 22:28:24 +08:00
|
|
|
add_public_tablegen_target(gen_onnx_rewrite)
|
|
|
|
add_dependencies(compiler gen_onnx_rewrite)
|
|
|
|
|
2020-03-19 15:03:37 +08:00
|
|
|
add_subdirectory(interface)
|
|
|
|
|
2019-12-23 13:13:52 +08:00
|
|
|
set(LLVM_TARGET_DEFINITIONS dialect/onnx/onnx.td)
|
2020-03-17 21:16:33 +08:00
|
|
|
onnx_mlir_tablegen(onnx.hpp.inc -gen-op-decls "-I${CMAKE_SOURCE_DIR}/compiler/pass")
|
|
|
|
onnx_mlir_tablegen(onnx.cpp.inc -gen-op-defs "-I${CMAKE_SOURCE_DIR}/compiler/pass")
|
2020-02-11 03:18:54 +08:00
|
|
|
set(GEN_DOC_FILE ${CMAKE_BINARY_DIR}/docs/Dialects/onnx.md)
|
2019-12-23 13:13:52 +08:00
|
|
|
add_public_tablegen_target(gen_onnx)
|
2020-03-19 15:03:37 +08:00
|
|
|
|
|
|
|
add_dependencies(gen_onnx gen_shape_inference)
|
2019-12-23 13:13:52 +08:00
|
|
|
add_dependencies(compiler gen_onnx)
|
2020-03-19 15:03:37 +08:00
|
|
|
|
|
|
|
# TODO: onnx_mlir_gen_promotable_const_operands_op_interface is really a
|
|
|
|
# dependency of the onnx dialect library, which is currently part of `compiler`.
|
|
|
|
add_dependencies(compiler onnx_mlir_gen_promotable_const_operands_op_interface)
|
|
|
|
|
|
|
|
|
2020-03-17 21:16:33 +08:00
|
|
|
add_onnx_mlir_dialect_doc(onnx dialect/onnx/onnx.td)
|
2019-12-23 13:13:52 +08:00
|
|
|
|
|
|
|
set(LLVM_TARGET_DEFINITIONS dialect/krnl/krnl_ops.td)
|
2020-03-17 21:16:33 +08:00
|
|
|
onnx_mlir_tablegen(krnl.hpp.inc -gen-op-decls)
|
|
|
|
onnx_mlir_tablegen(krnl.cpp.inc -gen-op-defs)
|
2019-12-23 13:13:52 +08:00
|
|
|
add_public_tablegen_target(gen_krnl_ops)
|
|
|
|
add_dependencies(compiler gen_krnl_ops)
|
|
|
|
|
2020-03-17 21:16:33 +08:00
|
|
|
add_library(onnx_mlir_onnx_decompose pass/onnx_decompose.cpp)
|
|
|
|
target_include_directories(onnx_mlir_onnx_decompose
|
|
|
|
PRIVATE ${ONNX_MLIR_SRC_ROOT} ${ONNX_MLIR_BIN_ROOT}
|
|
|
|
${ONNX_MLIR_SRC_ROOT})
|
|
|
|
target_link_libraries(onnx_mlir_onnx_decompose ${MLIRLibs})
|
2020-03-19 15:03:37 +08:00
|
|
|
add_dependencies(onnx_mlir_onnx_decompose gen_onnx)
|
2020-03-17 21:16:33 +08:00
|
|
|
|
|
|
|
add_library(onnx_mlir_shape_inference pass/shape_inference_pass.cpp)
|
|
|
|
target_include_directories(onnx_mlir_shape_inference
|
|
|
|
PRIVATE ${ONNX_MLIR_SRC_ROOT} ${ONNX_MLIR_BIN_ROOT}
|
|
|
|
${ONNX_MLIR_SRC_ROOT})
|
|
|
|
target_link_libraries(onnx_mlir_shape_inference ${MLIRLibs})
|
2020-03-19 15:03:37 +08:00
|
|
|
add_dependencies(onnx_mlir_shape_inference gen_onnx)
|
2020-03-17 21:16:33 +08:00
|
|
|
|
|
|
|
add_library(onnx_mlir_lower_frontend
|
2020-02-25 23:38:08 +08:00
|
|
|
conversion/onnx_to_krnl/onnx_to_krnl_common.cpp
|
|
|
|
conversion/onnx_to_krnl/onnx_to_krnl_common.hpp
|
|
|
|
conversion/onnx_to_krnl/math/elementwise.cpp
|
|
|
|
conversion/onnx_to_krnl/math/gemm.cpp
|
|
|
|
conversion/onnx_to_krnl/math/matmul.cpp
|
|
|
|
conversion/onnx_to_krnl/math/reduction.cpp
|
|
|
|
conversion/onnx_to_krnl/math/softmax.cpp
|
|
|
|
conversion/onnx_to_krnl/nn/conv.cpp
|
|
|
|
conversion/onnx_to_krnl/nn/normalization.cpp
|
2020-03-05 03:27:21 +08:00
|
|
|
conversion/onnx_to_krnl/nn/pooling.cpp
|
2020-02-25 23:38:08 +08:00
|
|
|
conversion/onnx_to_krnl/tensor/identity.cpp
|
|
|
|
conversion/onnx_to_krnl/tensor/reshape.cpp
|
2020-03-12 04:54:07 +08:00
|
|
|
conversion/onnx_to_krnl/tensor/padconstantvaluepad.cpp
|
2020-02-25 23:38:08 +08:00
|
|
|
conversion/onnx_to_krnl/tensor/transpose.cpp
|
|
|
|
conversion/onnx_to_krnl/tensor/unsqueeze.cpp
|
2020-03-12 22:58:42 +08:00
|
|
|
conversion/onnx_to_krnl/tensor/constant.cpp
|
2020-02-25 23:38:08 +08:00
|
|
|
conversion/onnx_to_krnl/convert_onnx_to_krnl.cpp)
|
2020-03-17 21:16:33 +08:00
|
|
|
target_include_directories(onnx_mlir_lower_frontend
|
|
|
|
PRIVATE ${ONNX_MLIR_SRC_ROOT} ${ONNX_MLIR_BIN_ROOT}
|
|
|
|
${ONNX_MLIR_SRC_ROOT})
|
|
|
|
target_link_libraries(onnx_mlir_lower_frontend ${MLIRLibs})
|
|
|
|
add_dependencies(onnx_mlir_lower_frontend gen_krnl_ops)
|
2019-12-23 13:13:52 +08:00
|
|
|
|
|
|
|
add_subdirectory(transform)
|
|
|
|
add_subdirectory(tool)
|
|
|
|
add_subdirectory(builder)
|
|
|
|
add_subdirectory(runtime)
|
|
|
|
|
2020-03-17 21:16:33 +08:00
|
|
|
add_executable(onnx-mlir main.cpp)
|
2019-11-27 02:55:44 +08:00
|
|
|
|
2020-03-19 15:03:37 +08:00
|
|
|
target_link_libraries(onnx-mlir
|
|
|
|
builder
|
|
|
|
${MLIRLibs}
|
|
|
|
onnx_mlir_transform
|
|
|
|
onnx_mlir_onnx_decompose
|
|
|
|
onnx_mlir_shape_inference
|
|
|
|
onnx_mlir_lower_frontend
|
|
|
|
onnx_mlir_attribute_promotion)
|
|
|
|
whole_archive_link_mlir(onnx-mlir
|
|
|
|
${MLIRWholeArchiveLibs})
|
|
|
|
|
2020-01-22 00:08:16 +08:00
|
|
|
find_package(ZLIB REQUIRED)
|
2020-03-17 21:16:33 +08:00
|
|
|
target_link_libraries(onnx-mlir ${ZLIB_LIBRARIES})
|
2019-12-21 14:58:23 +08:00
|
|
|
|
2020-03-17 21:16:33 +08:00
|
|
|
target_include_directories(onnx-mlir PRIVATE ${CMAKE_SOURCE_DIR})
|
|
|
|
target_include_directories(onnx-mlir PRIVATE ${CMAKE_BINARY_DIR})
|
2019-11-12 10:31:56 +08:00
|
|
|
|
2020-03-17 21:16:33 +08:00
|
|
|
install(TARGETS onnx-mlir DESTINATION bin)
|