diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-06-25 14:26:34 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-06-25 14:26:34 +0200 |
| commit | fb8f096b51cb518f81f558d4e0580a3652d104c1 (patch) | |
| tree | eb2898843faed207129f3747f9591ebb445058ae /tools | |
| parent | c9893b27f18bd3cd33c53100cefa86f689b8a273 (diff) | |
| download | ffwd-fb8f096b51cb518f81f558d4e0580a3652d104c1.tar.gz ffwd-fb8f096b51cb518f81f558d4e0580a3652d104c1.zip | |
server: drop the throwaway buffer in the base64 float path
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/server/encode.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/tools/server/encode.c b/tools/server/encode.c index 1674774..90e8229 100644 --- a/tools/server/encode.c +++ b/tools/server/encode.c @@ -29,15 +29,11 @@ signed char quantize_int8_tanh(float x) { char *encode_embedding(const float *emb, int dims, const char *encoding) { if (!strcmp(encoding, "base64")) { /* OpenAI/DashScope (Qwen3): base64 of the raw little-endian float32 - * vector. Copy through a byte buffer instead of reinterpret-casting the - * float pointer; x86_64 and aarch64 are little-endian, so the bytes - * match the wire format with no swap. */ + * vector. x86_64 and aarch64 are little-endian, so the float bytes are + * already the wire format; read them directly through an unsigned char + * pointer. */ size_t nbytes = (size_t)dims * sizeof(float); - unsigned char *buf = xmalloc(nbytes); - memcpy(buf, emb, nbytes); - char *out = base64_encode(buf, nbytes); - free(buf); - return out; + return base64_encode((const unsigned char *)emb, nbytes); } if (!strcmp(encoding, "base64_binary")) { size_t bytes = (size_t)dims / 8; |
