| |
| |
| |
| |
| |
| |
| |
| import json, struct, sys |
| H = 768 |
| R0 = int(sys.argv[1]) if len(sys.argv) > 1 else 8000 |
| def write_st(path, dtype, shape, itemsize, fill): |
| n = 1 |
| for d in shape: n *= d |
| data = bytes([fill]) * (n * itemsize) |
| header = {"emb_params": {"dtype": dtype, "shape": list(shape), "data_offsets": [0, len(data)]}} |
| hb = json.dumps(header).encode("utf-8") |
| with open(path, "wb") as f: |
| f.write(struct.pack("<Q", len(hb))); f.write(hb); f.write(data) |
| print(f"{path}: dtype={dtype} shape={shape} bytes={len(data)}") |
| write_st(f"{sys.argv[2] if len(sys.argv)>2 else '.'}/embd_f16.safetensors", "F16", (R0, H), 2, 0xAA) |
| write_st(f"{sys.argv[2] if len(sys.argv)>2 else '.'}/embd_f32.safetensors", "F32", (1, H), 4, 0x41) |
|
|