fn
is_grad_enabled
→boolis_grad_enabled()Return whether autograd gradient tracking is currently enabled.
Reports the current state of the process-wide flag that
no_grad, enable_grad, and
set_grad_enabled mutate. The result reflects whether
subsequent ops will register autograd nodes.
Parameters
NoneNo description.
Returns
boolTrue if gradient tracking is enabled (the default
outside any no_grad scope); False otherwise.
Notes
The flag is the same Boolean queried by the C++ engine at op construction time — the result is therefore guaranteed consistent with the actual behaviour of the next op.
Examples
>>> import lucid
>>> from lucid.autograd import no_grad, is_grad_enabled
>>> is_grad_enabled()
True
>>> with no_grad():
... is_grad_enabled()
False