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

Function common_debug_cb_eval

subprojects/llama.cpp/common/debug.cpp:113–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111 * @return true to receive data or continue the graph, false otherwise
112 */
113template <bool abort_on_nan> bool common_debug_cb_eval(struct ggml_tensor * t, bool ask, void * user_data) {
114 auto * cb_data = (base_callback_data *) user_data;
115
116 const struct ggml_tensor * src0 = t->src[0];
117 const struct ggml_tensor * src1 = t->src[1];
118
119 if (ask) {
120 return true; // Always retrieve data
121 }
122
123 bool matches_filter = cb_data->tensor_filters.empty();
124
125 if (!matches_filter) {
126 for (const auto & filter : cb_data->tensor_filters) {
127 if (std::regex_search(t->name, filter)) {
128 matches_filter = true;
129 break;
130 }
131 }
132 }
133
134 char src1_str[128] = { 0 };
135 if (src1) {
136 snprintf(src1_str, sizeof(src1_str), "%s{%s}", src1->name, common_ggml_ne_string(src1).c_str());
137 }
138
139 if (matches_filter) {
140 LOG_ERR("%s: %24s = (%s) %10s(%s{%s}, %s}) = {%s}\n", __func__, t->name, ggml_type_name(t->type),
141 ggml_op_desc(t), src0->name, common_ggml_ne_string(src0).c_str(), src1 ? src1_str : "",
142 common_ggml_ne_string(t).c_str());
143 }
144
145 const bool is_host = ggml_backend_buffer_is_host(t->buffer);
146
147 if (!is_host) {
148 auto n_bytes = ggml_nbytes(t);
149 cb_data->data.resize(n_bytes);
150 ggml_backend_tensor_get(t, cb_data->data.data(), 0, n_bytes);
151 }
152
153 if (!ggml_is_quantized(t->type) && matches_filter) {
154 uint8_t * data = is_host ? (uint8_t *) t->data : cb_data->data.data();
155 common_debug_print_tensor<abort_on_nan>(data, t->type, t->ne, t->nb, 3);
156 }
157
158 return true;
159}
160
161// Explicit template instantiations
162template bool common_debug_cb_eval<false>(ggml_tensor *, bool, void *);

Callers

nothing calls this directly

Calls 10

common_ggml_ne_stringFunction · 0.85
ggml_type_nameFunction · 0.85
ggml_op_descFunction · 0.85
ggml_nbytesFunction · 0.85
ggml_backend_tensor_getFunction · 0.85
ggml_is_quantizedFunction · 0.85
emptyMethod · 0.65
resizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected