didn't exist in pt-1.9 (#17644)

This commit is contained in:
Stas Bekman 2022-06-09 16:01:01 -07:00 committed by GitHub
parent fba0b6a820
commit df1ec6b122
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -305,7 +305,10 @@ def is_torch_bf16_available():
is_torch_gpu_bf16_available = False
# checking CPU
if not hasattr(torch.cpu.amp, "autocast"):
try:
# multiple levels of AttributeError depending on the pytorch version so do them all in one check
_ = torch.cpu.amp.autocast
except AttributeError:
is_torch_cpu_bf16_available = False
return is_torch_cpu_bf16_available or is_torch_gpu_bf16_available