liblloyal 1.0.0
Composable primitives for llama.cpp inference
Loading...
Searching...
No Matches
logits.hpp File Reference

Zero-copy logits access with clear lifetime semantics. More...

#include <llama/llama.h>
#include <stdexcept>

Go to the source code of this file.

Namespaces

namespace  lloyal
 JSON Schema to Grammar Converter (Header-Only)
 
namespace  lloyal::logits
 

Functions

float * lloyal::logits::get (llama_context *ctx, int32_t step=-1)
 Get raw logits pointer (zero-copy)
 

Detailed Description

Zero-copy logits access with clear lifetime semantics.

Provides safe wrapper around llama_get_logits_ith() with:

  • Null checking and error handling
  • Clear documentation of pointer lifetime
  • Consistent error messages

LIFETIME CONTRACT: The returned pointer is valid ONLY until the next decode()/encode() call. Shells are responsible for implementing their own safety mechanisms (e.g., buffer detachment, reference tracking) to prevent use-after-invalidation.

USAGE: float* logits = lloyal::logits::get(ctx); int n_vocab = lloyal::tokenizer::vocab_size(model); // Use logits[0..n_vocab-1] synchronously // DO NOT store across decode() calls

Definition in file logits.hpp.