@@ -547,8 +547,9 @@ def convert_arg_line_to_args(self, arg_line):
547547 type = _openvino_verify_device_type ,
548548 help = "Build with OpenVINO for specific hardware." ,
549549 )
550- parser .add_argument ("--use_openvino_static_libs" , action = "store_true" ,
551- help = "Build with OpenVINO built as Static Library." )
550+ parser .add_argument ("--use_openvino_static_libs" , type = str , default = "" ,
551+ help = "Build with OpenVINO built as Static Library."
552+ "Specify the device(s) to use in the format [CPU,GPU,NPU]" )
552553 parser .add_argument (
553554 "--dnnl_aarch64_runtime" , action = "store" , default = "" , type = str .lower , help = "e.g. --dnnl_aarch64_runtime acl"
554555 )
@@ -1229,10 +1230,9 @@ def generate_build_tree(
12291230
12301231 if args .winml_root_namespace_override :
12311232 cmake_args += ["-Donnxruntime_WINML_NAMESPACE_OVERRIDE=" + args .winml_root_namespace_override ]
1232- if args .use_openvino or args . use_openvino_static_libs :
1233+ if args .use_openvino :
12331234 cmake_args += [
12341235 "-Donnxruntime_USE_OPENVINO=ON" ,
1235- "-Donnxruntime_USE_OPENVINO_STATIC_LIBS=" + ("ON" if args .use_openvino_static_libs else "OFF" ),
12361236 "-Donnxruntime_NPU_NO_FALLBACK=" + ("ON" if args .use_openvino == "NPU_NO_CPU_FALLBACK" else "OFF" ),
12371237 "-Donnxruntime_USE_OPENVINO_GPU=" + ("ON" if args .use_openvino == "GPU" else "OFF" ),
12381238 "-Donnxruntime_USE_OPENVINO_CPU=" + ("ON" if args .use_openvino == "CPU" else "OFF" ),
@@ -1245,9 +1245,25 @@ def generate_build_tree(
12451245 "-Donnxruntime_USE_OPENVINO_MULTI=" + ("ON" if args .use_openvino .startswith ("MULTI" ) else "OFF" ),
12461246 "-Donnxruntime_USE_OPENVINO_AUTO=" + ("ON" if args .use_openvino .startswith ("AUTO" ) else "OFF" ),
12471247 ]
1248+ if args .use_openvino_static_libs :
1249+ cmake_args += ["-Donnxruntime_USE_OPENVINO_STATIC_LIBS=ON" ]
1250+ devices_str = args .use_openvino_static_libs .strip ('[]' )
1251+ devices = re .split (r',\s*' , devices_str )
1252+
1253+ valid_devices = {'CPU' , 'GPU' , 'NPU' }
1254+ if not all (device in valid_devices for device in devices ):
1255+ raise ValueError ("Invalid device specified. Valid devices are: CPU, GPU, NPU" )
1256+
1257+ for device in devices :
1258+ if device == 'CPU' :
1259+ cmake_args .append ("-Donnxruntime_USE_OPENVINO_CPU_DEVICE=ON" )
1260+ if device == 'GPU' :
1261+ cmake_args .append ("-Donnxruntime_USE_OPENVINO_GPU_DEVICE=ON" )
1262+ if device == 'NPU' :
1263+ cmake_args .append ("-Donnxruntime_USE_OPENVINO_NPU_DEVICE=ON" )
12481264
12491265 # VitisAI and OpenVINO providers currently only support full_protobuf option.
1250- if args .use_full_protobuf or args .use_openvino or args .use_openvino_static_libs or args . use_vitisai or args .gen_doc :
1266+ if args .use_full_protobuf or args .use_openvino or args .use_vitisai or args .gen_doc :
12511267 cmake_args += ["-Donnxruntime_USE_FULL_PROTOBUF=ON" , "-DProtobuf_USE_STATIC_LIBS=ON" ]
12521268
12531269 if args .use_tvm and args .llvm_path is not None :
0 commit comments