[docs]classautocast(torch.amp.autocast_mode.autocast):r""" See :class:`torch.autocast`. ``torch.cpu.amp.autocast(args...)`` is equivalent to ``torch.autocast("cpu", args...)`` """def__init__(self,enabled:bool=True,dtype:torch.dtype=torch.bfloat16,cache_enabled:bool=True,):iftorch._jit_internal.is_scripting():self._enabled=enabledself.device="cpu"self.fast_dtype=dtypereturnsuper().__init__("cpu",enabled=enabled,dtype=dtype,cache_enabled=cache_enabled)def__enter__(self):iftorch._jit_internal.is_scripting():returnselfreturnsuper().__enter__()# TODO: discuss a unified TorchScript-friendly API for autocastdef__exit__(self,exc_type:Any,exc_val:Any,exc_tb:Any):# type: ignore[override]iftorch._jit_internal.is_scripting():returnreturnsuper().__exit__(exc_type,exc_val,exc_tb)def__call__(self,func):iftorch._jit_internal.is_scripting():returnfuncreturnsuper().__call__(func)
Docs
Access comprehensive developer documentation for PyTorch
To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.