liblloyal 1.0.0
Composable primitives for llama.cpp inference
Loading...
Searching...
No Matches
lloyal::metrics::detail Namespace Reference

Classes

struct  BranchMetricsState
 
struct  PerplexityState
 

Functions

float max_finite (const float *a, int n)
 Find maximum finite value in array Used for log-sum-exp shift to prevent overflow.
 
float log_sum_exp (const float *a, int n, float shift)
 Numerically stable log-sum-exp Computes log(Σ exp(aᵢ)) using shift trick to avoid overflow.
 
std::unordered_map< PerplexityHandle, PerplexityState > & get_registry ()
 
PerplexityHandleget_next_handle ()
 
std::unordered_map< BranchMetricsHandle, BranchMetricsState > & get_branch_metrics_registry ()
 
BranchMetricsHandleget_next_branch_metrics_handle ()
 

Variables

constexpr float LN2 = 0.693147180559945309417232121458176568f
 

Function Documentation

◆ get_branch_metrics_registry()

std::unordered_map< BranchMetricsHandle, BranchMetricsState > & lloyal::metrics::detail::get_branch_metrics_registry ( )
inline

◆ get_next_branch_metrics_handle()

BranchMetricsHandle & lloyal::metrics::detail::get_next_branch_metrics_handle ( )
inline

◆ get_next_handle()

PerplexityHandle & lloyal::metrics::detail::get_next_handle ( )
inline

◆ get_registry()

std::unordered_map< PerplexityHandle, PerplexityState > & lloyal::metrics::detail::get_registry ( )
inline

◆ log_sum_exp()

float lloyal::metrics::detail::log_sum_exp ( const float *  a,
int  n,
float  shift 
)
inline

Numerically stable log-sum-exp Computes log(Σ exp(aᵢ)) using shift trick to avoid overflow.

Parameters
aArray of log-space values
nArray length
shiftMax value for numerical stability
Returns
log(Σ exp(aᵢ))
Examples
/home/runner/work/liblloyal/liblloyal/include/lloyal/metrics.hpp.

Definition at line 76 of file metrics.hpp.

◆ max_finite()

float lloyal::metrics::detail::max_finite ( const float *  a,
int  n 
)
inline

Find maximum finite value in array Used for log-sum-exp shift to prevent overflow.

Examples
/home/runner/work/liblloyal/liblloyal/include/lloyal/metrics.hpp.

Definition at line 58 of file metrics.hpp.

Variable Documentation

◆ LN2

constexpr float lloyal::metrics::detail::LN2 = 0.693147180559945309417232121458176568f
constexpr