Skip to content

Commit e1b2c28

Browse files
authored
Merge pull request #757 from intel/sync_msft_23_7_25
Backmerging with msft commits
2 parents a90ebe5 + 01c762b commit e1b2c28

File tree

74 files changed

+3413
-445
lines changed

Some content is hidden

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

74 files changed

+3413
-445
lines changed

.github/workflows/linux-wasm-ci-build-and-test-workflow.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,6 @@ jobs:
5050
with:
5151
node-version: "22"
5252

53-
# The image used in this workflow has an old version of Node.js installed at /bin/node and npm at /bin/npm.
54-
# We need to remove the system Node.js and npm, otherwise CMake will not be able to find the correct Node.js and npm executables.
55-
- name: Remove the system Node.js
56-
run: |
57-
if [ -f /bin/node ]; then
58-
rm /bin/node
59-
fi
60-
if [ -f /bin/npm ]; then
61-
rm /bin/npm
62-
fi
63-
6453
- name: Set up Python
6554
uses: actions/setup-python@v5
6655
with:

cmake/Info.plist.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
<string>????</string>
1717
<key>CFBundlePackageType</key>
1818
<string>FMWK</string>
19-
</dict>
19+
<key>MinimumOSVersion</key>
20+
<string>@CMAKE_OSX_DEPLOYMENT_TARGET@</string></dict>
2021
</plist>

cmake/node_helper.cmake

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
cmake_minimum_required(VERSION 3.25)
5+
6+
# Function to get NPM path from Node.js path
7+
function(get_npm_path_from_node result_var node_path)
8+
get_filename_component(NODE_DIR ${node_path} DIRECTORY)
9+
if(WIN32)
10+
set(NPM_CLI_CANDIDATE "${NODE_DIR}/npm.cmd")
11+
if(NOT EXISTS ${NPM_CLI_CANDIDATE})
12+
set(NPM_CLI_CANDIDATE "${NODE_DIR}/npm")
13+
endif()
14+
else()
15+
set(NPM_CLI_CANDIDATE "${NODE_DIR}/npm")
16+
endif()
17+
18+
set(${result_var} ${NPM_CLI_CANDIDATE} PARENT_SCOPE)
19+
endfunction()
20+
21+
# Validator function for Node.js installation (checks both Node.js and NPM versions)
22+
function(validate_nodejs_installation result_var node_path)
23+
# First validate Node.js version
24+
execute_process(
25+
COMMAND ${node_path} --version
26+
OUTPUT_VARIABLE NODE_VERSION_OUTPUT
27+
ERROR_VARIABLE NODE_VERSION_ERROR
28+
RESULT_VARIABLE NODE_VERSION_RESULT
29+
OUTPUT_STRIP_TRAILING_WHITESPACE
30+
)
31+
32+
if(NODE_VERSION_RESULT EQUAL 0)
33+
# Node version output starts with 'v', e.g., "v20.10.0"
34+
string(REGEX MATCH "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)" NODE_VERSION_MATCH ${NODE_VERSION_OUTPUT})
35+
if(NODE_VERSION_MATCH)
36+
set(NODE_VERSION_MAJOR ${CMAKE_MATCH_1})
37+
38+
if(NODE_VERSION_MAJOR LESS 20)
39+
message(STATUS "Node.js at ${node_path} version ${NODE_VERSION_OUTPUT} is too old. Required: >= v20.0.0")
40+
set(${result_var} FALSE PARENT_SCOPE)
41+
return()
42+
endif()
43+
44+
message(STATUS "Found Node.js at ${node_path} with version: ${NODE_VERSION_OUTPUT}")
45+
else()
46+
message(STATUS "Could not parse Node.js version from ${node_path}: ${NODE_VERSION_OUTPUT}")
47+
set(${result_var} FALSE PARENT_SCOPE)
48+
return()
49+
endif()
50+
else()
51+
message(STATUS "Failed to get Node.js version from ${node_path}: ${NODE_VERSION_ERROR}")
52+
set(${result_var} FALSE PARENT_SCOPE)
53+
return()
54+
endif()
55+
56+
# Now validate NPM from the same installation directory
57+
get_npm_path_from_node(NPM_CLI_CANDIDATE ${node_path})
58+
59+
if(NOT EXISTS ${NPM_CLI_CANDIDATE})
60+
get_filename_component(NODE_DIR ${node_path} DIRECTORY)
61+
message(STATUS "Could not find NPM in the same directory as Node.js: ${NODE_DIR}")
62+
set(${result_var} FALSE PARENT_SCOPE)
63+
return()
64+
endif()
65+
66+
# Validate NPM version
67+
execute_process(
68+
COMMAND ${NPM_CLI_CANDIDATE} --version
69+
OUTPUT_VARIABLE NPM_VERSION_OUTPUT
70+
ERROR_VARIABLE NPM_VERSION_ERROR
71+
RESULT_VARIABLE NPM_VERSION_RESULT
72+
OUTPUT_STRIP_TRAILING_WHITESPACE
73+
)
74+
75+
if(NPM_VERSION_RESULT EQUAL 0)
76+
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)" NPM_VERSION_MATCH ${NPM_VERSION_OUTPUT})
77+
if(NPM_VERSION_MATCH)
78+
set(NPM_VERSION_MAJOR ${CMAKE_MATCH_1})
79+
80+
if(NPM_VERSION_MAJOR LESS 10)
81+
message(STATUS "NPM at ${NPM_CLI_CANDIDATE} version ${NPM_VERSION_OUTPUT} is too old. Required: >= 10.0.0")
82+
set(${result_var} FALSE PARENT_SCOPE)
83+
return()
84+
endif()
85+
86+
message(STATUS "Found NPM at ${NPM_CLI_CANDIDATE} with version: ${NPM_VERSION_OUTPUT}")
87+
set(${result_var} TRUE PARENT_SCOPE)
88+
else()
89+
message(STATUS "Could not parse NPM version from ${NPM_CLI_CANDIDATE}: ${NPM_VERSION_OUTPUT}")
90+
set(${result_var} FALSE PARENT_SCOPE)
91+
endif()
92+
else()
93+
message(STATUS "Failed to get NPM version from ${NPM_CLI_CANDIDATE}: ${NPM_VERSION_ERROR}")
94+
set(${result_var} FALSE PARENT_SCOPE)
95+
endif()
96+
endfunction()
97+
98+
# Check if both Node.js and NPM are already provided
99+
if((NOT NPM_CLI) OR (NOT NODE_EXECUTABLE))
100+
# Find node executable with combined Node.js + NPM validation
101+
find_program(NODE_EXECUTABLE
102+
NAMES "node.exe" "node"
103+
DOC "Node.js executable"
104+
VALIDATOR validate_nodejs_installation
105+
REQUIRED
106+
)
107+
108+
# Set NPM_CLI from the validated Node.js installation
109+
get_npm_path_from_node(NPM_CLI ${NODE_EXECUTABLE})
110+
set(NPM_CLI ${NPM_CLI} CACHE FILEPATH "NPM command line client" FORCE)
111+
message(STATUS "Using Node.js and NPM from the same validated installation:")
112+
message(STATUS " Node.js: ${NODE_EXECUTABLE}")
113+
message(STATUS " NPM: ${NPM_CLI}")
114+
endif()

cmake/onnxruntime_nodejs.cmake

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,8 @@ set(JS_ROOT ${REPO_ROOT}/js)
55
set(JS_COMMON_ROOT ${JS_ROOT}/common)
66
set(JS_NODE_ROOT ${JS_ROOT}/node)
77

8-
find_program(NPM_CLI
9-
NAMES "npm.cmd" "npm"
10-
DOC "NPM command line client"
11-
REQUIRED
12-
)
13-
14-
# verify Node.js and NPM
15-
execute_process(COMMAND node --version
16-
WORKING_DIRECTORY ${JS_NODE_ROOT}
17-
OUTPUT_VARIABLE node_version
18-
RESULT_VARIABLE had_error
19-
OUTPUT_STRIP_TRAILING_WHITESPACE)
20-
if(had_error)
21-
message(FATAL_ERROR "Failed to find Node.js: " ${had_error})
22-
endif()
23-
execute_process(COMMAND ${NPM_CLI} --version
24-
WORKING_DIRECTORY ${JS_NODE_ROOT}
25-
OUTPUT_VARIABLE npm_version
26-
RESULT_VARIABLE had_error
27-
OUTPUT_STRIP_TRAILING_WHITESPACE)
28-
if(had_error)
29-
message(FATAL_ERROR "Failed to find NPM: " ${had_error})
30-
endif()
8+
# Include the Node.js helper for finding and validating Node.js and NPM
9+
include(node_helper.cmake)
3110

3211
# setup ARCH
3312
if (APPLE)

cmake/onnxruntime_providers_vitisai.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_vitisai_cc_srcs})
2222
onnxruntime_add_shared_library(onnxruntime_providers_vitisai ${onnxruntime_providers_vitisai_cc_srcs})
2323
onnxruntime_add_include_to_target(onnxruntime_providers_vitisai ${ONNXRUNTIME_PROVIDERS_SHARED} ${GSL_TARGET} safeint_interface flatbuffers::flatbuffers Boost::mp11)
24-
target_link_libraries(onnxruntime_providers_vitisai PRIVATE ${ONNXRUNTIME_PROVIDERS_SHARED})
24+
target_link_libraries(onnxruntime_providers_vitisai PRIVATE ${ONNXRUNTIME_PROVIDERS_SHARED} ${ABSEIL_LIBS})
2525
if(MSVC)
2626
onnxruntime_add_include_to_target(onnxruntime_providers_vitisai dbghelp)
2727
set_property(TARGET onnxruntime_providers_vitisai APPEND_STRING PROPERTY LINK_FLAGS "-DEF:${ONNXRUNTIME_ROOT}/core/providers/vitisai/symbols.def")

cmake/onnxruntime_providers_webgpu.cmake

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,13 @@
135135
set(WGSL_TEMPLATES_DIR "${ONNXRUNTIME_ROOT}/core/providers/webgpu/wgsl_templates")
136136
set(WGSL_GENERATED_ROOT "${CMAKE_CURRENT_BINARY_DIR}/wgsl_generated")
137137

138-
# Find npm and node executables
139-
find_program(NPM_EXECUTABLE "npm.cmd" "npm" REQUIRED)
140-
if(NOT NPM_EXECUTABLE)
141-
message(FATAL_ERROR "npm is required for WGSL template generation but was not found")
142-
endif()
143-
find_program(NODE_EXECUTABLE "node" REQUIRED)
144-
if (NOT NODE_EXECUTABLE)
145-
message(FATAL_ERROR "Node is required for WGSL template generation but was not found")
146-
endif()
138+
# Include the Node.js helper for finding and validating Node.js and NPM
139+
include(node_helper.cmake)
147140

148141
# Install npm dependencies
149142
add_custom_command(
150143
OUTPUT "${WGSL_TEMPLATES_DIR}/node_modules/.install_complete"
151-
COMMAND ${NPM_EXECUTABLE} ci
144+
COMMAND ${NPM_CLI} ci
152145
COMMAND ${CMAKE_COMMAND} -E touch "${WGSL_TEMPLATES_DIR}/node_modules/.install_complete"
153146
DEPENDS "${WGSL_TEMPLATES_DIR}/package.json" "${WGSL_TEMPLATES_DIR}/package-lock.json"
154147
WORKING_DIRECTORY ${WGSL_TEMPLATES_DIR}
@@ -203,7 +196,7 @@
203196
# Generate WGSL templates
204197
add_custom_command(
205198
OUTPUT ${WGSL_GENERATED_INDEX_H} ${WGSL_GENERATED_INDEX_IMPL_H} ${WGSL_GENERATED_TEMPLATES_JS}
206-
COMMAND ${NPM_EXECUTABLE} run gen -- ${WGSL_GEN_OPTIONS}
199+
COMMAND ${NPM_CLI} run gen -- ${WGSL_GEN_OPTIONS}
207200
DEPENDS "${WGSL_TEMPLATES_DIR}/node_modules/.install_complete" ${WGSL_TEMPLATE_FILES}
208201
WORKING_DIRECTORY ${WGSL_TEMPLATES_DIR}
209202
COMMENT "Generating WGSL templates from *.wgsl.template files"

cmake/onnxruntime_unittests.cmake

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,8 @@ function(AddTest)
198198
# xctest_add_test(xctest.${_UT_TARGET} ${_UT_TARGET}_xc)
199199
else()
200200
if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
201-
# We might have already executed the following "find_program" code when we build ORT nodejs binding.
202-
# Then the program is found the result is stored in the variable and the search will not be repeated.
203-
find_program(NPM_CLI
204-
NAMES "npm.cmd" "npm"
205-
DOC "NPM command line client"
206-
REQUIRED
207-
)
201+
# Include the Node.js helper for finding and validating Node.js and NPM
202+
include(node_helper.cmake)
208203

209204
if (onnxruntime_WEBASSEMBLY_RUN_TESTS_IN_BROWSER)
210205
add_custom_command(TARGET ${_UT_TARGET} POST_BUILD

docs/OperatorKernels.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ Do not modify directly.*
5858
|BitwiseOr|*in* A:**T**<br> *in* B:**T**<br> *out* C:**T**|18+|**T** = tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
5959
|BitwiseXor|*in* A:**T**<br> *in* B:**T**<br> *out* C:**T**|18+|**T** = tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
6060
|BlackmanWindow|*in* size:**T1**<br> *out* output:**T2**|17+|**T1** = tensor(int32), tensor(int64)<br/> **T2** = tensor(double), tensor(float), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
61-
|Cast|*in* input:**T1**<br> *out* output:**T2**|23+|**T1** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)<br/> **T2** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
62-
|||[21, 22]|**T1** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)<br/> **T2** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
63-
|||[19, 20]|**T1** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)<br/> **T2** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
64-
|||[13, 18]|**T1** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)<br/> **T2** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
65-
|||[6, 12]|**T1** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)<br/> **T2** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
61+
|Cast|*in* input:**T1**<br> *out* output:**T2**|23+|**T1** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int4), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint4), tensor(uint64), tensor(uint8)<br/> **T2** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int4), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint4), tensor(uint64), tensor(uint8)|
62+
|||[21, 22]|**T1** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int4), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint4), tensor(uint64), tensor(uint8)<br/> **T2** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int4), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint4), tensor(uint64), tensor(uint8)|
63+
|||[19, 20]|**T1** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int4), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint4), tensor(uint64), tensor(uint8)<br/> **T2** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int4), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint4), tensor(uint64), tensor(uint8)|
64+
|||[13, 18]|**T1** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int4), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint4), tensor(uint64), tensor(uint8)<br/> **T2** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int4), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint4), tensor(uint64), tensor(uint8)|
65+
|||[6, 12]|**T1** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int4), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint4), tensor(uint64), tensor(uint8)<br/> **T2** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int4), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint4), tensor(uint64), tensor(uint8)|
6666
|Ceil|*in* X:**T**<br> *out* Y:**T**|13+|**T** = tensor(double), tensor(float)|
6767
|||[6, 12]|**T** = tensor(double), tensor(float)|
6868
|Celu|*in* X:**T**<br> *out* Y:**T**|12+|**T** = tensor(float)|

include/onnxruntime/core/framework/data_types_internal.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ class CallableDispatchableHelper {
319319
public:
320320
explicit CallableDispatchableHelper(int32_t dt_type) noexcept : dt_type_(dt_type), called_(0) {}
321321

322+
#if defined(_MSC_VER)
323+
#pragma warning(push)
324+
#pragma warning(disable : 4702)
325+
#endif
322326
// Must return integer to be in a expandable context
323327
template <class T, class Fn, class... Args>
324328
int Invoke(Fn&& fn, Args&&... args) {
@@ -328,6 +332,9 @@ class CallableDispatchableHelper {
328332
}
329333
return 0;
330334
}
335+
#if defined(_MSC_VER)
336+
#pragma warning(pop)
337+
#endif
331338

332339
void CheckCalledOnce() const {
333340
ORT_ENFORCE(called_ == 1, "Unsupported data type: ", dt_type_);
@@ -338,7 +345,7 @@ class CallableDispatchableHelper {
338345
// Other policies may set the second result argument accordingly.
339346
template <class Ret>
340347
struct UnsupportedTypeDefaultPolicy {
341-
void operator()(int32_t dt_type, Ret& /*result*/) const {
348+
[[noreturn]] void operator()(int32_t dt_type, Ret& /*result*/) const {
342349
ORT_THROW("Unsupported data type: ", dt_type);
343350
}
344351
};

include/onnxruntime/core/graph/graph.h

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,8 +1198,16 @@ class Graph { // NOLINT(clang-analyzer-optin.performance.Padding): preserve exi
11981198
#endif
11991199

12001200
#if !defined(ORT_MINIMAL_BUILD)
1201-
/** Gets the GraphProto representation of this Graph. */
1201+
/** Gets the GraphProto representation of this Graph only. */
12021202
const ONNX_NAMESPACE::GraphProto& ToGraphProto();
1203+
1204+
/// <summary>
1205+
// This function recurses subgraphs and examines each initializer
1206+
// If initializer data points to in-memory location, it is inlined
1207+
// otherwise, the initializer is copied as is including any
1208+
// external data references.
1209+
/// </summary>
1210+
/// <returns>GraphProto</returns>
12031211
ONNX_NAMESPACE::GraphProto ToGraphProto() const;
12041212

12051213
/** Gets the GraphProto representation of this Graph
@@ -1561,6 +1569,25 @@ class Graph { // NOLINT(clang-analyzer-optin.performance.Padding): preserve exi
15611569
Status AddConstantProtoAsInitializer(const ONNX_NAMESPACE::NodeProto& constant_node_proto,
15621570
std::optional<std::string_view> new_name);
15631571

1572+
/// <summary>
1573+
/// This function is used by ToGraphProto() to ensure in-memory external data references
1574+
/// don't leak externally since they are non-standard.
1575+
///
1576+
/// It handles two scenarios:
1577+
/// - When GraphSynchronizationNeeded() is false: GraphProto is simply copied
1578+
/// from graph_proto_ by ToGraphProto(). This copy includes both main graph
1579+
/// and subgraph initializers. This function examines all initializers
1580+
/// and inlines any in-memory data references.
1581+
/// - When GraphSynchronizationNeeded() is true: ToGraphProto() generates a new GraphProto
1582+
/// using ToGraphProtoInternal(). This doesn't transfer main graph initializers, which are
1583+
/// copied and inlined by ToGraphProto() itself. This function processes only the subgraph initializers
1584+
/// as needed.
1585+
/// </summary>
1586+
/// <param name="output_graph_proto">The GraphProto to process</param>
1587+
/// <param name="process_main">Whether to process the main graph initializers</param>
1588+
/// <returns>Status indicating success or failure</returns> ///
1589+
Status ProcessSubgraphsInMemoryData(ONNX_NAMESPACE::GraphProto& output_graph_proto, bool process_main) const;
1590+
15641591
/// <summary>
15651592
/// This function traverses the graph bottom up and externalizes
15661593
/// constant initializers along with their pre-packed blobs from different

0 commit comments

Comments
 (0)