fix torch_dtype check of export_model

This commit is contained in:
fenglui 2024-01-21 05:01:53 +08:00
parent a0d59aa4ec
commit f7c5b2d105
1 changed files with 1 additions and 1 deletions

View File

@ -57,7 +57,7 @@ def export_model(args: Optional[Dict[str, Any]] = None):
raise ValueError("The model is not a `PreTrainedModel`, export aborted.") raise ValueError("The model is not a `PreTrainedModel`, export aborted.")
setattr(model.config, "use_cache", True) setattr(model.config, "use_cache", True)
if getattr(model.config, "torch_dtype", None) == "bfloat16": if getattr(model.config, "torch_dtype", None) == torch.bfloat16:
model = model.to(torch.bfloat16).to("cpu") model = model.to(torch.bfloat16).to("cpu")
else: else:
model = model.to(torch.float16).to("cpu") model = model.to(torch.float16).to("cpu")