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

Function save_tensor

tests/dump_vit_reference.py:122–129  ·  view source on GitHub ↗
(path, t)

Source from the content-addressed store, hash-verified

120
121
122def save_tensor(path, t):
123 t = t.detach().cpu().float().contiguous()
124 os.makedirs(os.path.dirname(path) or ".", exist_ok=True)
125 with open(path + ".bin", "wb") as f:
126 f.write(t.numpy().tobytes())
127 with open(path + ".shape", "w") as f:
128 f.write(",".join(str(d) for d in t.shape))
129 print(f" saved {path} shape={list(t.shape)}")
130
131
132def main():

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected