Skip to content

Commit 415ff40

Browse files
committed
minor updates
1 parent 861a457 commit 415ff40

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

optimum/exporters/onnx/__main__.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -415,14 +415,17 @@ def main_export(
415415
and getattr(model.config, "pad_token_id", None) is None
416416
)
417417

418-
if needs_pad_token_id and pad_token_id is None:
419-
tok = AutoTokenizer.from_pretrained(model_name_or_path)
420-
pad_token_id = getattr(tok, "pad_token_id", None)
421-
if pad_token_id is None:
422-
raise ValueError(
423-
"Could not infer the pad token id, which is needed in this case, please provide it with the --pad_token_id argument"
424-
)
425-
model.config.pad_token_id = pad_token_id
418+
if needs_pad_token_id:
419+
if pad_token_id is not None:
420+
model.config.pad_token_id = pad_token_id
421+
else:
422+
tok = AutoTokenizer.from_pretrained(model_name_or_path)
423+
pad_token_id = getattr(tok, "pad_token_id", None)
424+
if pad_token_id is None:
425+
raise ValueError(
426+
"Could not infer the pad token id, which is needed in this case, please provide it with the --pad_token_id argument"
427+
)
428+
model.config.pad_token_id = pad_token_id
426429

427430
if "stable-diffusion" in task:
428431
model_type = "stable-diffusion"

0 commit comments

Comments
 (0)