MCPcopy Create free account
hub / github.com/pytorch/tutorials / SaveToCpu

Class SaveToCpu

intermediate_source/autograd_saved_tensors_hooks_tutorial.py:353–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351#
352
353class SaveToCpu(nn.Module):
354 def __init__(self, module):
355 super().__init__()
356 self.module = module
357
358 def forward(self, *args, **kwargs):
359 with torch.autograd.graph.save_on_cpu(pin_memory=True):
360 return self.module(*args, **kwargs)
361
362model = nn.Sequential(
363 nn.Linear(10, 100),

Calls

no outgoing calls

Tested by

no test coverage detected