MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / print_mask

Function print_mask

subprojects/llama.cpp/src/llama-graph.cpp:286–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286static void print_mask(const float * data, int64_t n_tokens, int64_t n_kv, int64_t n_swa, llama_swa_type swa_type) {
287 LLAMA_LOG_DEBUG("%s: === Attention mask ===\n", __func__);
288 const char * swa_type_str = "unknown";
289
290 switch (swa_type) {
291 case LLAMA_SWA_TYPE_NONE: swa_type_str = "LLAMA_SWA_TYPE_NONE"; break;
292 case LLAMA_SWA_TYPE_STANDARD: swa_type_str = "LLAMA_SWA_TYPE_STANDARD"; break;
293 case LLAMA_SWA_TYPE_CHUNKED: swa_type_str = "LLAMA_SWA_TYPE_CHUNKED"; break;
294 case LLAMA_SWA_TYPE_SYMMETRIC: swa_type_str = "LLAMA_SWA_TYPE_SYMMETRIC"; break;
295 };
296
297 LLAMA_LOG_DEBUG("%s: n_swa : %d, n_kv: %d, swq_type: %s\n", __func__, (int)n_swa, (int)n_kv, swa_type_str);
298 LLAMA_LOG_DEBUG("%s: '0' = can attend, '∞' = masked\n", __func__);
299 LLAMA_LOG_DEBUG("%s: Rows = query tokens, Columns = key/value tokens\n\n", __func__);
300
301 LLAMA_LOG_DEBUG(" ");
302 for (int j = 0; j < std::min((int64_t)20, n_kv); ++j) {
303 LLAMA_LOG_DEBUG("%2d", j);
304 }
305 LLAMA_LOG_DEBUG("\n");
306
307 for (int i = 0; i < std::min((int64_t)20, n_tokens); ++i) {
308 LLAMA_LOG_DEBUG(" %2d ", i);
309 for (int j = 0; j < std::min((int64_t)20, n_kv); ++j) {
310 float val = data[i * n_kv + j];
311 if (val == -INFINITY) {
312 LLAMA_LOG_DEBUG(" ∞");
313 } else {
314 LLAMA_LOG_DEBUG(" 0");
315 }
316 }
317 LLAMA_LOG_DEBUG("\n");
318 }
319}
320
321void llm_graph_input_attn_no_cache::set_input(const llama_ubatch * ubatch) {
322 const int64_t n_kv = ubatch->n_tokens;

Callers 1

set_inputMethod · 0.85

Calls 1

minFunction · 0.85

Tested by

no test coverage detected