MCPcopy Create free account
hub / github.com/pytorch/pytorch / write_tensor

Method write_tensor

torch/utils/_content_store.py:181–189  ·  view source on GitHub ↗
(self, name: str, t: torch.Tensor)

Source from the content-addressed store, hash-verified

179 )
180
181 def write_tensor(self, name: str, t: torch.Tensor) -> None:
182 storage = t.untyped_storage()
183 h = self.write_storage(storage)
184 # TODO: Support more advanced snapshotting of requires_grad/grad/etc
185 d, f = os.path.split(name)
186 payload = self.compute_tensor_metadata(t, h=h)
187 subfolder = os.path.join(self.loc, "tensors", d)
188 os.makedirs(subfolder, exist_ok=True)
189 torch.save(payload, os.path.join(subfolder, f))
190
191
192class ContentStoreReader:

Callers 5

test_basicMethod · 0.95
test_load_tensorMethod · 0.95
save_hookFunction · 0.80
run_nodeMethod · 0.80
run_nodeMethod · 0.80

Calls 6

write_storageMethod · 0.95
makedirsMethod · 0.80
splitMethod · 0.45
joinMethod · 0.45
saveMethod · 0.45

Tested by 2

test_basicMethod · 0.76
test_load_tensorMethod · 0.76