diff options
Diffstat (limited to 'llama.cpp/ggml/src/ggml-cpu/traits.cpp')
| -rw-r--r-- | llama.cpp/ggml/src/ggml-cpu/traits.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/llama.cpp/ggml/src/ggml-cpu/traits.cpp b/llama.cpp/ggml/src/ggml-cpu/traits.cpp new file mode 100644 index 0000000..4f32f10 --- /dev/null +++ b/llama.cpp/ggml/src/ggml-cpu/traits.cpp @@ -0,0 +1,36 @@ +#include "traits.h" + +#include "ggml-backend-impl.h" +#include "ggml-backend.h" + +namespace ggml::cpu { +tensor_traits::~tensor_traits() {} + +extra_buffer_type::~extra_buffer_type() {} +} // namespace ggml::cpu + +bool ggml_cpu_extra_compute_forward(struct ggml_compute_params * params, struct ggml_tensor * op) { + for (auto extra : ggml_backend_cpu_get_extra_buffer_types()) { + if (extra && extra->context) { + auto buf_extra = (ggml::cpu::extra_buffer_type *) extra->context; + auto tensor_traits = buf_extra->get_tensor_traits(op); + if (tensor_traits && tensor_traits->compute_forward(params, op)) { + return true; + } + } + } + return false; +} + +bool ggml_cpu_extra_work_size(int n_threads, const struct ggml_tensor * op, size_t * size) { + for (auto extra : ggml_backend_cpu_get_extra_buffer_types()) { + if (extra && extra->context) { + auto buf_extra = (ggml::cpu::extra_buffer_type *) extra->context; + auto tensor_traits = buf_extra->get_tensor_traits(op); + if (tensor_traits && tensor_traits->work_size(n_threads, op, *size)) { + return true; + } + } + } + return false; +} |
