Skip to content

Commit fec6e49

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 7f86fad commit fec6e49

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

onnxruntime/core/providers/openvino/backend_manager.cc

Lines changed: 10 additions & 2 deletions
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] Bounded dynamic model execution using provider option reshape_input is not supported for OVEP EPContext model";
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);
@@ -110,7 +115,10 @@ BackendManager::BackendManager(SessionContext& session_context,
110115
if (ModelHasSymbolicInputDims(subgraph)) {
111116
subgraph_context_.has_dynamic_input_shape = true;
112117
LOGS_DEFAULT(INFO) << "[OpenVINO-EP] Model has symbolic input dims";
113-
if (!session_context_.disable_dynamic_shapes) {
118+
if ((!session_context_.disable_dynamic_shapes &&
119+
(session_context_.device_type.find("CPU") != std::string::npos ||
120+
session_context_.device_type.find("GPU") != std::string::npos)) ||
121+
(subgraph_context_.is_ep_ctx_graph)) {
114122
LOGS_DEFAULT(INFO) << "[OpenVINO-EP] Starting backend initialization. "
115123
<< "Creating backend Dynamic Shapes";
116124
try {
@@ -590,7 +598,7 @@ void BackendManager::Compute(OrtKernelContext* context) {
590598
// by rewriting the model to static shaped model at runtime based on input shape.
591599
// disable_dynamic_shapes should be set for devices that don't support dynamic shapes.
592600
bool need_dynamic_backend = subgraph_context_.has_dynamic_input_shape &&
593-
session_context_.disable_dynamic_shapes;
601+
session_context_.disable_dynamic_shapes && !subgraph_context_.is_ep_ctx_graph;
594602

595603
if (!need_dynamic_backend) {
596604
concrete_backend_->Infer(context);

0 commit comments

Comments
 (0)