2019-02-04 23:45:12 +00:00
|
|
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
|
# Licensed under the MIT License.
|
|
|
|
|
|
2021-08-27 07:16:05 +00:00
|
|
|
set(onnxruntime_optimizer_src_patterns)
|
|
|
|
|
|
2020-08-21 21:14:53 +00:00
|
|
|
if (onnxruntime_MINIMAL_BUILD)
|
|
|
|
|
# we include a couple of files so a library is produced and we minimize other changes to the build setup.
|
2021-08-27 07:16:05 +00:00
|
|
|
# if the transformer base class is unused it will be excluded from the final binary size
|
|
|
|
|
list(APPEND onnxruntime_optimizer_src_patterns
|
2020-08-21 21:14:53 +00:00
|
|
|
"${ONNXRUNTIME_INCLUDE_DIR}/core/optimizer/graph_transformer.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/graph_transformer.cc"
|
|
|
|
|
)
|
2021-08-27 07:16:05 +00:00
|
|
|
|
|
|
|
|
if (onnxruntime_ENABLE_ORT_FORMAT_RUNTIME_GRAPH_OPTIMIZATION)
|
|
|
|
|
list(APPEND onnxruntime_optimizer_src_patterns
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/ort_format_runtime_optimization/utils.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/ort_format_runtime_optimization/utils.cc"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/qdq_util.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/qdq_util.cc"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/*.cc"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/selectors_actions/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/selectors_actions/*.cc"
|
|
|
|
|
)
|
|
|
|
|
endif()
|
2020-08-21 21:14:53 +00:00
|
|
|
else()
|
2021-08-27 07:16:05 +00:00
|
|
|
list(APPEND onnxruntime_optimizer_src_patterns
|
2019-10-09 00:37:44 +00:00
|
|
|
"${ONNXRUNTIME_INCLUDE_DIR}/core/optimizer/*.h"
|
2019-02-04 23:45:12 +00:00
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/*.cc"
|
2021-03-25 16:17:23 +00:00
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/*.cc"
|
2021-08-27 07:16:05 +00:00
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/*.cc"
|
2021-07-09 06:11:43 +00:00
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/selectors_actions/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/selectors_actions/*.cc"
|
2020-08-21 21:14:53 +00:00
|
|
|
)
|
2021-08-27 07:16:05 +00:00
|
|
|
|
|
|
|
|
if (onnxruntime_ENABLE_ORT_FORMAT_RUNTIME_GRAPH_OPTIMIZATION)
|
|
|
|
|
list(APPEND onnxruntime_optimizer_src_patterns
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/ort_format_runtime_optimization/utils.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/ort_format_runtime_optimization/utils.cc"
|
|
|
|
|
)
|
|
|
|
|
endif()
|
2020-08-21 21:14:53 +00:00
|
|
|
endif()
|
2019-02-04 23:45:12 +00:00
|
|
|
|
2020-03-11 21:25:37 +00:00
|
|
|
if (onnxruntime_ENABLE_TRAINING)
|
2021-08-27 07:16:05 +00:00
|
|
|
list(APPEND onnxruntime_optimizer_src_patterns
|
|
|
|
|
"${ORTTRAINING_SOURCE_DIR}/core/optimizer/*.h"
|
|
|
|
|
"${ORTTRAINING_SOURCE_DIR}/core/optimizer/*.cc"
|
|
|
|
|
)
|
2020-03-11 21:25:37 +00:00
|
|
|
endif()
|
|
|
|
|
|
2021-08-27 07:16:05 +00:00
|
|
|
file(GLOB onnxruntime_optimizer_srcs CONFIGURE_DEPENDS ${onnxruntime_optimizer_src_patterns})
|
|
|
|
|
|
2019-02-04 23:45:12 +00:00
|
|
|
source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_optimizer_srcs})
|
|
|
|
|
|
2021-04-29 18:54:57 +00:00
|
|
|
onnxruntime_add_static_library(onnxruntime_optimizer ${onnxruntime_optimizer_srcs})
|
2020-08-21 21:14:53 +00:00
|
|
|
|
2019-02-04 23:45:12 +00:00
|
|
|
install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/optimizer DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core)
|
2021-06-03 06:36:49 +00:00
|
|
|
onnxruntime_add_include_to_target(onnxruntime_optimizer onnxruntime_common onnxruntime_framework onnx onnx_proto ${PROTOBUF_LIB} flatbuffers)
|
2019-02-04 23:45:12 +00:00
|
|
|
target_include_directories(onnxruntime_optimizer PRIVATE ${ONNXRUNTIME_ROOT})
|
2020-03-11 21:25:37 +00:00
|
|
|
if (onnxruntime_ENABLE_TRAINING)
|
|
|
|
|
target_include_directories(onnxruntime_optimizer PRIVATE ${ORTTRAINING_ROOT})
|
|
|
|
|
endif()
|
2019-02-04 23:45:12 +00:00
|
|
|
add_dependencies(onnxruntime_optimizer ${onnxruntime_EXTERNAL_DEPENDENCIES})
|
|
|
|
|
set_target_properties(onnxruntime_optimizer PROPERTIES FOLDER "ONNXRuntime")
|