Skip to content

Commit

Permalink
Make partitioning utils QDQ aware so it does not break up QDQ node un…
Browse files Browse the repository at this point in the history
…its (microsoft#19723)

### Description
<!-- Describe your changes. -->
If the EP handles QDQ node units, we need to make sure we do not split
those into different partitions.

Update the partitioning utils to be QDQ aware. If there are node units
we process the logical nodes they represent instead of individual nodes.
This ensure we process all nodes in a QDQ node unit at the same time so
that they are always in the same partition.

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
Fix one of the issues in microsoft#19590

---------

Co-authored-by: Edward Chen <[email protected]>
  • Loading branch information
skottmckay and edgchen1 authored Mar 12, 2024
1 parent cba605e commit 978c40d
Show file tree
Hide file tree
Showing 38 changed files with 890 additions and 493 deletions.
9 changes: 7 additions & 2 deletions cmake/external/onnxruntime_external_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ if (onnxruntime_BUILD_UNIT_TESTS)
set(gtest_disable_pthreads ON)
endif()
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
if (CMAKE_SYSTEM_NAME STREQUAL "iOS")
# Needs to update onnxruntime/test/xctest/xcgtest.mm
if (IOS OR ANDROID)
# on mobile platforms the absl flags class dumps the flag names (assumably for binary size), which breaks passing
# any args to gtest executables, such as using --gtest_filter to debug a specific test.
# Processing of compile definitions:
# https://github.com/abseil/abseil-cpp/blob/8dc90ff07402cd027daec520bb77f46e51855889/absl/flags/config.h#L21
# If set, this code throws away the flag and does nothing on registration, which results in no flags being known:
# https://github.com/abseil/abseil-cpp/blob/8dc90ff07402cd027daec520bb77f46e51855889/absl/flags/flag.h#L205-L217
set(GTEST_HAS_ABSL OFF CACHE BOOL "" FORCE)
else()
set(GTEST_HAS_ABSL ON CACHE BOOL "" FORCE)
Expand Down
4 changes: 2 additions & 2 deletions cmake/onnxruntime_providers_coreml.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ list(FILTER coreml_proto_generated_srcs INCLUDE REGEX "\.pb\.(h|cc)$")
source_group(TREE ${CMAKE_CURRENT_BINARY_DIR} PREFIX coreml_proto_generated FILES ${coreml_proto_generated_srcs})

# These are shared utils,
# TODO, move this to a separated lib when used by EPs other than NNAPI and CoreML
file(GLOB_RECURSE onnxruntime_providers_shared_utils_cc_srcs CONFIGURE_DEPENDS
# TODO, move this to a separate lib when used by EPs other than NNAPI and CoreML
file(GLOB onnxruntime_providers_shared_utils_cc_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/core/providers/shared/utils/utils.h"
"${ONNXRUNTIME_ROOT}/core/providers/shared/utils/utils.cc"
)
Expand Down
6 changes: 2 additions & 4 deletions cmake/onnxruntime_providers_nnapi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,10 @@
endif()

# These are shared utils,
# TODO, move this to a separated lib when used by EPs other than NNAPI and CoreML
# TODO, move this to a separate lib when used by EPs other than NNAPI and CoreML
list(APPEND onnxruntime_provider_nnapi_cc_src_patterns
"${ONNXRUNTIME_ROOT}/core/providers/shared/utils/utils.h"
"${ONNXRUNTIME_ROOT}/core/providers/shared/utils/utils.cc"
"${ONNXRUNTIME_ROOT}/core/providers/shared/node_unit/node_unit.h"
"${ONNXRUNTIME_ROOT}/core/providers/shared/node_unit/node_unit.cc"
)

file(GLOB onnxruntime_providers_nnapi_cc_srcs CONFIGURE_DEPENDS ${onnxruntime_provider_nnapi_cc_src_patterns})
Expand All @@ -81,4 +79,4 @@
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
endif()
8 changes: 3 additions & 5 deletions cmake/onnxruntime_providers_qnn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
add_compile_definitions(USE_QNN=1)

# These are shared utils,
# TODO, move this to a separated lib when used by EPs other than QNN, NNAPI and CoreML
file(GLOB_RECURSE onnxruntime_providers_shared_utils_cc_srcs CONFIGURE_DEPENDS
# TODO, move to a separate lib when used by EPs other than QNN, NNAPI and CoreML
file(GLOB onnxruntime_providers_shared_utils_cc_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/core/providers/shared/utils/utils.h"
"${ONNXRUNTIME_ROOT}/core/providers/shared/utils/utils.cc"
"${ONNXRUNTIME_ROOT}/core/providers/shared/node_unit/node_unit.h"
"${ONNXRUNTIME_ROOT}/core/providers/shared/node_unit/node_unit.cc"
)

file(GLOB_RECURSE
Expand Down Expand Up @@ -42,4 +40,4 @@
# ignore the warning unknown-pragmas on "pragma region"
if(NOT MSVC)
target_compile_options(onnxruntime_providers_qnn PRIVATE "-Wno-unknown-pragmas")
endif()
endif()
3 changes: 0 additions & 3 deletions cmake/onnxruntime_providers_xnnpack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
"${ONNXRUNTIME_INCLUDE_DIR}/core/providers/xnnpack/*.h"
"${ONNXRUNTIME_ROOT}/core/providers/xnnpack/*.h"
"${ONNXRUNTIME_ROOT}/core/providers/xnnpack/*.cc"
# utils for handling QDQ models
"${ONNXRUNTIME_ROOT}/core/providers/shared/node_unit/node_unit.h"
"${ONNXRUNTIME_ROOT}/core/providers/shared/node_unit/node_unit.cc"
)

source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_providers_xnnpack_cc_srcs})
Expand Down
Loading

0 comments on commit 978c40d

Please sign in to comment.