onnx-mlir/src/CMakeLists.txt

118 lines
4.5 KiB
CMake
Raw Normal View History

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
dialect/onnx/onnxop.inc
pass/onnx_combine.cpp
pass/onnx_rewrite.cpp
pass/onnx_decompose.cpp
pass/passes.hpp)
2019-12-23 13:13:52 +08:00
# 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/onnx_decompose.td)
onnf_tablegen(onnx_decompose.inc -gen-rewriters)
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)
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 pass/onnx_rewrite.td)
onnf_tablegen(onnx_rewrite.inc -gen-rewriters)
add_public_tablegen_target(gen_onnx_rewrite)
add_dependencies(compiler gen_onnx_rewrite)
2019-12-23 13:13:52 +08:00
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")
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)
add_dependencies(compiler gen_onnx)
add_onnf_dialect_doc(onnx dialect/onnx/onnx.td)
2019-12-23 13:13:52 +08:00
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_onnx_decompose pass/onnx_decompose.cpp)
target_include_directories(onnf_onnx_decompose
PRIVATE ${ONNF_SRC_ROOT} ${ONNF_BIN_ROOT}
${ONNF_SRC_ROOT})
target_link_libraries(onnf_onnx_decompose ${MLIRLibs})
add_dependencies(onnf_onnx_decompose gen_krnl_ops)
2019-12-23 13:13:52 +08:00
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
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
conversion/onnx_to_krnl/nn/pooling.cpp
conversion/onnx_to_krnl/tensor/identity.cpp
conversion/onnx_to_krnl/tensor/reshape.cpp
conversion/onnx_to_krnl/tensor/padconstantvaluepad.cpp
conversion/onnx_to_krnl/tensor/transpose.cpp
conversion/onnx_to_krnl/tensor/unsqueeze.cpp
conversion/onnx_to_krnl/tensor/constant.cpp
conversion/onnx_to_krnl/convert_onnx_to_krnl.cpp)
2019-12-23 13:13:52 +08:00
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)
2019-12-20 03:24:37 +08:00
add_executable(onnf main.cpp)
target_link_libraries(onnf builder ${MLIRLibs} onnf_transform onnf_onnx_decompose onnf_shape_inference onnf_lower_frontend)
2019-12-23 15:09:11 +08:00
whole_archive_link_mlir(onnf ${MLIRWholeArchiveLibs})
2020-01-22 00:08:16 +08:00
find_package(ZLIB REQUIRED)
target_link_libraries(onnf ${ZLIB_LIBRARIES})
target_include_directories(onnf PRIVATE ${CMAKE_SOURCE_DIR})
target_include_directories(onnf PRIVATE ${CMAKE_BINARY_DIR})
install(TARGETS onnf DESTINATION bin)