Skip to content
fn

is_inference_mode_enabled

→bool
is_inference_mode_enabled()

Return whether inference mode is active on the calling thread.

Reports the flag that inference_mode toggles. It is independent of is_grad_enabled: inference_mode(False) clears this flag and turns gradient tracking back on, while set_grad_enabled never touches it.

Returns

bool

True inside an inference_mode(True) scope, False otherwise.

Examples

>>> import lucid
>>> lucid.is_inference_mode_enabled()
False
>>> with lucid.inference_mode():
...     lucid.is_inference_mode_enabled()
True

Used by 2