/src/llama.cpp/ggml/src/ggml-cpu/traits.cpp
Line | Count | Source |
1 | | #include "traits.h" |
2 | | |
3 | | #include "ggml-backend-impl.h" |
4 | | #include "ggml-backend.h" |
5 | | |
6 | | namespace ggml::cpu { |
7 | 0 | tensor_traits::~tensor_traits() {} |
8 | | |
9 | 0 | extra_buffer_type::~extra_buffer_type() {} |
10 | | } // namespace ggml::cpu |
11 | | |
12 | 0 | bool ggml_cpu_extra_compute_forward(struct ggml_compute_params * params, struct ggml_tensor * op) { |
13 | 0 | for (auto extra : ggml_backend_cpu_get_extra_buffer_types()) { |
14 | 0 | if (extra && extra->context) { |
15 | 0 | auto buf_extra = (ggml::cpu::extra_buffer_type *) extra->context; |
16 | 0 | auto tensor_traits = buf_extra->get_tensor_traits(op); |
17 | 0 | if (tensor_traits && tensor_traits->compute_forward(params, op)) { |
18 | 0 | return true; |
19 | 0 | } |
20 | 0 | } |
21 | 0 | } |
22 | 0 | return false; |
23 | 0 | } |
24 | | |
25 | 0 | bool ggml_cpu_extra_work_size(int n_threads, const struct ggml_tensor * op, size_t * size) { |
26 | 0 | for (auto extra : ggml_backend_cpu_get_extra_buffer_types()) { |
27 | 0 | if (extra && extra->context) { |
28 | 0 | auto buf_extra = (ggml::cpu::extra_buffer_type *) extra->context; |
29 | 0 | auto tensor_traits = buf_extra->get_tensor_traits(op); |
30 | 0 | if (tensor_traits && tensor_traits->work_size(n_threads, op, *size)) { |
31 | 0 | return true; |
32 | 0 | } |
33 | 0 | } |
34 | 0 | } |
35 | 0 | return false; |
36 | 0 | } |