MCPcopy Create free account
hub / github.com/PABannier/sam3.cpp / save_tensor

Function save_tensor

tests/dump_reference.py:27–34  ·  view source on GitHub ↗

Save a tensor as raw float32 binary + shape file.

(path, t)

Source from the content-addressed store, hash-verified

25
26
27def save_tensor(path, t):
28 """Save a tensor as raw float32 binary + shape file."""
29 t = t.detach().cpu().float().contiguous()
30 with open(path + ".bin", "wb") as f:
31 f.write(t.numpy().tobytes())
32 with open(path + ".shape", "w") as f:
33 f.write(",".join(str(d) for d in t.shape))
34 print(f" saved {path} shape={list(t.shape)} bytes={t.numel()*4}")
35
36
37def main():

Callers 6

dump_preprocessingFunction · 0.70
dump_backboneFunction · 0.70
dump_fpn_neckFunction · 0.70
dump_image_featuresFunction · 0.70
dump_pvs_inferenceFunction · 0.70
mainFunction · 0.70

Calls 1

numelMethod · 0.45

Tested by

no test coverage detected