2020-03-19 16:48:09 +08:00
|
|
|
add_subdirectory(Interface)
|
2020-03-20 22:40:51 +08:00
|
|
|
add_subdirectory(Dialect)
|
|
|
|
add_subdirectory(Conversion)
|
2020-03-19 16:48:09 +08:00
|
|
|
add_subdirectory(Transform)
|
|
|
|
add_subdirectory(Tool)
|
|
|
|
add_subdirectory(Builder)
|
|
|
|
add_subdirectory(Runtime)
|
2019-12-23 13:13:52 +08:00
|
|
|
|
2020-03-25 01:48:54 +08:00
|
|
|
add_executable(onnx-mlir
|
|
|
|
MainUtils.hpp
|
|
|
|
MainUtils.cpp
|
|
|
|
main.cpp)
|
2020-04-14 17:40:05 +08:00
|
|
|
|
2020-05-19 10:15:48 +08:00
|
|
|
# Locate llc, which is needed for translating LLVM bitcode
|
|
|
|
# to object file.
|
|
|
|
if(NOT EXISTS "${LLVM_PROJ_BUILD}/bin/llc")
|
|
|
|
message(ERROR "Cannot find llc.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Get the compiler command name, the C++ compiler is needed to to translate
|
|
|
|
# object files to shared libraries.
|
|
|
|
get_filename_component(CXX_COMPILER_FILENAME ${CMAKE_CXX_COMPILER} NAME)
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ExternalUtil.hpp.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/ExternalUtil.hpp)
|
|
|
|
|
2020-04-14 17:40:05 +08:00
|
|
|
set(ONNX_MLIR_LD_PRELOAD_onnx-mlir "" CACHE STRING "" FORCE)
|
|
|
|
whole_archive_link_mlir(onnx-mlir ${MLIRWholeArchiveLibs})
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
message(STATUS "To run dynamically linked onnx-mlir, you must specify:")
|
|
|
|
message(STATUS "LD_PRELOAD=${ONNX_MLIR_LD_PRELOAD_onnx-mlir}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Libraries specified on the target_link_libraries for the add_subdirectory
|
|
|
|
# targets get added to the end of the list here. This creates two problems:
|
|
|
|
# 1. It produces duplicated libraries being specified for the link command.
|
|
|
|
# 2. The libraries added at the end may depend on other libraries thus
|
|
|
|
# cause linkage errors due to undefined symbols.
|
|
|
|
# So it's better not to use target_link_libraries for the add_subdirectory
|
|
|
|
# targets, or only use it for libraries that have no further dependencies
|
|
|
|
# (except system libraries such as libc).
|
2020-03-19 15:03:37 +08:00
|
|
|
target_link_libraries(onnx-mlir
|
2020-03-20 22:40:51 +08:00
|
|
|
OMBuilder
|
|
|
|
OMKrnlOps
|
|
|
|
OMONNXOps
|
2020-04-14 17:40:05 +08:00
|
|
|
OMShapeInference
|
|
|
|
OMShapeInferenceOpInterface
|
|
|
|
OMAttributePromotion
|
|
|
|
OMPromotableConstOperandsOpInterface
|
2020-04-25 04:15:36 +08:00
|
|
|
OMElideConstants
|
|
|
|
OMElideKrnlGlobalConstants
|
2020-03-20 22:40:51 +08:00
|
|
|
OMKrnlToAffine
|
|
|
|
OMKrnlToLLVM
|
|
|
|
OMONNXToKrnl
|
|
|
|
OMONNXRewrite
|
2020-04-14 17:40:05 +08:00
|
|
|
${MLIRLibs}
|
2020-03-20 22:40:51 +08:00
|
|
|
${CMAKE_DL_LIBS})
|
2019-12-21 14:58:23 +08:00
|
|
|
|
2020-05-13 06:43:44 +08:00
|
|
|
if (INCLUDE_ONNX_ML)
|
|
|
|
target_link_libraries(onnx-mlir OMMLONNXOps)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2020-03-21 00:04:22 +08:00
|
|
|
target_include_directories(onnx-mlir PRIVATE ${ONNX_MLIR_SRC_ROOT})
|
2020-03-17 21:16:33 +08:00
|
|
|
target_include_directories(onnx-mlir PRIVATE ${CMAKE_BINARY_DIR})
|
2020-03-21 00:04:22 +08:00
|
|
|
target_include_directories(onnx-mlir PRIVATE ${ONNX_MLIR_BIN_ROOT})
|
2019-11-12 10:31:56 +08:00
|
|
|
|
2020-03-17 21:16:33 +08:00
|
|
|
install(TARGETS onnx-mlir DESTINATION bin)
|
2020-05-21 11:03:06 +08:00
|
|
|
install(FILES Runtime/DynMemRef.h DESTINATION include)
|
|
|
|
install(TARGETS cruntime DESTINATION lib)
|