inference_mode
- class torch.autograd.grad_mode.inference_mode(mode=True)
Context manager that enables or disables inference mode.
InferenceMode is analogous to
no_gradand should be used when you are certain your operations will not interact with autograd (e.g., during data loading or model evaluation). Compared to , it removes additional overhead by disabling view tracking and version counter bumps. It is also more restrictive, in that tensors created in this mode cannot be used in computations recorded by autograd.