liblloyal 1.0.0
Composable primitives for llama.cpp inference
Loading...
Searching...
No Matches
logits.hpp
Go to the documentation of this file.
1#pragma once
2
3// SPDX-License-Identifier: Apache-2.0
4// Copyright 2026 Lloyal Labs
5
27#include <llama/llama.h>
28#include <stdexcept>
29
30namespace lloyal::logits {
31
60inline float* get(llama_context* ctx, int32_t step = -1) {
61 if (!ctx) {
62 throw std::runtime_error("logits::get - NULL context");
63 }
64
65 float* ptr = llama_get_logits_ith(ctx, step);
66 if (!ptr) {
67 throw std::runtime_error(
68 "logits::get - Failed to get logits. "
69 "Ensure decode() was called with logits=true for this step."
70 );
71 }
72
73 return ptr;
74}
75
76} // namespace lloyal::logits
float * get(llama_context *ctx, int32_t step=-1)
Get raw logits pointer (zero-copy)
Definition logits.hpp:60