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

Method graph_get_cb

subprojects/llama.cpp/src/llama-context.cpp:2144–2168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2142}
2143
2144llm_graph_cb llama_context::graph_get_cb() const {
2145 return [&](const llama_ubatch & ubatch, ggml_tensor * cur, const char * name, int il) {
2146 if (il >= 0) {
2147 ggml_format_name(cur, "%s-%d", name, il);
2148 } else {
2149 ggml_set_name(cur, name);
2150 }
2151
2152 // norm may be automatically assigned to the backend of the previous layer, increasing data transfer between backends
2153 // FIXME: fix in ggml_backend_sched
2154 const bool full_offload = model.n_gpu_layers() > model.hparams.n_layer;
2155 if (ubatch.n_tokens < 32 || full_offload) {
2156 if (il != -1 && strcmp(name, "norm") == 0) {
2157 const auto & dev_layer = model.dev_layer(il);
2158 for (const auto & backend : backends) {
2159 if (ggml_backend_get_device(backend.get()) == dev_layer) {
2160 if (ggml_backend_supports_op(backend.get(), cur)) {
2161 ggml_backend_sched_set_tensor_backend(sched.get(), cur, backend.get());
2162 }
2163 }
2164 }
2165 }
2166 }
2167 };
2168}
2169
2170//
2171// state save/load

Callers

nothing calls this directly

Calls 8

ggml_format_nameFunction · 0.85
ggml_set_nameFunction · 0.85
ggml_backend_get_deviceFunction · 0.85
ggml_backend_supports_opFunction · 0.85
n_gpu_layersMethod · 0.80
dev_layerMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected