Skip to content

Commit 1406fe4

Browse files
committed
CVS-176847 Reshape Input to apply to OVIR models as well
1 parent fa8f464 commit 1406fe4

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

onnxruntime/core/providers/openvino/backend_manager.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ BackendManager::BackendManager(SessionContext& session_context,
9696
ptr_stream_t model_stream;
9797
std::unique_ptr<onnx::ModelProto> model_proto;
9898
if (subgraph_context_.is_ep_ctx_graph) {
99-
if (!session_context_.reshape.empty()) {
99+
if (!session_context_.reshape.empty() && !subgraph_context_.is_ep_ctx_ovir_encapsulated) {
100100
std::string exception_str =
101101
"[OpenVINO-EP] Bounded dynamic model execution using provider option reshape_input is not supported for OVEP EPContext model";
102102
ORT_THROW(exception_str);

onnxruntime/core/providers/openvino/backends/basic_backend.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ BasicBackend::BasicBackend(std::unique_ptr<ONNX_NAMESPACE::ModelProto>& model_pr
6363
hw_target,
6464
device_config,
6565
enable_causallm,
66-
model_file_path());
66+
model_file_path(),
67+
session_context_);
6768
} else {
6869
// If the blob is held in an EPContext node, then skip FE+Compile
6970
// and directly move on to creating a backend with the executable blob

onnxruntime/core/providers/openvino/ov_interface.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ OVExeNetwork OVCore::ImportEPCtxOVIREncapsulation(std::istream& model_stream,
226226
std::string& hw_target,
227227
const ov::AnyMap& device_config,
228228
bool enable_causallm,
229-
std::filesystem::path model_file_path) {
229+
std::filesystem::path model_file_path,
230+
const SessionContext& session_context) {
230231
return OvExceptionBoundary<false>([&]() {
231232
OVExeNetwork exe;
232233

@@ -259,6 +260,11 @@ OVExeNetwork OVCore::ImportEPCtxOVIREncapsulation(std::istream& model_stream,
259260
// Load the model explicitly with XML contents
260261
std::shared_ptr<ov::Model> model = core.read_model(xml_file_path.string());
261262

263+
if (!session_context.reshape.empty()) {
264+
LOGS_DEFAULT(INFO) << log_tag << "Reshaping OV-IR model to specified shape";
265+
model->reshape(session_context.reshape);
266+
}
267+
262268
if (enable_causallm) {
263269
exe = OVCore::Get()->StatefulCompileModel(model, hw_target, device_config);
264270
} else {

onnxruntime/core/providers/openvino/ov_interface.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class OVCore;
3939
class OVInferRequest;
4040
class OVExeNetwork;
4141
struct ModelBlobWrapper;
42+
struct SessionContext;
4243

4344
typedef ov::Tensor OVTensor;
4445
typedef ov::ProfilingInfo OVProfilingInfo;
@@ -77,7 +78,8 @@ struct OVCore : WeakSingleton<OVCore> {
7778
std::string& hw_target,
7879
const ov::AnyMap& device_config,
7980
bool enable_causallm,
80-
std::filesystem::path model_file_path);
81+
std::filesystem::path model_file_path,
82+
const SessionContext& session_context);
8183

8284
std::vector<std::string> GetAvailableDevices() const;
8385
std::vector<std::string> GetAvailableDevices(const std::string& device_type) const;

0 commit comments

Comments
 (0)