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

Function save_tensor

tests/dump_phase4_reference.py:24–30  ·  view source on GitHub ↗
(path: str, t: torch.Tensor)

Source from the content-addressed store, hash-verified

22
23
24def save_tensor(path: str, t: torch.Tensor) -> None:
25 t = t.detach().cpu().float().contiguous()
26 os.makedirs(os.path.dirname(path) or ".", exist_ok=True)
27 with open(path + ".bin", "wb") as f:
28 f.write(t.numpy().tobytes())
29 with open(path + ".shape", "w") as f:
30 f.write(",".join(str(d) for d in t.shape))
31
32
33def save_i32_tensor(path: str, values: List[int]) -> None:

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected