2018-11-20 00:48:22 +00:00
|
|
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
|
# Licensed under the MIT License.
|
|
|
|
|
|
|
|
|
|
set(onnxruntime_common_src_patterns
|
|
|
|
|
"${ONNXRUNTIME_INCLUDE_DIR}/core/common/*.h"
|
|
|
|
|
"${ONNXRUNTIME_INCLUDE_DIR}/core/common/logging/*.h"
|
2019-04-18 17:20:46 +00:00
|
|
|
"${ONNXRUNTIME_INCLUDE_DIR}/core/platform/*.h"
|
2018-11-20 00:48:22 +00:00
|
|
|
"${ONNXRUNTIME_ROOT}/core/common/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/common/*.cc"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/common/logging/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/common/logging/*.cc"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/common/logging/sinks/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/common/logging/sinks/*.cc"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/env.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/env.cc"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/env_time.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/env_time.cc"
|
2020-03-18 18:53:46 +00:00
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/path_lib.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/path_lib.cc"
|
2019-10-24 17:28:13 +00:00
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/scoped_resource.h"
|
2019-10-20 01:25:57 +00:00
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/telemetry.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/telemetry.cc"
|
2021-05-27 17:03:02 +00:00
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/logging/make_platform_default_log_sink.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/logging/make_platform_default_log_sink.cc"
|
2021-07-15 03:56:58 +00:00
|
|
|
"$(ONNXRUNTIME_ROOT}/core/quantization/*.h"
|
|
|
|
|
"$(ONNXRUNTIME_ROOT}/core/quantization/*.cc"
|
2018-11-20 00:48:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
|
list(APPEND onnxruntime_common_src_patterns
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/windows/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/windows/*.cc"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/windows/logging/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/windows/logging/*.cc"
|
|
|
|
|
)
|
2021-10-26 19:16:49 +00:00
|
|
|
|
2018-11-20 00:48:22 +00:00
|
|
|
else()
|
|
|
|
|
list(APPEND onnxruntime_common_src_patterns
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/posix/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/posix/*.cc"
|
|
|
|
|
)
|
2019-06-06 06:35:06 +00:00
|
|
|
|
|
|
|
|
if (onnxruntime_USE_SYSLOG)
|
|
|
|
|
list(APPEND onnxruntime_common_src_patterns
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/posix/logging/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/posix/logging/*.cc"
|
|
|
|
|
)
|
|
|
|
|
endif()
|
The initial PR for NNAPI EP (#4287)
* Move nnapi dnnlib to subfolder
* dnnlib compile settings
* add nnapi buildin build.py
* add onnxruntime_USE_NNAPI_BUILTIN
* compile using onnxruntime_USE_NNAPI_BUILTIN
* remove dnnlib from built in code
* Group onnxruntime_USE_NNAPI_BUILTIN sources
* add file stubs
* java 32bit compile error
* built in nnapi support 5-26
* init working version
* initializer support
* fix crash on free execution
* add dynamic input support
* bug fixes for dynamic input shape, add mul support, working on conv and batchnorm
* Add batchnormalization, add overflow check for int64 attributes
* add global average/max pool and reshape
* minor changes
* minor changes
* add skip relu and options to use different type of memory
* small bug fix for in operator relu
* bug fix for nnapi
* add transpose support, minor bug fix
* Add transpose support
* minor bug fixes, depthwise conv weight fix
* fixed the bug where the onnx model input has mismatch order than the nnapi model input
* add helper to add scalar operand
* add separated opbuilder to handle single operator
* add cast operator
* fixed reshape, moved some logs to verbose
* Add softmax and identity support, change shaper calling signature, and add support for int32 output
* changed the way to execute the NNAPI
* move NNMemory and InputOutputInfo into Model class
* add limited support for input dynamic shape
* add gemm support, fixed crash when allocating big array on stack
* add abs/exp/floor/log/sigmoid/neg/sin/sqrt/tanh support
* better dynamic input shape support;
* add more check for IsOpSupportedImpl, refactored some code
* some code style fix, switch to safeint
* Move opbuilders to a map with single instance, minor bug fixes
* add GetUniqueName for new temp tensors
* change from throw std to ort_throw
* build settings change and 3rd party notice update
* add readme for nnapi_lib, move to ort log, add comments to public functions, clean the code
* add android log sink and more logging changes, add new string for NnApiErrorDescription
* add nnapi execution options/fp16 relax
* fix a dnnlibrary build break
* addressed review comments
* address review comments, changed adding output for subgraph in NnapiExecutionProvider::GetCapability, minor issue fixes
* formatting in build.py
* more formatting fix in build.py, return fail status instead of throw in compute_func
* moved android_log_sink to platform folder, minor coding style changes
* addressed review comments
2020-06-26 07:02:39 +00:00
|
|
|
|
|
|
|
|
if (CMAKE_SYSTEM_NAME STREQUAL "Android")
|
|
|
|
|
list(APPEND onnxruntime_common_src_patterns
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/android/logging/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/android/logging/*.cc"
|
|
|
|
|
)
|
|
|
|
|
endif()
|
2021-05-27 17:03:02 +00:00
|
|
|
|
|
|
|
|
if (APPLE)
|
|
|
|
|
list(APPEND onnxruntime_common_src_patterns
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/apple/logging/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/apple/logging/*.mm"
|
|
|
|
|
)
|
|
|
|
|
endif()
|
2018-11-20 00:48:22 +00:00
|
|
|
endif()
|
|
|
|
|
|
2021-03-29 22:35:30 +00:00
|
|
|
if(onnxruntime_target_platform STREQUAL "ARM64EC")
|
|
|
|
|
if (MSVC)
|
|
|
|
|
link_directories("$ENV{VCINSTALLDIR}/Tools/MSVC/$ENV{VCToolsVersion}/lib/ARM64EC")
|
|
|
|
|
link_directories("$ENV{VCINSTALLDIR}/Tools/MSVC/$ENV{VCToolsVersion}/ATLMFC/lib/ARM64EC")
|
|
|
|
|
link_libraries(softintrin.lib)
|
|
|
|
|
add_compile_options("/bigobj")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2019-04-29 19:58:20 +00:00
|
|
|
file(GLOB onnxruntime_common_src CONFIGURE_DEPENDS
|
|
|
|
|
${onnxruntime_common_src_patterns}
|
|
|
|
|
)
|
2018-11-20 00:48:22 +00:00
|
|
|
|
2021-12-08 01:56:58 +00:00
|
|
|
# Remove new/delete intercept. To deal with memory leaks
|
|
|
|
|
# Use either non-mimalloc build OR use mimalloc built-in features.
|
|
|
|
|
if(WIN32 AND onnxruntime_USE_MIMALLOC)
|
|
|
|
|
list(REMOVE_ITEM onnxruntime_common_src
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/windows/debug_alloc.cc"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/platform/windows/debug_alloc.h")
|
|
|
|
|
endif()
|
|
|
|
|
|
2018-11-20 00:48:22 +00:00
|
|
|
source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_common_src})
|
|
|
|
|
|
2021-04-29 18:54:57 +00:00
|
|
|
onnxruntime_add_static_library(onnxruntime_common ${onnxruntime_common_src})
|
2018-11-20 00:48:22 +00:00
|
|
|
|
2019-12-04 07:34:53 +00:00
|
|
|
if (onnxruntime_USE_TELEMETRY)
|
|
|
|
|
set_target_properties(onnxruntime_common PROPERTIES COMPILE_FLAGS "/FI${ONNXRUNTIME_INCLUDE_DIR}/core/platform/windows/TraceLoggingConfigPrivate.h")
|
|
|
|
|
endif()
|
|
|
|
|
|
2021-12-08 01:56:58 +00:00
|
|
|
if (onnxruntime_USE_MIMALLOC)
|
|
|
|
|
if(NOT WIN32)
|
2021-12-09 18:00:44 +00:00
|
|
|
message(FATAL_ERROR "Currently do not support MIMALLOC in GPU builds")
|
2021-12-08 01:56:58 +00:00
|
|
|
endif()
|
2020-02-28 21:19:17 +00:00
|
|
|
if(onnxruntime_USE_CUDA OR onnxruntime_USE_OPENVINO)
|
2021-12-08 01:56:58 +00:00
|
|
|
message(WARNING "Currently do not support MIMALLOC in GPU builds")
|
2019-10-24 05:34:00 +00:00
|
|
|
else()
|
|
|
|
|
include(external/mimalloc.cmake)
|
|
|
|
|
list(APPEND onnxruntime_EXTERNAL_LIBRARIES mimalloc-static)
|
|
|
|
|
list(APPEND onnxruntime_EXTERNAL_DEPENDENCIES mimalloc-static)
|
2021-12-08 01:56:58 +00:00
|
|
|
set(onnxruntime_mimalloc_shim_src "${ONNXRUNTIME_ROOT}/core/platform/windows/mimalloc/mimalloc_overloads.cc")
|
|
|
|
|
add_library(onnxruntime_mimalloc_shim ${onnxruntime_mimalloc_shim_src})
|
|
|
|
|
target_link_libraries(onnxruntime_mimalloc_shim mimalloc-static)
|
|
|
|
|
target_link_libraries(onnxruntime_common onnxruntime_mimalloc_shim)
|
2019-10-24 05:34:00 +00:00
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2022-04-27 15:57:52 +00:00
|
|
|
if(NOT onnxruntime_DISABLE_ABSEIL)
|
|
|
|
|
include(external/abseil-cpp.cmake)
|
|
|
|
|
endif()
|
2022-01-24 18:40:46 +00:00
|
|
|
|
2020-04-16 17:34:32 +00:00
|
|
|
onnxruntime_add_include_to_target(onnxruntime_common date_interface wil)
|
|
|
|
|
target_include_directories(onnxruntime_common
|
|
|
|
|
PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT} ${eigen_INCLUDE_DIRS}
|
2020-11-03 23:27:47 +00:00
|
|
|
# propagate include directories of dependencies that are part of public interface
|
|
|
|
|
PUBLIC
|
|
|
|
|
${OPTIONAL_LITE_INCLUDE_DIR})
|
2020-04-16 17:34:32 +00:00
|
|
|
|
2022-03-04 17:28:04 +00:00
|
|
|
target_link_libraries(onnxruntime_common safeint_interface Boost::mp11)
|
2021-01-28 15:27:19 +00:00
|
|
|
|
2021-04-16 04:46:11 +00:00
|
|
|
if(NOT WIN32)
|
2020-03-30 19:18:40 +00:00
|
|
|
target_include_directories(onnxruntime_common PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/external/nsync/public")
|
|
|
|
|
endif()
|
2019-08-29 01:00:10 +00:00
|
|
|
|
|
|
|
|
add_dependencies(onnxruntime_common ${onnxruntime_EXTERNAL_DEPENDENCIES})
|
2018-11-20 00:48:22 +00:00
|
|
|
|
2018-11-23 04:56:43 +00:00
|
|
|
install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/common DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core)
|
2018-11-20 00:48:22 +00:00
|
|
|
set_target_properties(onnxruntime_common PROPERTIES LINKER_LANGUAGE CXX)
|
|
|
|
|
set_target_properties(onnxruntime_common PROPERTIES FOLDER "ONNXRuntime")
|
|
|
|
|
|
2019-06-27 22:45:06 +00:00
|
|
|
# check if we need to link against librt on Linux
|
|
|
|
|
include(CheckLibraryExists)
|
|
|
|
|
include(CheckFunctionExists)
|
|
|
|
|
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
|
|
|
|
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
|
|
|
|
|
|
|
|
|
|
if (NOT HAVE_CLOCK_GETTIME)
|
|
|
|
|
set(CMAKE_EXTRA_INCLUDE_FILES time.h)
|
|
|
|
|
check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
|
|
|
|
|
set(CMAKE_EXTRA_INCLUDE_FILES)
|
|
|
|
|
else()
|
|
|
|
|
target_link_libraries(onnxruntime_common rt)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
2020-09-24 21:58:07 +00:00
|
|
|
|
|
|
|
|
if (onnxruntime_WINML_NAMESPACE_OVERRIDE STREQUAL "Windows")
|
|
|
|
|
target_compile_definitions(onnxruntime_common PRIVATE "BUILD_INBOX=1")
|
2020-10-09 12:34:32 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# check if we need to link against libatomic due to std::atomic usage by the threadpool code
|
|
|
|
|
# e.g. Raspberry Pi requires this
|
|
|
|
|
if (onnxruntime_LINK_LIBATOMIC)
|
|
|
|
|
list(APPEND onnxruntime_EXTERNAL_LIBRARIES atomic)
|
|
|
|
|
endif()
|
2021-05-27 17:03:02 +00:00
|
|
|
|
|
|
|
|
if(APPLE)
|
|
|
|
|
target_link_libraries(onnxruntime_common "-framework Foundation")
|
|
|
|
|
endif()
|
2021-07-12 21:21:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
|
if(onnxruntime_target_platform STREQUAL "ARM64")
|
|
|
|
|
set(ARM64 TRUE)
|
|
|
|
|
elseif (onnxruntime_target_platform STREQUAL "ARM")
|
|
|
|
|
set(ARM TRUE)
|
|
|
|
|
elseif(onnxruntime_target_platform STREQUAL "x64")
|
|
|
|
|
set(X64 TRUE)
|
|
|
|
|
elseif(onnxruntime_target_platform STREQUAL "x86")
|
|
|
|
|
set(X86 TRUE)
|
|
|
|
|
endif()
|
2021-09-04 20:30:33 +00:00
|
|
|
elseif(APPLE)
|
|
|
|
|
if(CMAKE_OSX_ARCHITECTURES_LEN LESS_EQUAL 1)
|
|
|
|
|
set(X64 TRUE)
|
2021-07-12 21:21:12 +00:00
|
|
|
endif()
|
2021-09-04 20:30:33 +00:00
|
|
|
elseif(NOT onnxruntime_BUILD_WEBASSEMBLY)
|
2021-07-12 21:21:12 +00:00
|
|
|
if (CMAKE_SYSTEM_NAME STREQUAL "Android")
|
|
|
|
|
if (CMAKE_ANDROID_ARCH_ABI STREQUAL "armeabi-v7a")
|
|
|
|
|
set(ARM TRUE)
|
|
|
|
|
elseif (CMAKE_ANDROID_ARCH_ABI STREQUAL "arm64-v8a")
|
|
|
|
|
set(ARM64 TRUE)
|
|
|
|
|
elseif (CMAKE_ANDROID_ARCH_ABI STREQUAL "x86_64")
|
|
|
|
|
set(X86_64 TRUE)
|
|
|
|
|
elseif (CMAKE_ANDROID_ARCH_ABI STREQUAL "x86")
|
|
|
|
|
set(X86 TRUE)
|
|
|
|
|
endif()
|
|
|
|
|
else()
|
|
|
|
|
execute_process(
|
|
|
|
|
COMMAND ${CMAKE_C_COMPILER} -dumpmachine
|
|
|
|
|
OUTPUT_VARIABLE dumpmachine_output
|
|
|
|
|
ERROR_QUIET
|
|
|
|
|
)
|
|
|
|
|
if(dumpmachine_output MATCHES "^arm64.*")
|
|
|
|
|
set(ARM64 TRUE)
|
|
|
|
|
elseif(dumpmachine_output MATCHES "^arm.*")
|
|
|
|
|
set(ARM TRUE)
|
|
|
|
|
elseif(dumpmachine_output MATCHES "^aarch64.*")
|
|
|
|
|
set(ARM64 TRUE)
|
|
|
|
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86?)$")
|
|
|
|
|
set(X86 TRUE)
|
|
|
|
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64)$")
|
|
|
|
|
set(X86_64 TRUE)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
2021-07-14 23:39:17 +00:00
|
|
|
if (ARM64 OR ARM OR X86 OR X64 OR X86_64)
|
2022-03-17 23:43:12 +00:00
|
|
|
if((WIN32 AND NOT CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib) OR ((ARM64 OR ARM) AND MSVC))
|
2021-07-12 21:21:12 +00:00
|
|
|
# msvc compiler report syntax error with cpuinfo arm source files
|
|
|
|
|
# and cpuinfo does not have code for getting arm uarch info under windows
|
|
|
|
|
else()
|
2022-04-08 04:32:12 +00:00
|
|
|
# Link cpuinfo if supported
|
2021-07-14 23:39:17 +00:00
|
|
|
# Using it mainly in ARM with Android.
|
2021-07-12 21:21:12 +00:00
|
|
|
# Its functionality in detecting x86 cpu features are lacking, so is support for Windows.
|
|
|
|
|
|
2022-04-08 04:32:12 +00:00
|
|
|
if (CPUINFO_SUPPORTED)
|
|
|
|
|
target_link_libraries(onnxruntime_common cpuinfo)
|
|
|
|
|
list(APPEND onnxruntime_EXTERNAL_LIBRARIES cpuinfo clog)
|
|
|
|
|
endif()
|
2021-07-12 21:21:12 +00:00
|
|
|
endif()
|
|
|
|
|
endif()
|
2022-04-04 05:37:18 +00:00
|
|
|
|
|
|
|
|
if (NOT onnxruntime_BUILD_SHARED_LIB)
|
|
|
|
|
install(TARGETS onnxruntime_common
|
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
|
FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
|
|
|
endif()
|