(path: str)
| 80 | |
| 81 | |
| 82 | def load_tensor(path: str) -> torch.Tensor: |
| 83 | with open(path + ".shape", "r") as f: |
| 84 | shape = [int(x) for x in f.read().strip().split(",") if x] |
| 85 | data = np.fromfile(path + ".bin", dtype=np.float32).reshape(shape) |
| 86 | return torch.from_numpy(data) |
| 87 | |
| 88 | |
| 89 | # ── Sinusoidal position encoding (matches PositionEmbeddingSine) ────────── |