MCPcopy Create free account
hub / github.com/tdrussell/diffusion-pipe / rebuild_tensor

Function rebuild_tensor

utils/reduction.py:113–123  ·  view source on GitHub ↗
(cls, storage, metadata)

Source from the content-addressed store, hash-verified

111
112
113def rebuild_tensor(cls, storage, metadata):
114 storage_offset, size, stride, requires_grad = metadata
115 t = torch._utils._rebuild_tensor(storage, storage_offset, size, stride)
116 if cls == torch.nn.parameter.Parameter:
117 # we have to pass requires_grad into constructor, rather than set it as an
118 # attribute later, because it's an important check for Integer Tensors to
119 # have requires_grad=False (or else they raise an error)
120 t = torch.nn.parameter.Parameter(t, requires_grad=requires_grad)
121 else:
122 t.requires_grad = requires_grad
123 return t
124
125
126def rebuild_meta_tensor(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected