diff --git a/onnxruntime/core/providers/openvino/openvino_provider_factory.cc b/onnxruntime/core/providers/openvino/openvino_provider_factory.cc index cd82367b71a49..3929e83f56757 100644 --- a/onnxruntime/core/providers/openvino/openvino_provider_factory.cc +++ b/onnxruntime/core/providers/openvino/openvino_provider_factory.cc @@ -374,13 +374,12 @@ static void ParseProviderInfo(const ProviderOptions& provider_options, } // Should likely account for meta devices as well, but for now keep the current behavior. - bool target_devices_support_dynamic_shapes = - pi.device_type.find("GPU") != std::string::npos || - pi.device_type.find("CPU") != std::string::npos || - (pi.device_type.find("NPU") != std::string::npos && - pi.enable_causallm); - - pi.disable_dynamic_shapes = !target_devices_support_dynamic_shapes; + // Respect the user-provided option for CPU/GPU. For NPU, keep the existing constraint: + const bool is_npu_device = pi.device_type.find("NPU") != std::string::npos; + if (is_npu_device && pi.enable_causallm && pi.disable_dynamic_shapes) { + LOGS_DEFAULT(WARNING) << "Enabling dynamic shapes for NPU because CausalLM is enabled."; + pi.disable_dynamic_shapes = false; + } } struct OpenVINOProviderFactory : IExecutionProviderFactory {