(tensor: torch.Tensor)
| 186 | |
| 187 | |
| 188 | def tensor_to_base64(tensor: torch.Tensor) -> str: |
| 189 | array = tensor.detach().cpu().to(torch.float16).numpy() |
| 190 | little_endian = np.ascontiguousarray(array.astype("<f2", copy=False)).view("<u2") |
| 191 | data = little_endian.tobytes() |
| 192 | return base64.b64encode(data).decode("ascii") |
| 193 | |
| 194 | |
| 195 | def write_snapshot_file( |
no outgoing calls
no test coverage detected