Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions torchbenchmark/util/extra_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ def check_precision(
if precision == "bypass":
return True
if precision == "fp16":
return model.device == "cuda" and hasattr(model, "enable_fp16")
return model.device == "cuda" or model.device == "xpu" and hasattr(model, "enable_fp16")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return model.device == "cuda" or model.device == "xpu" and hasattr(model, "enable_fp16")
return model.device in ["cuda", "xpu"] and hasattr(model, "enable_fp16")

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

if precision == "tf32":
return model.device == "cuda"
return model.device == "cuda" or model.device == "xpu"
if precision == "amp":
return True
if precision == "fx_int8":
return model.device == "cpu" and hasattr(model, "enable_fx_int8")
if precision == "bf16":
return True
if precision == "amp_fp16":
if model.test == "eval" and model.device == "cuda":
if model.test == "eval" and (model.device == "cuda" or model.device == "xpu"):
return True
if model.test == "train" and model.device == "cuda":
if model.test == "train" and (model.device == "cuda" or model.device == "xpu"):
return hasattr(model, "enable_amp") or is_staged_train_test(model)
if precision == "amp_bf16":
if model.test == "eval" and model.device == "cpu":
Expand Down Expand Up @@ -87,13 +87,13 @@ def get_precision_default(model: "torchbenchmark.util.model.BenchmarkModel") ->
if (
hasattr(model, "DEFAULT_EVAL_CUDA_PRECISION")
and model.test == "eval"
and model.device == "cuda"
and (model.device == "cuda" or model.device == "xpu")
):
return model.DEFAULT_EVAL_CUDA_PRECISION
if (
hasattr(model, "DEFAULT_TRAIN_CUDA_PRECISION")
and model.test == "train"
and model.device == "cuda"
and (model.device == "cuda" or model.device == "xpu")
):
return model.DEFAULT_TRAIN_CUDA_PRECISION
if hasattr(model, "DEFAULT_PRECISION"):
Expand Down