Skip to content

Commit ad45432

Browse files
adrianlizarragaquic-tirupathquic-calvnguyqti-kromeroqti-jkilpatrick
authored
ORT 1.23.0 cherry-pick prs 25592 - 25831 (#25805)
### Description Cherry-pick the following PRs into the `rel-1.23.0` branch: - #25592 - #25622 - #25688 - #25729 - #25743 - #25769 - #25745 - #25761 - #25751 - #25716 - #25228 - #25768 - #25788 - #25747 - #25800 - #25818 - #25762 - #25749 - #25831 ### 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. --> --------- Co-authored-by: quic-tirupath <[email protected]> Co-authored-by: quic-calvnguy <[email protected]> Co-authored-by: qti-kromero <[email protected]> Co-authored-by: Jeff Kilpatrick <[email protected]> Co-authored-by: Scott McKay <[email protected]> Co-authored-by: David Fan <[email protected]> Co-authored-by: kuanyul-qti <[email protected]> Co-authored-by: Dmitri Smirnov <[email protected]> Co-authored-by: Chi Lo <[email protected]> Co-authored-by: Edward Chen <[email protected]> Co-authored-by: Chunye Wang@AMD <[email protected]> Co-authored-by: minfhong-qti <[email protected]> Co-authored-by: Vishal Agarwal <[email protected]> Co-authored-by: Maximilian Müller <[email protected]> Co-authored-by: Maximilian Müller <[email protected]> Co-authored-by: Changming Sun <[email protected]> Co-authored-by: adrastogi <[email protected]> Co-authored-by: Aditya Rastogi <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 1d1712f commit ad45432

File tree

109 files changed

+3961
-1366
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+3961
-1366
lines changed

.github/workflows/mac.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ jobs:
5353
runs-on: macos-15
5454

5555
env:
56-
xcode_version: 16
56+
xcode_version: 16.4
57+
simulator_runtime_version: 18.5
5758

5859
strategy:
5960
matrix:
@@ -90,6 +91,8 @@ jobs:
9091
--apple_deploy_target=15.1 \
9192
--apple_sysroot=iphonesimulator \
9293
--osx_arch=${{ matrix.target_arch }}
94+
env:
95+
ORT_GET_SIMULATOR_DEVICE_INFO_REQUESTED_RUNTIME_VERSION: ${{ env.simulator_runtime_version }}
9396

9497
Objective-C-StaticAnalysis:
9598
runs-on: macos-14

cmake/external/onnxruntime_external_deps.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,13 @@ if (onnxruntime_ENABLE_CPUINFO)
336336
set(CPUINFO_SUPPORTED TRUE)
337337
endif()
338338
if (WIN32)
339-
set(CPUINFO_SUPPORTED TRUE)
339+
# There's an error when linking with cpuinfo on arm64ec with a vcpkg build (--use_vcpkg).
340+
# TODO Fix it and then re-enable cpuinfo on arm64ec.
341+
if (onnxruntime_target_platform STREQUAL "ARM64EC")
342+
set(CPUINFO_SUPPORTED FALSE)
343+
else()
344+
set(CPUINFO_SUPPORTED TRUE)
345+
endif()
340346
elseif (NOT ${onnxruntime_target_platform} MATCHES "^(i[3-6]86|AMD64|x86(_64)?|armv[5-8].*|aarch64|arm64)$")
341347
message(WARNING
342348
"Target processor architecture \"${onnxruntime_target_platform}\" is not supported in cpuinfo. "

cmake/onnxruntime_common.cmake

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set(onnxruntime_common_src_patterns
1414
"${ONNXRUNTIME_ROOT}/core/platform/check_intel.h"
1515
"${ONNXRUNTIME_ROOT}/core/platform/check_intel.cc"
1616
"${ONNXRUNTIME_ROOT}/core/platform/device_discovery.h"
17-
"${ONNXRUNTIME_ROOT}/core/platform/device_discovery.cc"
17+
"${ONNXRUNTIME_ROOT}/core/platform/device_discovery_common.cc"
1818
"${ONNXRUNTIME_ROOT}/core/platform/env.h"
1919
"${ONNXRUNTIME_ROOT}/core/platform/env.cc"
2020
"${ONNXRUNTIME_ROOT}/core/platform/env_time.h"
@@ -32,26 +32,38 @@ set(onnxruntime_common_src_patterns
3232

3333
if(WIN32)
3434
list(APPEND onnxruntime_common_src_patterns
35-
"${ONNXRUNTIME_ROOT}/core/platform/windows/*.h"
36-
"${ONNXRUNTIME_ROOT}/core/platform/windows/*.cc"
35+
"${ONNXRUNTIME_ROOT}/core/platform/windows/debug_alloc.cc"
36+
"${ONNXRUNTIME_ROOT}/core/platform/windows/debug_alloc.h"
37+
"${ONNXRUNTIME_ROOT}/core/platform/windows/dll_load_error.cc"
38+
"${ONNXRUNTIME_ROOT}/core/platform/windows/dll_load_error.h"
39+
"${ONNXRUNTIME_ROOT}/core/platform/windows/env_time.cc"
40+
"${ONNXRUNTIME_ROOT}/core/platform/windows/env.cc"
41+
"${ONNXRUNTIME_ROOT}/core/platform/windows/env.h"
42+
"${ONNXRUNTIME_ROOT}/core/platform/windows/hardware_core_enumerator.cc"
43+
"${ONNXRUNTIME_ROOT}/core/platform/windows/hardware_core_enumerator.h"
44+
"${ONNXRUNTIME_ROOT}/core/platform/windows/stacktrace.cc"
45+
"${ONNXRUNTIME_ROOT}/core/platform/windows/telemetry.cc"
46+
"${ONNXRUNTIME_ROOT}/core/platform/windows/telemetry.h"
3747
"${ONNXRUNTIME_ROOT}/core/platform/windows/logging/*.h"
3848
"${ONNXRUNTIME_ROOT}/core/platform/windows/logging/*.cc"
3949
)
4050

4151
else()
4252
list(APPEND onnxruntime_common_src_patterns
43-
"${ONNXRUNTIME_ROOT}/core/platform/posix/*.h"
44-
"${ONNXRUNTIME_ROOT}/core/platform/posix/*.cc"
53+
"${ONNXRUNTIME_ROOT}/core/platform/posix/env_time.cc"
54+
"${ONNXRUNTIME_ROOT}/core/platform/posix/env.cc"
55+
"${ONNXRUNTIME_ROOT}/core/platform/posix/stacktrace.cc"
4556
)
4657

58+
# logging files
4759
if (onnxruntime_USE_SYSLOG)
4860
list(APPEND onnxruntime_common_src_patterns
4961
"${ONNXRUNTIME_ROOT}/core/platform/posix/logging/*.h"
5062
"${ONNXRUNTIME_ROOT}/core/platform/posix/logging/*.cc"
5163
)
5264
endif()
5365

54-
if (CMAKE_SYSTEM_NAME STREQUAL "Android")
66+
if (ANDROID)
5567
list(APPEND onnxruntime_common_src_patterns
5668
"${ONNXRUNTIME_ROOT}/core/platform/android/logging/*.h"
5769
"${ONNXRUNTIME_ROOT}/core/platform/android/logging/*.cc"
@@ -66,6 +78,21 @@ else()
6678
endif()
6779
endif()
6880

81+
# platform-specific device discovery files
82+
if (WIN32)
83+
list(APPEND onnxruntime_common_src_patterns
84+
"${ONNXRUNTIME_ROOT}/core/platform/windows/device_discovery.cc")
85+
elseif (LINUX)
86+
list(APPEND onnxruntime_common_src_patterns
87+
"${ONNXRUNTIME_ROOT}/core/platform/linux/device_discovery.cc")
88+
elseif (APPLE)
89+
list(APPEND onnxruntime_common_src_patterns
90+
"${ONNXRUNTIME_ROOT}/core/platform/apple/device_discovery.cc")
91+
else()
92+
list(APPEND onnxruntime_common_src_patterns
93+
"${ONNXRUNTIME_ROOT}/core/platform/device_discovery_default.cc")
94+
endif()
95+
6996
if(onnxruntime_target_platform STREQUAL "ARM64EC")
7097
if (MSVC)
7198
link_directories("$ENV{VCINSTALLDIR}/Tools/MSVC/$ENV{VCToolsVersion}/lib/ARM64EC")
@@ -216,8 +243,6 @@ endif()
216243

217244
if (RISCV64 OR ARM64 OR ARM OR X86 OR X64 OR X86_64)
218245
# Link cpuinfo if supported
219-
# Using it mainly in ARM with Android.
220-
# Its functionality in detecting x86 cpu features are lacking, so is support for Windows.
221246
if (CPUINFO_SUPPORTED)
222247
onnxruntime_add_include_to_target(onnxruntime_common cpuinfo::cpuinfo)
223248
list(APPEND onnxruntime_EXTERNAL_LIBRARIES cpuinfo::cpuinfo ${ONNXRUNTIME_CLOG_TARGET_NAME})
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/include/cpuinfo.h b/include/cpuinfo.h
2+
index f1d35d4..9e454d2 100644
3+
--- a/include/cpuinfo.h
4+
+++ b/include/cpuinfo.h
5+
@@ -18,7 +18,7 @@
6+
#define CPUINFO_ARCH_X86 1
7+
#endif
8+
9+
-#if defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
10+
+#if defined(__x86_64__) || defined(__x86_64) || (defined(_M_X64) && !defined(_M_ARM64EC)) || (defined(_M_AMD64) && !defined(_M_ARM64EC))
11+
#define CPUINFO_ARCH_X86_64 1
12+
#endif
13+
14+
@@ -26,7 +26,7 @@
15+
#define CPUINFO_ARCH_ARM 1
16+
#endif
17+
18+
-#if defined(__aarch64__) || defined(_M_ARM64)
19+
+#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
20+
#define CPUINFO_ARCH_ARM64 1
21+
#endif
22+

cmake/vcpkg-ports/cpuinfo/portfile.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ vcpkg_from_github(
99
REF 8a1772a0c5c447df2d18edf33ec4603a8c9c04a6
1010
SHA512 b94ccbfa886221d6bb16513d074675af0a72928a9dd9485dcacdc1124a8a60aacbbe91913a1579e766dfb024f0be1d52eeead40342004ff0238a8b94a095ed08
1111
HEAD_REF master
12+
PATCHES
13+
patch_cpuinfo_h_for_arm64ec.patch
1214
)
1315

1416
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS

include/onnxruntime/core/common/parse_string.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,30 @@ template <typename T>
3535
std::enable_if_t<detail::ParseWithFromChars<T>, bool>
3636
TryParseStringWithClassicLocale(std::string_view str, T& value) {
3737
T parsed_value{};
38-
const auto [ptr, ec] = std::from_chars(str.data(), str.data() + str.size(), parsed_value);
3938

40-
if (ec != std::errc{}) {
39+
std::from_chars_result conversion_result{};
40+
if constexpr (std::is_integral_v<T> && std::is_unsigned_v<T>) {
41+
// For unsigned integral types, also handle hex values, i.e., those beginning with "0x".
42+
// std::from_chars() does not accept the "0x" prefix.
43+
const bool has_hex_prefix = str.size() >= 2 &&
44+
str[0] == '0' &&
45+
(str[1] == 'x' || str[1] == 'X');
46+
47+
if (has_hex_prefix) {
48+
str = str.substr(2);
49+
}
50+
51+
const int base = has_hex_prefix ? 16 : 10;
52+
conversion_result = std::from_chars(str.data(), str.data() + str.size(), parsed_value, base);
53+
} else {
54+
conversion_result = std::from_chars(str.data(), str.data() + str.size(), parsed_value);
55+
}
56+
57+
if (conversion_result.ec != std::errc{}) {
4158
return false;
4259
}
4360

44-
if (ptr != str.data() + str.size()) {
61+
if (conversion_result.ptr != str.data() + str.size()) {
4562
return false;
4663
}
4764

include/onnxruntime/core/framework/execution_provider.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class GraphOptimizerRegistry;
3636
#include "core/framework/framework_provider_common.h"
3737
#include "core/framework/stream_handles.h"
3838
#include "core/framework/tuning_context.h"
39+
#include "core/session/onnxruntime_c_api.h"
3940

4041
struct OrtEpDevice;
4142
struct OrtRunOptions;
@@ -322,6 +323,29 @@ class IExecutionProvider {
322323
virtual common::Status Compile(const std::vector<FusedNodeAndGraph>& fused_nodes_and_graphs,
323324
std::vector<NodeComputeInfo>& node_compute_funcs);
324325

326+
/**
327+
* Get the compatibility info for a compiled model.
328+
*
329+
* The execution provider determines this value, which denotes the compatibility of the compiled model with the EP.
330+
* This is stored in the model metadata under a key associated with the EP type.
331+
*/
332+
virtual std::string GetCompiledModelCompatibilityInfo(const onnxruntime::GraphViewer& graph_viewer) const {
333+
// graph_viewer and model_metadata are not used in the default implementation.
334+
ORT_UNUSED_PARAMETER(graph_viewer);
335+
// Default implementation returns empty string
336+
return std::string();
337+
}
338+
339+
/**
340+
* Validate the compatibility of a compiled model with this execution provider.
341+
*/
342+
virtual common::Status ValidateCompiledModelCompatibilityInfo(const std::string& /*compatibility_info*/,
343+
OrtCompiledModelCompatibility& model_compatibility) const {
344+
// Default implementation indicates this EP does not support model compatibility validation
345+
model_compatibility = OrtCompiledModelCompatibility_EP_NOT_APPLICABLE;
346+
return Status::OK();
347+
}
348+
325349
#endif
326350

327351
void SetLogger(const logging::Logger* logger) {

include/onnxruntime/core/graph/indexed_sub_graph.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct IndexedSubGraph {
3131
std::string domain; ///< Domain of customized SubGraph/FunctionProto
3232
int since_version; ///< Since version of customized SubGraph/FunctionProto.
3333

34-
ONNX_NAMESPACE::OperatorStatus status; ///< Status of customized SubGraph/FunctionProto.
34+
ONNX_NAMESPACE::OperatorStatus status{ONNX_NAMESPACE::OperatorStatus::STABLE}; ///< Status of customized SubGraph/FunctionProto.
3535

3636
std::vector<std::string> inputs; ///< Inputs of customized SubGraph/FunctionProto.
3737
std::vector<std::string> outputs; ///< Outputs of customized SubGraph/FunctionProto.

include/onnxruntime/core/providers/nv_tensorrt_rtx/nv_provider_options.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ constexpr const char* kProfilesMinShapes = "nv_profile_min_shapes";
3232
constexpr const char* kProfilesMaxShapes = "nv_profile_max_shapes";
3333
constexpr const char* kProfilesOptShapes = "nv_profile_opt_shapes";
3434
constexpr const char* kCudaGraphEnable = "nv_cuda_graph_enable";
35-
constexpr const char* kONNXBytestream = "nv_onnx_bytestream";
36-
constexpr const char* kONNXBytestreamSize = "nv_onnx_bytestream_size";
3735
constexpr const char* kMultiProfileEnable = "nv_multi_profile_enable";
36+
constexpr const char* kUseExternalDataInitializer = "nv_use_external_data_initializer";
3837

3938
} // namespace provider_option_names
4039
namespace run_option_names {

include/onnxruntime/core/session/environment.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -199,23 +199,6 @@ class Environment {
199199

200200
using OrtAllocatorUniquePtr = std::unique_ptr<OrtAllocator, std::function<void(OrtAllocator*)>>;
201201

202-
// if the user calls CreateSharedAllocator and wraps the plugin EP's allocator with an arena we end up with
203-
// OrtAllocator from EP -> wrapped in IAllocatorImplWrappingOrtAllocator -> inside a BFCArena IAllocator.
204-
// we can put that in shared_allocators_ for sessions to use, but to have an OrtAllocator available in
205-
// shared_ort_allocators_ that can be used outside of a session we need to additionally wrap that in an
206-
// OrtAllocatorImplWrappingIAllocator. way too many levels of indirection but that is what it is currently.
207-
// we need something to own that final OrtAllocator, so we add it to arena_ort_allocators_.
208-
//
209-
// TODO: we could split out the BFCArena implementation so it can be plugged into either an IAllocator
210-
// or an OrtAllocator instance to reduce the indirection a little.
211-
// with that we get an OrtAllocator from the EP, wrap it with an OrtAllocator based BFCArena, and wrap that with the
212-
// IAllocatorImplWrappingOrtAllocator which takes ownership of the OrtAllocator and is in shared_allocators_.
213-
//
214-
// Alternatively we can disable wrapping an EP's allocator with a BFCArena and say the EP should provide the arena
215-
// implementation directly. They're free to copy BFCArena as it came from TF originally. Or we could provide a
216-
// cut-and-paste BFCArena implementation that works using the EP API that can be included in the EP source.
217-
std::unordered_map<const OrtMemoryInfo*, std::unique_ptr<OrtAllocatorImplWrappingIAllocator>> arena_ort_allocators_;
218-
219202
#if !defined(ORT_MINIMAL_BUILD)
220203
// register EPs that are built into the ORT binary so they can take part in AutoEP selection
221204
// added to ep_libraries

0 commit comments

Comments
 (0)