MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / log_softmax

Function log_softmax

tools/perplexity/perplexity.cpp:60–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60static results_log_softmax log_softmax(int n_vocab, const float * logits, int tok) {
61 float max_logit = logits[0];
62 for (int i = 1; i < n_vocab; ++i) {
63 max_logit = std::max(max_logit, logits[i]);
64 }
65 double sum_exp = 0.0;
66 for (int i = 0; i < n_vocab; ++i) {
67 sum_exp += expf(logits[i] - max_logit);
68 }
69 return {logits[tok] - max_logit - log(sum_exp), logits[tok], expf(logits[tok] - max_logit) / (float) sum_exp};
70}
71
72static inline int nearest_int(float fval) {
73 //assert(fval <= 4194303.f);

Callers 1

process_logitsFunction · 0.70

Calls 4

maxFunction · 0.85
logFunction · 0.85
minFunction · 0.85
nearest_intFunction · 0.70

Tested by

no test coverage detected