Skip to content

Commit 2487432

Browse files
EPCtx changes for dynamic model with reshape_input provider optional
1. Throw an ErrorMessage when user provide reshape_input with EPctx graph. 2. Do not Create dynamic_backend for EPctx graph. Update onnxruntime/core/providers/openvino/backend_manager.cc Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 6d04a2e commit 2487432

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

onnxruntime/core/providers/openvino/backend_manager.cc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ BackendManager::BackendManager(SessionContext& session_context,
8484
ptr_stream_t model_stream;
8585
std::unique_ptr<onnx::ModelProto> model_proto;
8686
if (subgraph_context_.is_ep_ctx_graph) {
87+
if (!session_context_.reshape.empty()) {
88+
std::string exception_str =
89+
"[OpenVINO-EP] reshape_input is not supported for EPContext graph";
90+
ORT_THROW(exception_str);
91+
}
8792
model_stream = ep_ctx_handle_.GetModelBlobStream(session_context_.so_context_file_path, subgraph);
8893
} else {
8994
model_proto = GetModelProtoFromFusedNode(fused_node, subgraph, logger);
@@ -126,6 +131,21 @@ BackendManager::BackendManager(SessionContext& session_context,
126131
LOGS_DEFAULT(INFO) << "[OpenVINO-EP] "
127132
<< "Backend created for graph " << subgraph_context_.subgraph_name;
128133
} else {
134+
// Do not create dynamic backend for EPCtx graph
135+
if (subgraph_context_.is_ep_ctx_graph) {
136+
LOGS_DEFAULT(INFO) << "[OpenVINO-EP] Starting backend initialization. "
137+
<< "Initializing backend for EPContext graph "
138+
<< subgraph_context_.subgraph_name;
139+
try {
140+
concrete_backend_ = BackendFactory::MakeBackend(model_proto,
141+
session_context_,
142+
subgraph_context_,
143+
shared_context_,
144+
model_stream);
145+
} catch (std::string const& msg) {
146+
ORT_THROW(msg);
147+
}
148+
}
129149
// Only cache model_proto in session context to rewrite the model with input shapes at runtime.
130150
// For dynamic backend creation
131151
model_proto_ = std::move(model_proto);
@@ -591,7 +611,7 @@ void BackendManager::Compute(OrtKernelContext* context) {
591611
// by rewriting the model to static shaped model at runtime based on input shape.
592612
// disable_dynamic_shapes should be set for devices that don't support dynamic shapes.
593613
bool need_dynamic_backend = subgraph_context_.has_dynamic_input_shape &&
594-
session_context_.disable_dynamic_shapes;
614+
session_context_.disable_dynamic_shapes && !subgraph_context_.is_ep_ctx_graph;
595615

596616
if (!need_dynamic_backend) {
597617
concrete_backend_->Infer(context);

0 commit comments

Comments
 (0)