mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-16 21:00:14 +00:00
* Add Transpose Optimizer and modify nhwc optimizer to use it. * Fix casts * Fix casts2 * Fix move * Add tests * Add headers * Fixes and tests * Remove explicit template instantiation * Fix build warning * Name unit tests * Code review fixes * Add some comments * Fix some casts * Make optimization slightly less agressive * Some unit test fixes * Update Attention pattern to work with transpose optimizer * Update attention fuser * Fix attention fusion python script * Improve transpose optimizer documentation * Create OptimizerCtx struct * Disable Slice handler for testing * Implement Slice int32 * Only push transposes leading up to other transposes * Improve optimization heuristic * Add exemption for MaxPool * Document transpose optimizer api.h * Revert fusion tests to master * Remove temp files * Replace typedef with using * Trim trailing whitespace * Move class declarations from api_impl.h to api_impl.cc * Remove copy constructors and move allocator * Alphabetize headers * Add override keyword * Comments for nhwc_transformer * Rename OrtGraph to ApiGraph, etc. * Wrap line * Remove extra qualifier on ApiGraph * Refector attention fusion * Remove c-style casts from api_impl.cc * Improve documentation * Avoid printing vector in ORT_ENSURES * Revert attention fusion refactor * Remove duplicate cost heuristics and improve documentation * Fix size_t casts * Fixes from Scott's review * Unrevert attention refactor and more updates from Scott's review * Revert api_impl.cc ValueInfo change * only optimize first transpose input * Unrevert api_impl.cc changes * Make vector call reserve * transpose_optimizer.cc update from Scott's comments * Rename api::Graph to api::GraphRef etc. * Consider domains 'onnx.ai' and '' equal * Replace AddInput with SetInput * Improve tests * quantization and heuristic tests * Comments for tests * Replace const string_view with string_view and update tests * Fixes requested by Edward * Fix std::string to string_view conversion * Add <string> to includes * Fix bug for broadcasting ops with unknown rank. Slight safety improvements * Changes requested by Edward * Fix formatting * Improve description of cost metric
69 lines
3.3 KiB
CMake
69 lines
3.3 KiB
CMake
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
# Licensed under the MIT License.
|
|
|
|
set(onnxruntime_optimizer_src_patterns)
|
|
|
|
if (onnxruntime_MINIMAL_BUILD)
|
|
# we include a couple of files so a library is produced and we minimize other changes to the build setup.
|
|
# if the transformer base class is unused it will be excluded from the final binary size
|
|
list(APPEND onnxruntime_optimizer_src_patterns
|
|
"${ONNXRUNTIME_INCLUDE_DIR}/core/optimizer/graph_transformer.h"
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/graph_transformer.cc"
|
|
)
|
|
|
|
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()
|
|
else()
|
|
list(APPEND onnxruntime_optimizer_src_patterns
|
|
"${ONNXRUNTIME_INCLUDE_DIR}/core/optimizer/*.h"
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/*.h"
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/*.cc"
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/*.h"
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/*.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"
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/transpose_optimizer/*.h"
|
|
"${ONNXRUNTIME_ROOT}/core/optimizer/transpose_optimizer/*.cc"
|
|
)
|
|
|
|
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()
|
|
endif()
|
|
|
|
if (onnxruntime_ENABLE_TRAINING)
|
|
list(APPEND onnxruntime_optimizer_src_patterns
|
|
"${ORTTRAINING_SOURCE_DIR}/core/optimizer/*.h"
|
|
"${ORTTRAINING_SOURCE_DIR}/core/optimizer/*.cc"
|
|
)
|
|
endif()
|
|
|
|
file(GLOB onnxruntime_optimizer_srcs CONFIGURE_DEPENDS ${onnxruntime_optimizer_src_patterns})
|
|
|
|
source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_optimizer_srcs})
|
|
|
|
onnxruntime_add_static_library(onnxruntime_optimizer ${onnxruntime_optimizer_srcs})
|
|
|
|
install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/optimizer DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core)
|
|
onnxruntime_add_include_to_target(onnxruntime_optimizer onnxruntime_common onnxruntime_framework onnx onnx_proto ${PROTOBUF_LIB} flatbuffers)
|
|
target_include_directories(onnxruntime_optimizer PRIVATE ${ONNXRUNTIME_ROOT})
|
|
if (onnxruntime_ENABLE_TRAINING)
|
|
target_include_directories(onnxruntime_optimizer PRIVATE ${ORTTRAINING_ROOT})
|
|
endif()
|
|
add_dependencies(onnxruntime_optimizer ${onnxruntime_EXTERNAL_DEPENDENCIES})
|
|
set_target_properties(onnxruntime_optimizer PROPERTIES FOLDER "ONNXRuntime")
|