From 43fdb308879fb0c61cb71553d9ac885c011d3a66 Mon Sep 17 00:00:00 2001 From: Onur Gündüz Date: Mon, 15 Jun 2026 09:45:22 +0200 Subject: late: batch CPU rerank candidate encoding in one packed forward --- embed.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'embed.h') diff --git a/embed.h b/embed.h index 24e53e1..b84f71c 100644 --- a/embed.h +++ b/embed.h @@ -286,6 +286,25 @@ EMBED_API int embed_late_model_encode_tokens(const embed_late_model_t *model, int normalize, float *out_vectors); +/* + * Encode n_docs documents in one block-diagonal forward and pack each + * document's kept token vectors back-to-back into out_vectors[total_keep, + * token_dim] in document order, where total_keep is the sum of n_keep. + * out_offsets[n_docs + 1] receives the prefix sum of kept counts, the layout + * embed_late_maxsim_batch consumes. keep[d] lists the n_keep[d] token indices to + * retain from document d. Returns 0 on success, -1 on error. + */ +EMBED_API int embed_late_model_encode_docs(const embed_late_model_t *model, + embed_late_workspace_t *ws, + const int *const *doc_ids, + const int *n_tokens, + const int *const *keep, + const int *n_keep, + int n_docs, + int normalize, + float *out_vectors, + int *out_offsets); + /* * Sum over query tokens of max dot product against document tokens. */ -- cgit v1.3.1