Skip to content

Commit b685871

Browse files
authored
When dynamic shapes are used the proto might be overriden and offsets from initializers might become invalid (#828)
Signed-off-by: bfilipek <[email protected]>
1 parent 2652479 commit b685871

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

onnxruntime/core/providers/openvino/backend_manager.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ BackendManager::BackendManager(SessionContext& session_context,
8383

8484
subgraph_context_.subgraph_name = fused_node.Name();
8585

86+
if (ModelHasSymbolicInputDims(subgraph)) {
87+
subgraph_context_.has_dynamic_input_shape = true;
88+
}
89+
8690
ptr_stream_t model_stream;
8791
std::unique_ptr<onnx::ModelProto> model_proto;
8892
if (subgraph_context_.is_ep_ctx_graph) {
@@ -119,8 +123,7 @@ BackendManager::BackendManager(SessionContext& session_context,
119123
backend_utils::CreateOVTensors(session_context_.device_type, sw.metadata, *sw.mapped_weights);
120124
}
121125

122-
if (ModelHasSymbolicInputDims(subgraph)) {
123-
subgraph_context_.has_dynamic_input_shape = true;
126+
if (subgraph_context_.has_dynamic_input_shape) {
124127
LOGS_DEFAULT(INFO) << "[OpenVINO-EP] Model has symbolic input dims";
125128
if ((!session_context_.disable_dynamic_shapes &&
126129
(session_context_.device_type.find("CPU") != std::string::npos ||
@@ -609,7 +612,7 @@ BackendManager::GetModelProtoFromFusedNode(const onnxruntime::Node& fused_node,
609612
std::unordered_map<std::string, std::pair<size_t, size_t>> external_initializers_offset_and_length;
610613
std::string tempLocation;
611614
size_t extInitializerTotalSize = 0;
612-
if (session_context_.has_external_weights) {
615+
if (session_context_.has_external_weights && !subgraph_context_.has_dynamic_input_shape) {
613616
auto allInitializers = subgraph.GetAllInitializedTensors();
614617
for (auto& [name, tp] : allInitializers) {
615618
if (utils::HasExternalDataInMemory(*tp)) {

0 commit comments

Comments
 (0)