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

Function save_tensor

tests/dump_phase3_reference.py:29–37  ·  view source on GitHub ↗
(path, t)

Source from the content-addressed store, hash-verified

27# ── Helpers ────────────────────────────────────────────────────────────────
28
29def save_tensor(path, t):
30 t = t.detach().cpu().float().contiguous()
31 os.makedirs(os.path.dirname(path) or ".", exist_ok=True)
32 with open(path + ".bin", "wb") as f:
33 f.write(t.numpy().tobytes())
34 with open(path + ".shape", "w") as f:
35 f.write(",".join(str(d) for d in t.shape))
36 print(f" saved {path} shape={list(t.shape)} "
37 f"min={t.min().item():.6f} max={t.max().item():.6f} mean={t.mean().item():.6f}")
38
39
40# ── Inlined from vitdet.py ─────────────────────────────────────────────────

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected