File tree Expand file tree Collapse file tree 5 files changed +20
-9
lines changed
onnxruntime/core/providers/openvino Expand file tree Collapse file tree 5 files changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -28,9 +28,10 @@ SessionContext& BackendManager::GetSessionContext() {
2828 return session_context_;
2929}
3030
31- ov::CompiledModel& BackendManager::GetOVCompiledModel () {
32- ov::CompiledModel& ov_ptr = concrete_backend_->GetOVCompiledModel ();
33- return (ov_ptr);
31+ ov::CompiledModel BackendManager::GetOVCompiledModel () {
32+ if (concrete_backend_)
33+ return concrete_backend_->GetOVCompiledModel ();
34+ return ov::CompiledModel ();
3435}
3536
3637BackendManager::BackendManager (SessionContext& session_context,
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ class BackendManager {
2929 void ShutdownBackendManager ();
3030 SessionContext& GetSessionContext ();
3131 Status ExportCompiledBlobAsEPCtxNode (const onnxruntime::GraphViewer& subgraph);
32- ov::CompiledModel& GetOVCompiledModel ();
32+ ov::CompiledModel GetOVCompiledModel ();
3333
3434 private:
3535 std::unique_ptr<ONNX_NAMESPACE::ModelProto> GetModelProtoFromFusedNode (
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ class BasicBackend : public IBackend {
8282
8383 void Infer (OrtKernelContext* context) override ;
8484 ~BasicBackend () override = default ;
85- ov::CompiledModel& GetOVCompiledModel () override {
85+ ov::CompiledModel GetOVCompiledModel () override {
8686 return exe_network_.Get ();
8787 }
8888
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ namespace openvino_ep {
1515class IBackend {
1616 public:
1717 virtual void Infer (OrtKernelContext* context) = 0;
18- virtual ov::CompiledModel& GetOVCompiledModel () = 0;
18+ virtual ov::CompiledModel GetOVCompiledModel () = 0;
1919 virtual ~IBackend () = default ;
2020};
2121using ptr_stream_t = std::unique_ptr<std::istream>;
Original file line number Diff line number Diff line change @@ -238,10 +238,20 @@ common::Status OpenVINOExecutionProvider::SetEpDynamicOptions(gsl::span<const ch
238238 LOGS_DEFAULT (WARNING) << " Supported types are 'Efficient' and 'Default' \n " ;
239239 }
240240 if (workload_type != " " ) {
241- LOGS_DEFAULT (INFO ) << " SetEpDynamicOptions - modifying: " << key << " /" << value;
241+ LOGS_DEFAULT (VERBOSE ) << " SetEpDynamicOptions - modifying: " << key << " /" << value;
242242 for (auto & backend : backend_managers_) {
243- ov::CompiledModel& ov_compiled_model = backend.GetOVCompiledModel ();
244- ov_compiled_model.set_property (ov::workload_type (workload_type));
243+ ov::CompiledModel ov_compiled_model = backend.GetOVCompiledModel ();
244+ if (ov_compiled_model) {
245+ ov_compiled_model.set_property (ov::workload_type (workload_type));
246+ } else {
247+ LOGS_DEFAULT (VERBOSE) << " Model is not compiled in OV as its dynamic" ;
248+ ov::AnyMap map;
249+ map[" WORKLOAD_TYPE" ] = workload_type;
250+ if (session_context_.device_type == " NPU" )
251+ session_context_.load_config [" NPU" ] = std::move (map);
252+ else
253+ ORT_THROW (" WORKLOAD_TYPE property is supported only for NPU" );
254+ }
245255 }
246256 }
247257 } else {
You can’t perform that action at this time.
0 commit comments