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()andpermute()return lazy views of the tensordict instead of tensordicts, andtorch.stack()returns a lazy stack. The mode is off by default, and theLAZY_LEGACY_OPenvironment variable sets it at import. Use it as a context manager or a decorator, or callset_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. Uselazy_stack()to build a lazy stack.- Parameters:
mode (bool) – if
True, turns the legacy lazy mode on, and emits aDeprecationWarning.