optimum/graphcore/modeling_utils.py
def recomputation_checkpoint(module: nn.Module):
    """Annotates the output of a module to be checkpointed instead of
    recomputed"""

    def recompute_outputs(module, inputs, outputs):
        if isinstance(outputs, torch.Tensor):
            return poptorch.recomputationCheckpoint(outputs)
        elif isinstance(outputs, tuple):
            return tuple(poptorch.recomputationCheckpoint(y) for y in outputs)

    return module.register_forward_hook(recompute_outputs)
Annotates the output of a module to be checkpointed instead of
    recomputed
Annotates the output of a module to be checkpointed instead of
recomputed
Annotates the output of a module to be checkpointed instead of recomputed
def recomputation_checkpoint(module: nn.Module):
    def recompute_outputs(module, inputs, outputs):
        if isinstance(outputs, torch.Tensor):
            return poptorch.recomputationCheckpoint(outputs)
        elif isinstance(outputs, tuple):
            return tuple(poptorch.recomputationCheckpoint(y) for y in outputs)
    return module.register_forward_hook(recompute_outputs)
def recomputation_checkpoint ( module : nn . Module ) : def recompute_outputs ( module , inputs , outputs ) : if isinstance ( outputs , torch . Tensor ) : return poptorch . recomputationCheckpoint ( outputs ) elif isinstance ( outputs , tuple ) : return tuple ( poptorch . recomputationCheckpoint ( y ) for y in outputs ) return module . register_forward_hook ( recompute_outputs )
Annotates the output of a module to be checkpointed instead of
recomputed
Annotates the output of a module to be checkpointed instead of recomputed
"""Annotates the output of a module to be checkpointed instead of
    recomputed"""
module
nn.Module