(path, t)
| 120 | |
| 121 | |
| 122 | def 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 | |
| 132 | def main(): |