Beispiel #1
0
 def forward(self, *args, **kwargs):
     offload_mgr = save_on_cpu(pin_memory=True) if self.offload_to_cpu else suppress()
     with offload_mgr:  # type: ignore[attr-defined]
         return checkpoint(
             self.mod,
             use_reentrant=(self.checkpoint_impl == CheckpointImpl.REENTRANT),
             *args,
             **kwargs,
         )
Beispiel #2
0
 def forward(self, *args, **kwargs):
     offload_mgr = save_on_cpu(
         pin_memory=True) if self.offload_to_cpu else suppress()
     with offload_mgr:  # type: ignore[attr-defined]
         return self.checkpoint_fn(self._checkpoint_wrapped_module, *args,
                                   **kwargs)