@@ -44,6 +44,10 @@ BackendManager::BackendManager(SessionContext& session_context,
4444 shared_context_{shared_context} {
4545 subgraph_context_.is_ep_ctx_graph = ep_ctx_handle_.CheckForOVEPCtxNodeInGraph (subgraph);
4646
47+ bool cpu_or_gpu = session_context_.device_type .find (" CPU" ) != std::string::npos ||
48+ session_context_.device_type .find (" GPU" ) != std::string::npos;
49+ bool npu = session_context_.device_type .find (" NPU" ) != std::string::npos;
50+
4751 subgraph_context_.model_precision = [&](const GraphViewer& graph_viewer) {
4852 // return empty if graph has no inputs or if types are not one of FP32/FP16
4953 // else assume the type of the first input
@@ -105,9 +109,7 @@ BackendManager::BackendManager(SessionContext& session_context,
105109 if (ModelHasSymbolicInputDims (subgraph)) {
106110 subgraph_context_.has_dynamic_input_shape = true ;
107111 LOGS_DEFAULT (INFO) << " [OpenVINO-EP] Model has symbolic input dims" ;
108- if ((session_context_.device_type .find (" CPU" ) != std::string::npos ||
109- session_context_.device_type .find (" GPU" ) != std::string::npos ||
110- (session_context_.device_type .find (" NPU" ) != std::string::npos && session_context_.enable_causallm )) &&
112+ if (cpu_or_gpu || (npu && session_context_.enable_causallm ) &&
111113 !session_context_.disable_dynamic_shapes ) {
112114 LOGS_DEFAULT (INFO) << " [OpenVINO-EP] Starting backend initialization. "
113115 << " Creating backend Dynamic Shapes" ;
@@ -481,6 +483,9 @@ BackendManager::ReWriteBatchDimWithOne(const ONNX_NAMESPACE::ModelProto& model_p
481483void BackendManager::Compute (OrtKernelContext* context) {
482484 Ort::KernelContext ctx (context);
483485 std::chrono::high_resolution_clock::time_point start_compute, end_compute;
486+ bool cpu_or_gpu = session_context_.device_type .find (" CPU" ) != std::string::npos ||
487+ session_context_.device_type .find (" GPU" ) != std::string::npos;
488+ bool npu = session_context_.device_type .find (" NPU" ) != std::string::npos;
484489#ifdef OPENVINO_FIL_ENABLED
485490 static bool fil_enabled = true ;
486491 if (fil_enabled) {
@@ -494,10 +499,7 @@ void BackendManager::Compute(OrtKernelContext* context) {
494499 // disable_dynamic_shapes is always set to true for OV NPU plugin.
495500 if (subgraph_context_.has_dynamic_input_shape &&
496501 !session_context_.disable_dynamic_shapes &&
497- (session_context_.device_type .find (" CPU" ) != std::string::npos ||
498- session_context_.device_type .find (" GPU" ) != std::string::npos ||
499- (session_context_.device_type .find (" NPU" ) != std::string::npos &&
500- session_context_.enable_causallm ))) {
502+ (cpu_or_gpu || (npu && session_context_.enable_causallm ))) {
501503 concrete_backend_->Infer (context);
502504 } else if (subgraph_context_.has_dynamic_input_shape ) {
503505 std::vector<std::vector<int64_t >> tensor_shapes = GetInputTensorShapes (ctx);
0 commit comments