(path, t)
| 21 | |
| 22 | |
| 23 | def save_tensor(path, t): |
| 24 | t = t.detach().cpu().float().contiguous() |
| 25 | os.makedirs(os.path.dirname(path) or ".", exist_ok=True) |
| 26 | with open(path + ".bin", "wb") as f: |
| 27 | f.write(t.numpy().tobytes()) |
| 28 | with open(path + ".shape", "w") as f: |
| 29 | f.write(",".join(str(d) for d in t.shape)) |
| 30 | print(f" saved {path} shape={list(t.shape)}") |
| 31 | |
| 32 | |
| 33 | def save_tensor_i32(path, t): |