@@ -547,8 +547,9 @@ def convert_arg_line_to_args(self, arg_line):
547
547
type = _openvino_verify_device_type ,
548
548
help = "Build with OpenVINO for specific hardware." ,
549
549
)
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]" )
552
553
parser .add_argument (
553
554
"--dnnl_aarch64_runtime" , action = "store" , default = "" , type = str .lower , help = "e.g. --dnnl_aarch64_runtime acl"
554
555
)
@@ -1229,10 +1230,9 @@ def generate_build_tree(
1229
1230
1230
1231
if args .winml_root_namespace_override :
1231
1232
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 :
1233
1234
cmake_args += [
1234
1235
"-Donnxruntime_USE_OPENVINO=ON" ,
1235
- "-Donnxruntime_USE_OPENVINO_STATIC_LIBS=" + ("ON" if args .use_openvino_static_libs else "OFF" ),
1236
1236
"-Donnxruntime_NPU_NO_FALLBACK=" + ("ON" if args .use_openvino == "NPU_NO_CPU_FALLBACK" else "OFF" ),
1237
1237
"-Donnxruntime_USE_OPENVINO_GPU=" + ("ON" if args .use_openvino == "GPU" else "OFF" ),
1238
1238
"-Donnxruntime_USE_OPENVINO_CPU=" + ("ON" if args .use_openvino == "CPU" else "OFF" ),
@@ -1245,9 +1245,25 @@ def generate_build_tree(
1245
1245
"-Donnxruntime_USE_OPENVINO_MULTI=" + ("ON" if args .use_openvino .startswith ("MULTI" ) else "OFF" ),
1246
1246
"-Donnxruntime_USE_OPENVINO_AUTO=" + ("ON" if args .use_openvino .startswith ("AUTO" ) else "OFF" ),
1247
1247
]
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" )
1248
1264
1249
1265
# 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 :
1251
1267
cmake_args += ["-Donnxruntime_USE_FULL_PROTOBUF=ON" , "-DProtobuf_USE_STATIC_LIBS=ON" ]
1252
1268
1253
1269
if args .use_tvm and args .llvm_path is not None :
0 commit comments