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

Function buft_supported

subprojects/llama.cpp/src/llama-model.cpp:7390–7414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7388
7389template<typename F>
7390static bool buft_supported(ggml_backend_buffer_type_t buft, ggml_backend_dev_t dev, F & fn) {
7391 ggml_init_params params = {
7392 /*.mem_size =*/ ggml_tensor_overhead()*8,
7393 /*.mem_buffer =*/ NULL,
7394 /*.no_alloc =*/ true,
7395 };
7396
7397 ggml_context_ptr ctx { ggml_init(params) };
7398 if (!ctx) {
7399 throw std::runtime_error(format("failed to create ggml context"));
7400 }
7401
7402 ggml_backend_buffer_ptr buf { ggml_backend_buft_alloc_buffer(buft, 0) };
7403 ggml_tensor * op_tensor = fn(ctx.get());
7404 for (int i = 0; i < GGML_MAX_SRC; i++) {
7405 if (op_tensor->src[i] != nullptr) {
7406 assert(op_tensor->src[i]->buffer == nullptr);
7407 op_tensor->src[i]->buffer = buf.get();
7408 }
7409 }
7410
7411 bool op_supported = ggml_backend_dev_supports_op(dev, op_tensor);
7412
7413 return op_supported;
7414}
7415
7416template<typename F>
7417static ggml_backend_buffer_type_t select_buft(const buft_list_t & buft_list, const F & fn) {

Callers 1

select_buftFunction · 0.85

Calls 6

ggml_tensor_overheadFunction · 0.85
ggml_initFunction · 0.85
formatFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected