File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -262,8 +262,9 @@ def run(self):
262262 if self .args .weight_format is None :
263263 ov_config = None
264264 if not no_compression_parameter_provided (self .args ):
265- logger .warning (
266- "The provided compression parameters will not affect conversion because of the missing --weight-format argument."
265+ raise ValueError (
266+ "Some compression parameters are provided, but the weight format is not specified. "
267+ "Please provide it with --weight-format argument."
267268 )
268269 elif self .args .weight_format in {"fp16" , "fp32" }:
269270 ov_config = OVConfig (dtype = self .args .weight_format )
Original file line number Diff line number Diff line change @@ -384,3 +384,20 @@ def test_exporters_cli_open_clip(self):
384384 model = eval (_HEAD_TO_AUTOMODELS ["open_clip" ]).from_pretrained (tmpdir , compile = False )
385385 self .assertTrue ("text_features" in model .text_model .output_names )
386386 self .assertTrue ("image_features" in model .visual_model .output_names )
387+
388+ def test_export_openvino_with_missed_weight_format (self ):
389+ # Test that exception is raised when some compression parameter is given, but weight format is not.
390+ with TemporaryDirectory () as tmpdir :
391+ with self .assertRaises (subprocess .CalledProcessError ) as exc_info :
392+ subprocess .run (
393+ f"optimum-cli export openvino --model { MODEL_NAMES ['gpt2' ]} --task text-generation --sym { tmpdir } " ,
394+ shell = True ,
395+ check = True ,
396+ stdout = subprocess .PIPE ,
397+ stderr = subprocess .PIPE ,
398+ text = True ,
399+ )
400+ self .assertIn (
401+ "Some compression parameters are provided, but the weight format is not specified." ,
402+ str (exc_info .exception .stderr ),
403+ )
You can’t perform that action at this time.
0 commit comments