Rate this Page
★ ★ ★ ★ ★

set_lazy_legacy#

class tensordict.set_lazy_legacy(mode: bool)#

Turns the legacy lazy mode on or off.

In the legacy lazy mode, unsqueeze(), squeeze(), view(), transpose() and permute() return lazy views of the tensordict instead of tensordicts, and torch.stack() returns a lazy stack. The mode is off by default, and the LAZY_LEGACY_OP environment variable sets it at import. Use it as a context manager or a decorator, or call set_lazy_legacy(mode).set() to change the mode for the rest of the program.

Deprecated since version 0.15: The legacy lazy mode (set_lazy_legacy(True)) is deprecated and will be removed in TensorDict 0.17. set_lazy_legacy(False) will then do nothing. Use lazy_stack() to build a lazy stack.

Parameters:

mode (bool) – if True, turns the legacy lazy mode on, and emits a DeprecationWarning.