onnxruntime/cmake/onnxruntime_graph.cmake

147 lines
5.6 KiB
CMake
Raw Normal View History

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_RECURSE onnxruntime_graph_src CONFIGURE_DEPENDS
"${ONNXRUNTIME_INCLUDE_DIR}/core/graph/*.h"
"${ONNXRUNTIME_ROOT}/core/graph/*.h"
"${ONNXRUNTIME_ROOT}/core/graph/*.cc"
)
# create empty list for any excludes
set(onnxruntime_graph_src_exclude_patterns)
if (onnxruntime_MINIMAL_BUILD)
# remove schema registration support
list(APPEND onnxruntime_graph_src_exclude_patterns
"${ONNXRUNTIME_INCLUDE_DIR}/core/graph/schema_registry.h"
"${ONNXRUNTIME_ROOT}/core/graph/schema_registry.cc"
"${ONNXRUNTIME_ROOT}/core/graph/contrib_ops/*defs.h"
"${ONNXRUNTIME_ROOT}/core/graph/contrib_ops/*defs.cc"
2022-02-09 17:31:58 +00:00
"${ONNXRUNTIME_ROOT}/core/graph/contrib_ops/onnx_deprecated_operators.cc"
"${ONNXRUNTIME_ROOT}/core/graph/contrib_ops/onnx_function_util.h"
"${ONNXRUNTIME_ROOT}/core/graph/contrib_ops/onnx_function_util.cc"
"${ONNXRUNTIME_ROOT}/core/graph/function_template.h"
"${ONNXRUNTIME_ROOT}/core/graph/function_utils.h"
"${ONNXRUNTIME_ROOT}/core/graph/function_utils.cc"
)
# no Function support initially
list(APPEND onnxruntime_graph_src_exclude_patterns
"${ONNXRUNTIME_ROOT}/core/graph/function*"
)
Unify the Compile API for mobile build and normal build (#10632) * use the lightweight compile api as default; use dnnl ep for testing * apply to tensorrt ep * fix the missing files * fix build * fix the copy issue on linux * migrate migraphx and openvino ep * fix openvino build break * fix linux build * fix unused parameter * fix coreml build * use graph view's filtered initializers * fix openvino break * fix tvm compile api * fix tvm / rknpu / vitisai ep build * add IsInitializedTensor in graph_viewer; fix nuphar build * use serializer directly as tvm ep is still static lib * fix the type mismatch * fix the type mismatch * fix merge conflict * add a comment * fix minimal build * fix the DML EP's legacy approach * save type/shape in dnnl IR * fix linux break * fix tvm failure * dnnl ep: move initializer referenced out of dnnl subgraph * Revert "add IsInitializedTensor in graph_viewer; fix nuphar build" This reverts commit 1cc3c7f08c16fee4fe3309a67209eb769d479587. * add IsInitializedTensor to graph viewer * add the legacy code for nuphar build to temporarily make nuphar build work * ignore internal test for nuphar * remove the out of date tests * keep the legacy API in EP for a while * turn serializer into a static function * update comments * fix tvm build * Update include/onnxruntime/core/framework/execution_provider.h Co-authored-by: Pranav Sharma <prs@microsoft.com> * Update include/onnxruntime/core/framework/execution_provider.h Co-authored-by: Pranav Sharma <prs@microsoft.com> * Update onnxruntime/core/framework/execution_provider.cc Co-authored-by: Pranav Sharma <prs@microsoft.com> * updatee comments; add warning message for legacy compil call * add a flag to control out of scope arg in serialization * fix trt build; improve the test * resolve merege errors * fix a typo Co-authored-by: Cheng Tang <chenta@microsoft.com> Co-authored-by: Cheng Tang <chenta@microsoft.com@orttrainingdev9.d32nl1ml4oruzj4qz3bqlggovf.px.internal.cloudapp.net> Co-authored-by: Pranav Sharma <prs@microsoft.com>
2022-05-05 15:30:07 +00:00
# remove graph proto serializer
list(APPEND onnxruntime_graph_src_exclude_patterns
"${ONNXRUNTIME_ROOT}/core/graph/graph_proto_serializer.cc"
"${ONNXRUNTIME_ROOT}/core/graph/graph_proto_serializer.h"
)
# no optimizer support in base minimal build
# some optimizer support in extended minimal build
if (NOT onnxruntime_EXTENDED_MINIMAL_BUILD)
list(APPEND onnxruntime_graph_src_exclude_patterns
"${ONNXRUNTIME_ROOT}/core/graph/graph_utils.*"
)
endif()
endif()
if (onnxruntime_DISABLE_CONTRIB_OPS)
list(APPEND onnxruntime_graph_src_exclude_patterns
"${ONNXRUNTIME_ROOT}/core/graph/contrib_ops/*.h"
"${ONNXRUNTIME_ROOT}/core/graph/contrib_ops/*.cc"
)
endif()
2018-11-20 00:48:22 +00:00
if(NOT onnxruntime_USE_DML)
list(APPEND onnxruntime_graph_src_exclude_patterns
"${ONNXRUNTIME_ROOT}/core/graph/dml_ops/*.h"
"${ONNXRUNTIME_ROOT}/core/graph/dml_ops/*.cc"
)
endif()
file(GLOB onnxruntime_graph_src_exclude ${onnxruntime_graph_src_exclude_patterns})
list(REMOVE_ITEM onnxruntime_graph_src ${onnxruntime_graph_src_exclude})
2019-04-29 19:58:20 +00:00
file(GLOB_RECURSE onnxruntime_ir_defs_src CONFIGURE_DEPENDS
2020-03-11 21:25:37 +00:00
"${ONNXRUNTIME_ROOT}/core/defs/*.cc"
2018-11-20 00:48:22 +00:00
)
if (onnxruntime_ENABLE_TRAINING_OPS AND NOT onnxruntime_ENABLE_TRAINING)
set(orttraining_graph_src
"${ORTTRAINING_SOURCE_DIR}/core/graph/training_op_defs.cc"
"${ORTTRAINING_SOURCE_DIR}/core/graph/training_op_defs.h"
)
endif()
2020-03-11 21:25:37 +00:00
if (onnxruntime_ENABLE_TRAINING)
file(GLOB_RECURSE orttraining_graph_src CONFIGURE_DEPENDS
"${ORTTRAINING_SOURCE_DIR}/core/graph/*.h"
"${ORTTRAINING_SOURCE_DIR}/core/graph/*.cc"
)
endif()
set(onnxruntime_graph_lib_src ${onnxruntime_graph_src} ${onnxruntime_ir_defs_src})
if (onnxruntime_ENABLE_TRAINING OR onnxruntime_ENABLE_TRAINING_OPS)
2020-03-11 21:25:37 +00:00
list(APPEND onnxruntime_graph_lib_src ${orttraining_graph_src})
endif()
onnxruntime_add_static_library(onnxruntime_graph ${onnxruntime_graph_lib_src})
add_dependencies(onnxruntime_graph onnx_proto flatbuffers)
Update manylinux build scripts and GPU CUDA version from 11.0 to 11.1 (#7632) 1. Update manylinux build scripts. This will add [PEP600](https://www.python.org/dev/peps/pep-0600/)(manylinux2 tags) support. numpy has adopted this new feature, we should do the same. The old build script files were copied from https://github.com/pypa/manylinux, but they has been deleted and replaced in the upstream repo. The manylinux repo doesn't have a manylinux2014 branch anymore. So I'm removing the obsolete code, sync the files with the latest master. 2. Update GPU CUDA version from 11.0 to 11.1(after a discussion with PMs). 3. Delete tools/ci_build/github/linux/docker/Dockerfile.manylinux2014_cuda10_2. (Merged the content to tools/ci_build/github/linux/docker/Dockerfile.manylinux2014_cuda11) 4. Modernize the cmake code of how to locate python devel files. It was suggested in https://github.com/onnx/onnx/pull/1631 . 5. Remove `onnxruntime_MSVC_STATIC_RUNTIME` and `onnxruntime_GCC_STATIC_CPP_RUNTIME` build options. Now cmake has builtin support for it. Starting from cmake 3.15, we can use `CMAKE_MSVC_RUNTIME_LIBRARY` cmake variable to choose which MSVC runtime library we want to use. 6. Update Ubuntu docker images that used in our CI build from Ubuntu 18.04 to Ubuntu 20.04. 7. Update GCC version in CUDA 11.1 pipelines from 8.x to 9.3.1 8. Split Linux GPU CI pipeline to two jobs: build the code on a CPU machine then run the tests on another GPU machines. In the past we didn't test our python packages. We only tested the pre-packed files. So we didn't catch the rpath issue in CI build. 9. Add a CentOS machine pool and test our Linux GPU build on real CentOS machines. 10. Rework ARM64 Linux GPU python packaging pipeline. Previously it uses cross-compiling therefore we must static link to C Runtime. But now have pluggable EP API and it doesn't support static link. So I changed to use qemu emulation instead. Now the build is 10x slower than before. But it is more extensible.
2021-06-03 06:36:49 +00:00
onnxruntime_add_include_to_target(onnxruntime_graph onnxruntime_common onnx onnx_proto ${PROTOBUF_LIB} flatbuffers)
if(NOT MSVC)
target_compile_options(onnxruntime_graph PRIVATE "-Wno-parentheses")
endif()
if (onnxruntime_ENABLE_TRAINING)
#TODO: the graph library should focus on ONNX IR, it shouldn't depend on math libraries like MKLML/OpenBlas
target_include_directories(onnxruntime_graph PRIVATE ${MKLML_INCLUDE_DIR})
target_link_libraries(onnxruntime_graph PRIVATE nlohmann_json::nlohmann_json)
endif()
2018-11-20 00:48:22 +00:00
target_include_directories(onnxruntime_graph PRIVATE ${ONNXRUNTIME_ROOT})
2020-03-11 21:25:37 +00:00
if (onnxruntime_ENABLE_TRAINING OR onnxruntime_ENABLE_TRAINING_OPS)
2020-03-11 21:25:37 +00:00
target_include_directories(onnxruntime_graph PRIVATE ${ORTTRAINING_ROOT})
if (onnxruntime_USE_NCCL)
target_include_directories(onnxruntime_graph PRIVATE ${NCCL_INCLUDE_DIRS})
endif()
2020-03-11 21:25:37 +00:00
endif()
2018-11-20 00:48:22 +00:00
set_target_properties(onnxruntime_graph PROPERTIES FOLDER "ONNXRuntime")
set_target_properties(onnxruntime_graph PROPERTIES LINKER_LANGUAGE CXX)
2018-11-23 04:56:43 +00:00
install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/graph DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core)
2018-11-20 00:48:22 +00:00
source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_graph_src} ${onnxruntime_ir_defs_src})
if (onnxruntime_ENABLE_TRAINING OR onnxruntime_ENABLE_TRAINING_OPS)
2020-03-11 21:25:37 +00:00
source_group(TREE ${ORTTRAINING_ROOT} FILES ${orttraining_graph_src})
endif()
2018-11-20 00:48:22 +00:00
Add LearningModelBuilder to WinML Experimental Namespace along with various Audio operators (#6623) * model building * fix build * winml adapter model building api * model building * make build * make build again * add model building with audio op * inplace and inorder fft * add ifft * works! * cleanup * add comments * switch to iterative rather than recursive and use parallelization * batched parallelization * fft->dft * cleanup * window functions * add melweightmatrix op * updates to make spectrogram test work * push latest * add onesided * cleanup * Clean up building apis and fix mel * cleanup * cleanup * naive stft * fix test output * middle c complete * 3 tones * cleanup * signal def new line * Add save functionality * Perf improvements, 10x improvement * cleanup * use bitreverse lookup table for performance * implement constant initializers for tensors * small changes * add matmul tests * merge issues * support add attribute * add tests for double data type windowfunctions and minor cleanup * stft onesided/and not tests * cleanup * cleanup * clean up * cleanup * remove threading attribute * forward declare orttypeinfo * warnings * fwd declare * fix warnings * 1 more warning * remove saving to e drive... * cleanup and fix stft test * add opset picker * small additions * add onnxruntime tests * add signed/unsigned * fix warning * fix warning * finish onnxruntime tests * make windows namespace build succeed * add experimental flag * add experimental api into nuget package * add experimental api build flag and add to windows ai nuget package * turn experimental for tests * add minimum opset version to new experimental domain * api cleanup * disable ms experimental ops test when --ms_experimental is not enabled * add macro behind flag * remove unused x * pr feedback Co-authored-by: Sheil Kumar <sheilk@microsoft.com>
2021-02-12 22:17:10 +00:00
if (onnxruntime_BUILD_MS_EXPERIMENTAL_OPS)
target_compile_definitions(onnxruntime_graph PRIVATE BUILD_MS_EXPERIMENTAL_OPS=1)
endif()
2018-11-20 00:48:22 +00:00
if (WIN32)
set(onnxruntime_graph_static_library_flags
-IGNORE:4221 # LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
)
set_target_properties(onnxruntime_graph PROPERTIES
STATIC_LIBRARY_FLAGS "${onnxruntime_graph_static_library_flags}")
if (NOT onnxruntime_DISABLE_EXCEPTIONS)
2018-11-20 00:48:22 +00:00
target_compile_options(onnxruntime_graph PRIVATE
/EHsc # exception handling - C++ may throw, extern "C" will not
)
endif()
endif()
if (onnxruntime_ENABLE_ATEN)
target_compile_definitions(onnxruntime_graph PRIVATE ENABLE_ATEN)
2018-11-20 00:48:22 +00:00
endif()
if (NOT onnxruntime_BUILD_SHARED_LIB)
install(TARGETS onnxruntime_graph
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()