From 76e1fd0f4569c2729bf8da9af47c60d2cf0be9ca Mon Sep 17 00:00:00 2001 From: luffy06 <534427411@qq.com> Date: Wed, 10 Jan 2024 22:36:50 +0800 Subject: [PATCH] print graph --- ggml.h | 2 +- llama.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ggml.h b/ggml.h index 3ef708c11..573743bb8 100644 --- a/ggml.h +++ b/ggml.h @@ -515,7 +515,7 @@ extern "C" { struct ggml_backend_buffer * buffer; - int64_t ne[GGML_MAX_DIMS]; // number of elements, [batch size, , seq len, hidden dim] + int64_t ne[GGML_MAX_DIMS]; // number of elements, [batch size, heads, seq len, hidden dim] size_t nb[GGML_MAX_DIMS]; // stride in bytes: // nb[0] = ggml_type_size(type) // nb[1] = nb[0] * (ne[0] / ggml_blck_size(type)) + padding diff --git a/llama.cpp b/llama.cpp index 8778193a6..1f4eafeff 100644 --- a/llama.cpp +++ b/llama.cpp @@ -4514,6 +4514,31 @@ struct llm_build_context { LLAMA_LOG_INFO(")\n"); } } + LLAMA_LOG_INFO("%s: \tSource tensor [", __func__); + switch (t->op) { + case GGML_OP_VIEW: + case GGML_OP_RMS_NORM: + case GGML_OP_RESHAPE: + case GGML_OP_CPY: + case GGML_OP_TRANSPOSE: + case GGML_OP_PERMUTE: + case GGML_OP_CONT: + case GGML_OP_UNARY: + LLAMA_LOG_INFO("%s", t->src[0]->name); + break; + case GGML_OP_ROPE: + case GGML_OP_GET_ROWS: + case GGML_OP_MUL: + case GGML_OP_MUL_MAT: + case GGML_OP_SOFT_MAX: + case GGML_OP_ADD: + LLAMA_LOG_INFO("%s, %s", t->src[0]->name, t->src[1]->name); + break; + default: + LLAMA_LOG_INFO("Unknown OP [%s]\n", ggml_op_string(t->op)); + exit(-1); + } + LLAMA_LOG_INFO("]\n"); } exit(-1);