torch.is_inference_mode_enabled
function is_inference_mode_enabled(): booleanChecks if inference mode is enabled.
Inference mode disables gradient computation and view tracking to improve performance during inference. It's less strict than no_grad() but still prevents unintended gradient accumulation.
In torch.js, use
no_grad or inference_mode context managers to disable gradients. The enabled state is not globally tracked.Returns
boolean– Always false in torch.js (inference mode not separately tracked)Examples
// Check inference mode status
const enabled = torch.is_inference_mode_enabled();
// torch.js: always falseSee Also
- PyTorch torch.is_inference_mode_enabled()
- inference_mode - Context manager for inference mode
- no_grad - Context manager to disable gradients