← Back to C-Kernel-Engine Docs Doxygen Source Documentation
Loading...
Searching...
No Matches
ck_decoder_features.h
Go to the documentation of this file.
1#ifndef CK_DECODER_FEATURES_H
2#define CK_DECODER_FEATURES_H
3#include <stddef.h>
4#include <stdint.h>
5
6/* ABI 1 describes an exclusively owned, already initialized generated decoder.
7 * The callbacks have the ordinary generated decoder ABI; they schedule no layers
8 * in the caller. Feature storage must remain valid until this call returns.
9 * This descriptor is runtime state, never a weight or checkpoint tensor. */
10typedef struct CKDecoderFeatures {
11 uint32_t abi_version;
12 size_t channels;
13 const float *features;
15 int (*decode)(int32_t token, float *logits);
16 void (*reset)(void);
17 int (*active_tokens)(void);
18 int (*context_window)(void);
19 int (*vocabulary_size)(void);
20 int (*should_cancel)(void *context); /* Optional; independent of decoder reset. */
23
24/* IDs and all buffers are caller-owned. Rejection before execution changes
25 * neither decoder state nor output. Execution failures attempt decoder reset
26 * and leave output untouched; scratch may change. A failed reset invalidates
27 * the decoder until its owner reinitializes it. Only valid rows are published.
28 * The caller must exclude concurrent access to this decoder instance. */
30 const void *context, size_t context_bytes,
31 const int32_t *ids, size_t id_elements, size_t tokens, size_t channels,
32 float *output, size_t output_elements,
33 float *scratch, size_t scratch_elements);
34#endif
int decoder_features_sequence_checked_f32(const void *context, size_t context_bytes, const int32_t *ids, size_t id_elements, size_t tokens, size_t channels, float *output, size_t output_elements, float *scratch, size_t scratch_elements)
int(* should_cancel)(void *context)
int(* decode)(int32_t token, float *logits)
int(* vocabulary_size)(void)
int(* context_window)(void)
const int32_t * ids
Definition tokenizer.h:447
const char * token
Definition tokenizer.h:308