2018-11-20 00:48:22 +00:00
|
|
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
|
# Licensed under the MIT License.
|
|
|
|
|
|
2019-04-29 19:58:20 +00:00
|
|
|
file(GLOB onnxruntime_session_srcs CONFIGURE_DEPENDS
|
2018-11-20 00:48:22 +00:00
|
|
|
"${ONNXRUNTIME_INCLUDE_DIR}/core/session/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/session/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/session/*.cc"
|
|
|
|
|
)
|
|
|
|
|
|
2023-01-03 21:28:16 +00:00
|
|
|
if (onnxruntime_ENABLE_TRAINING_APIS)
|
|
|
|
|
file(GLOB_RECURSE training_api_srcs CONFIGURE_DEPENDS
|
2022-06-15 18:13:35 +00:00
|
|
|
"${ORTTRAINING_SOURCE_DIR}/training_api/*.cc"
|
2023-01-19 18:26:53 +00:00
|
|
|
"${ORTTRAINING_SOURCE_DIR}/training_api/*.h"
|
2023-01-11 04:58:04 +00:00
|
|
|
"${ORTTRAINING_SOURCE_DIR}/core/framework/checkpoint_common.cc"
|
|
|
|
|
"${ORTTRAINING_SOURCE_DIR}/core/framework/checkpoint_common.h"
|
2022-06-15 18:13:35 +00:00
|
|
|
)
|
|
|
|
|
|
2023-01-03 21:28:16 +00:00
|
|
|
list(APPEND onnxruntime_session_srcs ${training_api_srcs})
|
2022-06-15 18:13:35 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
2021-07-19 22:19:32 +00:00
|
|
|
if (onnxruntime_MINIMAL_BUILD)
|
|
|
|
|
set(onnxruntime_session_src_exclude
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/session/provider_bridge_ort.cc"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
list(REMOVE_ITEM onnxruntime_session_srcs ${onnxruntime_session_src_exclude})
|
|
|
|
|
endif()
|
|
|
|
|
|
2018-11-20 00:48:22 +00:00
|
|
|
source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_session_srcs})
|
|
|
|
|
|
2021-04-29 18:54:57 +00:00
|
|
|
onnxruntime_add_static_library(onnxruntime_session ${onnxruntime_session_srcs})
|
2022-12-20 19:44:02 +00:00
|
|
|
onnxruntime_add_include_to_target(onnxruntime_session onnxruntime_common onnxruntime_framework onnx onnx_proto ${PROTOBUF_LIB} flatbuffers::flatbuffers Boost::mp11 safeint_interface nlohmann_json::nlohmann_json)
|
2019-11-12 05:34:10 +00:00
|
|
|
if(onnxruntime_ENABLE_INSTRUMENT)
|
|
|
|
|
target_compile_definitions(onnxruntime_session PUBLIC ONNXRUNTIME_ENABLE_INSTRUMENT)
|
|
|
|
|
endif()
|
2021-08-19 01:16:32 +00:00
|
|
|
|
2021-07-31 00:16:37 +00:00
|
|
|
if(NOT MSVC)
|
|
|
|
|
set_source_files_properties(${ONNXRUNTIME_ROOT}/core/session/environment.cc PROPERTIES COMPILE_FLAGS "-Wno-parentheses")
|
|
|
|
|
endif()
|
2021-04-02 00:42:58 +00:00
|
|
|
target_include_directories(onnxruntime_session PRIVATE ${ONNXRUNTIME_ROOT} ${eigen_INCLUDE_DIRS})
|
2021-08-28 04:45:52 +00:00
|
|
|
if (onnxruntime_USE_EXTENSIONS)
|
|
|
|
|
target_link_libraries(onnxruntime_session PRIVATE onnxruntime_extensions)
|
2021-07-01 16:34:03 +00:00
|
|
|
endif()
|
2018-11-20 00:48:22 +00:00
|
|
|
add_dependencies(onnxruntime_session ${onnxruntime_EXTERNAL_DEPENDENCIES})
|
|
|
|
|
set_target_properties(onnxruntime_session PROPERTIES FOLDER "ONNXRuntime")
|
2019-07-11 21:49:20 +00:00
|
|
|
if (onnxruntime_USE_CUDA)
|
|
|
|
|
target_include_directories(onnxruntime_session PRIVATE ${onnxruntime_CUDNN_HOME}/include ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
|
|
|
|
|
endif()
|
2021-10-14 22:15:51 +00:00
|
|
|
if (onnxruntime_USE_ROCM)
|
2022-11-03 11:32:30 +00:00
|
|
|
target_compile_options(onnxruntime_session PRIVATE -Wno-sign-compare -D__HIP_PLATFORM_AMD__=1 -D__HIP_PLATFORM_HCC__=1)
|
2021-10-14 22:15:51 +00:00
|
|
|
target_include_directories(onnxruntime_session PRIVATE ${onnxruntime_ROCM_HOME}/hipfft/include ${onnxruntime_ROCM_HOME}/include ${onnxruntime_ROCM_HOME}/hipcub/include ${onnxruntime_ROCM_HOME}/hiprand/include ${onnxruntime_ROCM_HOME}/rocrand/include)
|
|
|
|
|
# ROCM provider sources are generated, need to add include directory for generated headers
|
|
|
|
|
target_include_directories(onnxruntime_session PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/onnxruntime ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/orttraining)
|
|
|
|
|
endif()
|
2022-12-14 16:32:46 +00:00
|
|
|
if (onnxruntime_ENABLE_TRAINING_OPS)
|
2020-03-11 21:25:37 +00:00
|
|
|
target_include_directories(onnxruntime_session PRIVATE ${ORTTRAINING_ROOT})
|
|
|
|
|
endif()
|
2021-08-21 07:40:12 +00:00
|
|
|
|
2021-08-17 17:55:13 +00:00
|
|
|
if (onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
|
2022-06-15 18:13:35 +00:00
|
|
|
onnxruntime_add_include_to_target(onnxruntime_session Python::Module)
|
2021-08-17 17:55:13 +00:00
|
|
|
endif()
|
2022-04-04 05:37:18 +00:00
|
|
|
|
|
|
|
|
if (NOT onnxruntime_BUILD_SHARED_LIB)
|
2023-06-20 05:20:31 +00:00
|
|
|
install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/session DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core)
|
2022-04-04 05:37:18 +00:00
|
|
|
install(TARGETS onnxruntime_session
|
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
|
FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
|
|
|
endif()
|
2022-12-07 01:10:37 +00:00
|
|
|
|
|
|
|
|
if (onnxruntime_USE_NCCL AND onnxruntime_USE_ROCM)
|
|
|
|
|
add_dependencies(onnxruntime_session generate_hipified_files)
|
|
|
|
|
endif()
|