Skip to content

Commit 1e8d394

Browse files
committed
Address review comment: Remove duplicate NPU fallback logic
Per MayureshV1's review comment, the NPU->CPU fallback logic was moved to basic_backend.cc in PR #723. This commit removes the duplicate implementation from backend_manager.cc constructor to avoid conflicts and maintain single responsibility.
1 parent 49fe713 commit 1e8d394

File tree

1 file changed

+5
-33
lines changed

1 file changed

+5
-33
lines changed

onnxruntime/core/providers/openvino/backend_manager.cc

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -159,39 +159,11 @@ BackendManager::BackendManager(SessionContext& session_context,
159159
subgraph_context_.has_dynamic_input_shape = false;
160160

161161
// OV NPU plugin is supported with fallback to OV CPU upon compilation failures.
162-
try {
163-
concrete_backend_ = BackendFactory::MakeBackend(model_proto,
164-
session_context_,
165-
subgraph_context_,
166-
shared_context_,
167-
model_stream);
168-
} catch (const ovep_exception& ex) {
169-
#ifndef OPENVINO_DISABLE_NPU_FALLBACK
170-
bool eligible_for_cpu_fallback = session_context_.device_type.find("NPU") != std::string::npos &&
171-
!session_context_.so_disable_cpu_ep_fallback &&
172-
!subgraph_context_.is_ep_ctx_graph;
173-
if (eligible_for_cpu_fallback) {
174-
std::string exception_str = ex.what();
175-
LOGS_DEFAULT(VERBOSE) << exception_str;
176-
LOGS_DEFAULT(WARNING) << "Model compilation failed at OV NPU."
177-
<< "Falling back to OV CPU for execution";
178-
session_context_.device_type = "CPU";
179-
session_context_.precision = "FP32";
180-
try {
181-
concrete_backend_ = BackendFactory::MakeBackend(model_proto,
182-
session_context_,
183-
subgraph_context_,
184-
shared_context_,
185-
model_stream);
186-
} catch (std::string const& msg) {
187-
ORT_THROW(msg);
188-
}
189-
} else
190-
#endif
191-
{
192-
throw ex;
193-
}
194-
}
162+
concrete_backend_ = BackendFactory::MakeBackend(model_proto,
163+
session_context_,
164+
subgraph_context_,
165+
shared_context_,
166+
model_stream);
195167
}
196168
if (session_context_.so_context_enable &&
197169
(subgraph_context_.is_ep_ctx_ovir_encapsulated || !subgraph_context_.is_ep_ctx_graph)) {

0 commit comments

Comments
 (0)