cui-llama.rn 1.2.6 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +3 -2
  2. package/android/src/main/CMakeLists.txt +20 -5
  3. package/android/src/main/java/com/rnllama/LlamaContext.java +115 -27
  4. package/android/src/main/java/com/rnllama/RNLlama.java +40 -7
  5. package/android/src/main/jni.cpp +222 -34
  6. package/android/src/newarch/java/com/rnllama/RNLlamaModule.java +9 -4
  7. package/android/src/oldarch/java/com/rnllama/RNLlamaModule.java +9 -4
  8. package/cpp/common.cpp +1682 -2114
  9. package/cpp/common.h +600 -613
  10. package/cpp/ggml-aarch64.c +129 -3478
  11. package/cpp/ggml-aarch64.h +19 -39
  12. package/cpp/ggml-alloc.c +1040 -1040
  13. package/cpp/ggml-alloc.h +76 -76
  14. package/cpp/ggml-backend-impl.h +216 -216
  15. package/cpp/ggml-backend-reg.cpp +195 -0
  16. package/cpp/ggml-backend.cpp +1997 -2661
  17. package/cpp/ggml-backend.h +328 -314
  18. package/cpp/ggml-common.h +1853 -1853
  19. package/cpp/ggml-cpp.h +38 -38
  20. package/cpp/ggml-cpu-aarch64.c +3560 -0
  21. package/cpp/ggml-cpu-aarch64.h +30 -0
  22. package/cpp/ggml-cpu-impl.h +371 -614
  23. package/cpp/ggml-cpu-quants.c +10822 -0
  24. package/cpp/ggml-cpu-quants.h +63 -0
  25. package/cpp/ggml-cpu.c +13975 -13720
  26. package/cpp/ggml-cpu.cpp +663 -0
  27. package/cpp/ggml-cpu.h +177 -150
  28. package/cpp/ggml-impl.h +550 -296
  29. package/cpp/ggml-metal.h +66 -66
  30. package/cpp/ggml-metal.m +4294 -3933
  31. package/cpp/ggml-quants.c +5247 -15739
  32. package/cpp/ggml-quants.h +100 -147
  33. package/cpp/ggml-threading.cpp +12 -0
  34. package/cpp/ggml-threading.h +12 -0
  35. package/cpp/ggml.c +8180 -8390
  36. package/cpp/ggml.h +2411 -2441
  37. package/cpp/llama-grammar.cpp +1138 -1138
  38. package/cpp/llama-grammar.h +144 -144
  39. package/cpp/llama-impl.h +181 -181
  40. package/cpp/llama-sampling.cpp +2348 -2345
  41. package/cpp/llama-sampling.h +48 -48
  42. package/cpp/llama-vocab.cpp +1984 -1984
  43. package/cpp/llama-vocab.h +170 -170
  44. package/cpp/llama.cpp +22132 -22046
  45. package/cpp/llama.h +1253 -1255
  46. package/cpp/log.cpp +401 -401
  47. package/cpp/log.h +121 -121
  48. package/cpp/rn-llama.hpp +83 -19
  49. package/cpp/sampling.cpp +466 -466
  50. package/cpp/sgemm.cpp +1884 -1276
  51. package/ios/RNLlama.mm +43 -20
  52. package/ios/RNLlamaContext.h +9 -3
  53. package/ios/RNLlamaContext.mm +133 -33
  54. package/jest/mock.js +0 -1
  55. package/lib/commonjs/NativeRNLlama.js.map +1 -1
  56. package/lib/commonjs/index.js +52 -15
  57. package/lib/commonjs/index.js.map +1 -1
  58. package/lib/module/NativeRNLlama.js.map +1 -1
  59. package/lib/module/index.js +51 -15
  60. package/lib/module/index.js.map +1 -1
  61. package/lib/typescript/NativeRNLlama.d.ts +29 -5
  62. package/lib/typescript/NativeRNLlama.d.ts.map +1 -1
  63. package/lib/typescript/index.d.ts +12 -5
  64. package/lib/typescript/index.d.ts.map +1 -1
  65. package/package.json +1 -1
  66. package/src/NativeRNLlama.ts +41 -6
  67. package/src/index.ts +82 -27
  68. package/cpp/json-schema-to-grammar.cpp +0 -1045
  69. package/cpp/json-schema-to-grammar.h +0 -8
  70. package/cpp/json.hpp +0 -24766
package/cpp/ggml-cpu.h CHANGED
@@ -1,150 +1,177 @@
1
- #pragma once
2
-
3
- #include "ggml.h"
4
- #include "ggml-backend.h"
5
-
6
- #ifdef __cplusplus
7
- extern "C" {
8
- #endif
9
-
10
- // Scheduling priorities
11
- enum lm_ggml_sched_priority {
12
- LM_GGML_SCHED_PRIO_NORMAL,
13
- LM_GGML_SCHED_PRIO_MEDIUM,
14
- LM_GGML_SCHED_PRIO_HIGH,
15
- LM_GGML_SCHED_PRIO_REALTIME
16
- };
17
-
18
- // Threadpool params
19
- // Use lm_ggml_threadpool_params_default() or lm_ggml_threadpool_params_init() to populate the defaults
20
- struct lm_ggml_threadpool_params {
21
- bool cpumask[LM_GGML_MAX_N_THREADS]; // mask of cpu cores (all-zeros means use default affinity settings)
22
- int n_threads; // number of threads
23
- enum lm_ggml_sched_priority prio; // thread priority
24
- uint32_t poll; // polling level (0 - no polling, 100 - aggressive polling)
25
- bool strict_cpu; // strict cpu placement
26
- bool paused; // start in paused state
27
- };
28
-
29
- struct lm_ggml_threadpool; // forward declaration, see ggml.c
30
-
31
- typedef struct lm_ggml_threadpool * lm_ggml_threadpool_t;
32
-
33
- // the compute plan that needs to be prepared for lm_ggml_graph_compute()
34
- // since https://github.com/ggerganov/ggml/issues/287
35
- struct lm_ggml_cplan {
36
- size_t work_size; // size of work buffer, calculated by `lm_ggml_graph_plan()`
37
- uint8_t * work_data; // work buffer, to be allocated by caller before calling to `lm_ggml_graph_compute()`
38
-
39
- int n_threads;
40
- struct lm_ggml_threadpool * threadpool;
41
-
42
- // abort lm_ggml_graph_compute when true
43
- lm_ggml_abort_callback abort_callback;
44
- void * abort_callback_data;
45
- };
46
-
47
- // numa strategies
48
- enum lm_ggml_numa_strategy {
49
- LM_GGML_NUMA_STRATEGY_DISABLED = 0,
50
- LM_GGML_NUMA_STRATEGY_DISTRIBUTE = 1,
51
- LM_GGML_NUMA_STRATEGY_ISOLATE = 2,
52
- LM_GGML_NUMA_STRATEGY_NUMACTL = 3,
53
- LM_GGML_NUMA_STRATEGY_MIRROR = 4,
54
- LM_GGML_NUMA_STRATEGY_COUNT
55
- };
56
-
57
- LM_GGML_API void lm_ggml_numa_init(enum lm_ggml_numa_strategy numa); // call once for better performance on NUMA systems
58
- LM_GGML_API bool lm_ggml_is_numa(void); // true if init detected that system has >1 NUMA node
59
-
60
- LM_GGML_API struct lm_ggml_tensor * lm_ggml_new_i32(struct lm_ggml_context * ctx, int32_t value);
61
- LM_GGML_API struct lm_ggml_tensor * lm_ggml_new_f32(struct lm_ggml_context * ctx, float value);
62
-
63
- LM_GGML_API struct lm_ggml_tensor * lm_ggml_set_i32 (struct lm_ggml_tensor * tensor, int32_t value);
64
- LM_GGML_API struct lm_ggml_tensor * lm_ggml_set_f32 (struct lm_ggml_tensor * tensor, float value);
65
-
66
- LM_GGML_API int32_t lm_ggml_get_i32_1d(const struct lm_ggml_tensor * tensor, int i);
67
- LM_GGML_API void lm_ggml_set_i32_1d(const struct lm_ggml_tensor * tensor, int i, int32_t value);
68
-
69
- LM_GGML_API int32_t lm_ggml_get_i32_nd(const struct lm_ggml_tensor * tensor, int i0, int i1, int i2, int i3);
70
- LM_GGML_API void lm_ggml_set_i32_nd(const struct lm_ggml_tensor * tensor, int i0, int i1, int i2, int i3, int32_t value);
71
-
72
- LM_GGML_API float lm_ggml_get_f32_1d(const struct lm_ggml_tensor * tensor, int i);
73
- LM_GGML_API void lm_ggml_set_f32_1d(const struct lm_ggml_tensor * tensor, int i, float value);
74
-
75
- LM_GGML_API float lm_ggml_get_f32_nd(const struct lm_ggml_tensor * tensor, int i0, int i1, int i2, int i3);
76
- LM_GGML_API void lm_ggml_set_f32_nd(const struct lm_ggml_tensor * tensor, int i0, int i1, int i2, int i3, float value);
77
-
78
- LM_GGML_API struct lm_ggml_threadpool_params lm_ggml_threadpool_params_default(int n_threads);
79
- LM_GGML_API void lm_ggml_threadpool_params_init (struct lm_ggml_threadpool_params * p, int n_threads);
80
- LM_GGML_API bool lm_ggml_threadpool_params_match (const struct lm_ggml_threadpool_params * p0, const struct lm_ggml_threadpool_params * p1);
81
- LM_GGML_API struct lm_ggml_threadpool * lm_ggml_threadpool_new (struct lm_ggml_threadpool_params * params);
82
- LM_GGML_API void lm_ggml_threadpool_free (struct lm_ggml_threadpool * threadpool);
83
- LM_GGML_API int lm_ggml_threadpool_get_n_threads(struct lm_ggml_threadpool * threadpool);
84
- LM_GGML_API void lm_ggml_threadpool_pause (struct lm_ggml_threadpool * threadpool);
85
- LM_GGML_API void lm_ggml_threadpool_resume (struct lm_ggml_threadpool * threadpool);
86
-
87
- // lm_ggml_graph_plan() has to be called before lm_ggml_graph_compute()
88
- // when plan.work_size > 0, caller must allocate memory for plan.work_data
89
- LM_GGML_API struct lm_ggml_cplan lm_ggml_graph_plan(
90
- const struct lm_ggml_cgraph * cgraph,
91
- int n_threads, /* = LM_GGML_DEFAULT_N_THREADS */
92
- struct lm_ggml_threadpool * threadpool /* = NULL */ );
93
- LM_GGML_API enum lm_ggml_status lm_ggml_graph_compute(struct lm_ggml_cgraph * cgraph, struct lm_ggml_cplan * cplan);
94
-
95
- // same as lm_ggml_graph_compute() but the work data is allocated as a part of the context
96
- // note: the drawback of this API is that you must have ensured that the context has enough memory for the work data
97
- LM_GGML_API enum lm_ggml_status lm_ggml_graph_compute_with_ctx(struct lm_ggml_context * ctx, struct lm_ggml_cgraph * cgraph, int n_threads);
98
-
99
- // TODO: move to backend interface
100
- LM_GGML_API int lm_ggml_cpu_has_neon (void);
101
- LM_GGML_API int lm_ggml_cpu_has_sve (void);
102
- LM_GGML_API int lm_ggml_cpu_has_matmul_int8(void);
103
- // get the sve vector length in bytes
104
- LM_GGML_API int lm_ggml_cpu_get_sve_cnt(void);
105
-
106
- // Internal types and functions exposed for tests and benchmarks
107
-
108
- typedef void (*lm_ggml_from_float_to_mat_t)
109
- (const float * LM_GGML_RESTRICT x, void * LM_GGML_RESTRICT y, int64_t nr, int64_t k, int64_t bs);
110
- typedef void (*lm_ggml_vec_dot_t) (int n, float * LM_GGML_RESTRICT s, size_t bs, const void * LM_GGML_RESTRICT x, size_t bx,
111
- const void * LM_GGML_RESTRICT y, size_t by, int nrc);
112
- typedef void (*lm_ggml_gemv_t) (int n, float * LM_GGML_RESTRICT s, size_t bs, const void * LM_GGML_RESTRICT x,
113
- const void * LM_GGML_RESTRICT y, int nr, int nc);
114
- typedef void (*lm_ggml_gemm_t) (int n, float * LM_GGML_RESTRICT s, size_t bs, const void * LM_GGML_RESTRICT x,
115
- const void * LM_GGML_RESTRICT y, int nr, int nc);
116
-
117
- struct lm_ggml_type_traits_cpu {
118
- lm_ggml_from_float_to_mat_t from_float_to_mat;
119
- lm_ggml_vec_dot_t vec_dot;
120
- enum lm_ggml_type vec_dot_type;
121
- int64_t nrows; // number of rows to process simultaneously
122
- int64_t ncols; // number of columns to process simultaneously
123
- lm_ggml_gemv_t gemv;
124
- lm_ggml_gemm_t gemm;
125
- };
126
-
127
- LM_GGML_API const struct lm_ggml_type_traits_cpu * lm_ggml_get_type_traits_cpu(enum lm_ggml_type type);
128
-
129
- LM_GGML_API void lm_ggml_cpu_init(void);
130
-
131
- //
132
- // CPU backend
133
- //
134
-
135
- LM_GGML_API lm_ggml_backend_t lm_ggml_backend_cpu_init(void);
136
-
137
- LM_GGML_API bool lm_ggml_backend_is_cpu (lm_ggml_backend_t backend);
138
- LM_GGML_API void lm_ggml_backend_cpu_set_n_threads (lm_ggml_backend_t backend_cpu, int n_threads);
139
- LM_GGML_API void lm_ggml_backend_cpu_set_threadpool (lm_ggml_backend_t backend_cpu, lm_ggml_threadpool_t threadpool);
140
- LM_GGML_API void lm_ggml_backend_cpu_set_abort_callback(lm_ggml_backend_t backend_cpu, lm_ggml_abort_callback abort_callback, void * abort_callback_data);
141
-
142
- LM_GGML_API lm_ggml_backend_reg_t lm_ggml_backend_cpu_reg(void);
143
-
144
- #ifdef LM_GGML_USE_CPU_HBM
145
- LM_GGML_API lm_ggml_backend_buffer_type_t lm_ggml_backend_cpu_hbm_buffer_type(void);
146
- #endif
147
-
148
- #ifdef __cplusplus
149
- }
150
- #endif
1
+ #pragma once
2
+
3
+ #include "ggml.h"
4
+ #include "ggml-backend.h"
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ // Scheduling priorities
11
+ enum lm_ggml_sched_priority {
12
+ LM_GGML_SCHED_PRIO_NORMAL,
13
+ LM_GGML_SCHED_PRIO_MEDIUM,
14
+ LM_GGML_SCHED_PRIO_HIGH,
15
+ LM_GGML_SCHED_PRIO_REALTIME
16
+ };
17
+
18
+ // Threadpool params
19
+ // Use lm_ggml_threadpool_params_default() or lm_ggml_threadpool_params_init() to populate the defaults
20
+ struct lm_ggml_threadpool_params {
21
+ bool cpumask[LM_GGML_MAX_N_THREADS]; // mask of cpu cores (all-zeros means use default affinity settings)
22
+ int n_threads; // number of threads
23
+ enum lm_ggml_sched_priority prio; // thread priority
24
+ uint32_t poll; // polling level (0 - no polling, 100 - aggressive polling)
25
+ bool strict_cpu; // strict cpu placement
26
+ bool paused; // start in paused state
27
+ };
28
+
29
+ struct lm_ggml_threadpool; // forward declaration, see ggml.c
30
+
31
+ typedef struct lm_ggml_threadpool * lm_ggml_threadpool_t;
32
+
33
+ // the compute plan that needs to be prepared for lm_ggml_graph_compute()
34
+ // since https://github.com/ggerganov/ggml/issues/287
35
+ struct lm_ggml_cplan {
36
+ size_t work_size; // size of work buffer, calculated by `lm_ggml_graph_plan()`
37
+ uint8_t * work_data; // work buffer, to be allocated by caller before calling to `lm_ggml_graph_compute()`
38
+
39
+ int n_threads;
40
+ struct lm_ggml_threadpool * threadpool;
41
+
42
+ // abort lm_ggml_graph_compute when true
43
+ lm_ggml_abort_callback abort_callback;
44
+ void * abort_callback_data;
45
+ };
46
+
47
+ // numa strategies
48
+ enum lm_ggml_numa_strategy {
49
+ LM_GGML_NUMA_STRATEGY_DISABLED = 0,
50
+ LM_GGML_NUMA_STRATEGY_DISTRIBUTE = 1,
51
+ LM_GGML_NUMA_STRATEGY_ISOLATE = 2,
52
+ LM_GGML_NUMA_STRATEGY_NUMACTL = 3,
53
+ LM_GGML_NUMA_STRATEGY_MIRROR = 4,
54
+ LM_GGML_NUMA_STRATEGY_COUNT
55
+ };
56
+
57
+ LM_GGML_BACKEND_API void lm_ggml_numa_init(enum lm_ggml_numa_strategy numa); // call once for better performance on NUMA systems
58
+ LM_GGML_BACKEND_API bool lm_ggml_is_numa(void); // true if init detected that system has >1 NUMA node
59
+
60
+ LM_GGML_BACKEND_API struct lm_ggml_tensor * lm_ggml_new_i32(struct lm_ggml_context * ctx, int32_t value);
61
+ LM_GGML_BACKEND_API struct lm_ggml_tensor * lm_ggml_new_f32(struct lm_ggml_context * ctx, float value);
62
+
63
+ LM_GGML_BACKEND_API struct lm_ggml_tensor * lm_ggml_set_i32 (struct lm_ggml_tensor * tensor, int32_t value);
64
+ LM_GGML_BACKEND_API struct lm_ggml_tensor * lm_ggml_set_f32 (struct lm_ggml_tensor * tensor, float value);
65
+
66
+ LM_GGML_BACKEND_API int32_t lm_ggml_get_i32_1d(const struct lm_ggml_tensor * tensor, int i);
67
+ LM_GGML_BACKEND_API void lm_ggml_set_i32_1d(const struct lm_ggml_tensor * tensor, int i, int32_t value);
68
+
69
+ LM_GGML_BACKEND_API int32_t lm_ggml_get_i32_nd(const struct lm_ggml_tensor * tensor, int i0, int i1, int i2, int i3);
70
+ LM_GGML_BACKEND_API void lm_ggml_set_i32_nd(const struct lm_ggml_tensor * tensor, int i0, int i1, int i2, int i3, int32_t value);
71
+
72
+ LM_GGML_BACKEND_API float lm_ggml_get_f32_1d(const struct lm_ggml_tensor * tensor, int i);
73
+ LM_GGML_BACKEND_API void lm_ggml_set_f32_1d(const struct lm_ggml_tensor * tensor, int i, float value);
74
+
75
+ LM_GGML_BACKEND_API float lm_ggml_get_f32_nd(const struct lm_ggml_tensor * tensor, int i0, int i1, int i2, int i3);
76
+ LM_GGML_BACKEND_API void lm_ggml_set_f32_nd(const struct lm_ggml_tensor * tensor, int i0, int i1, int i2, int i3, float value);
77
+
78
+ LM_GGML_BACKEND_API struct lm_ggml_threadpool_params lm_ggml_threadpool_params_default(int n_threads);
79
+ LM_GGML_BACKEND_API void lm_ggml_threadpool_params_init (struct lm_ggml_threadpool_params * p, int n_threads);
80
+ LM_GGML_BACKEND_API bool lm_ggml_threadpool_params_match (const struct lm_ggml_threadpool_params * p0, const struct lm_ggml_threadpool_params * p1);
81
+ LM_GGML_BACKEND_API struct lm_ggml_threadpool * lm_ggml_threadpool_new (struct lm_ggml_threadpool_params * params);
82
+ LM_GGML_BACKEND_API void lm_ggml_threadpool_free (struct lm_ggml_threadpool * threadpool);
83
+ LM_GGML_BACKEND_API int lm_ggml_threadpool_get_n_threads(struct lm_ggml_threadpool * threadpool);
84
+ LM_GGML_BACKEND_API void lm_ggml_threadpool_pause (struct lm_ggml_threadpool * threadpool);
85
+ LM_GGML_BACKEND_API void lm_ggml_threadpool_resume (struct lm_ggml_threadpool * threadpool);
86
+
87
+ // lm_ggml_graph_plan() has to be called before lm_ggml_graph_compute()
88
+ // when plan.work_size > 0, caller must allocate memory for plan.work_data
89
+ LM_GGML_BACKEND_API struct lm_ggml_cplan lm_ggml_graph_plan(
90
+ const struct lm_ggml_cgraph * cgraph,
91
+ int n_threads, /* = LM_GGML_DEFAULT_N_THREADS */
92
+ struct lm_ggml_threadpool * threadpool /* = NULL */ );
93
+ LM_GGML_BACKEND_API enum lm_ggml_status lm_ggml_graph_compute(struct lm_ggml_cgraph * cgraph, struct lm_ggml_cplan * cplan);
94
+
95
+ // same as lm_ggml_graph_compute() but the work data is allocated as a part of the context
96
+ // note: the drawback of this API is that you must have ensured that the context has enough memory for the work data
97
+ LM_GGML_BACKEND_API enum lm_ggml_status lm_ggml_graph_compute_with_ctx(struct lm_ggml_context * ctx, struct lm_ggml_cgraph * cgraph, int n_threads);
98
+
99
+ //
100
+ // system info
101
+ //
102
+
103
+ // x86
104
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_sse3 (void);
105
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_ssse3 (void);
106
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_avx (void);
107
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_avx2 (void);
108
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_f16c (void);
109
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_fma (void);
110
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_avx_vnni (void);
111
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_avx512 (void);
112
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_avx512_vbmi(void);
113
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_avx512_vnni(void);
114
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_avx512_bf16(void);
115
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_amx_int8 (void);
116
+ // ARM
117
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_neon (void);
118
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_arm_fma (void);
119
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_fp16_va (void);
120
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_matmul_int8(void);
121
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_sve (void);
122
+ LM_GGML_BACKEND_API int lm_ggml_cpu_get_sve_cnt (void); // sve vector length in bytes
123
+ // other
124
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_riscv_v (void);
125
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_vsx (void);
126
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_wasm_simd (void);
127
+ LM_GGML_BACKEND_API int lm_ggml_cpu_has_llamafile (void);
128
+
129
+ // Internal types and functions exposed for tests and benchmarks
130
+
131
+ typedef void (*lm_ggml_from_float_to_mat_t)
132
+ (const float * LM_GGML_RESTRICT x, void * LM_GGML_RESTRICT y, int64_t nr, int64_t k, int64_t bs);
133
+ typedef void (*lm_ggml_vec_dot_t) (int n, float * LM_GGML_RESTRICT s, size_t bs, const void * LM_GGML_RESTRICT x, size_t bx,
134
+ const void * LM_GGML_RESTRICT y, size_t by, int nrc);
135
+ typedef void (*lm_ggml_gemv_t) (int n, float * LM_GGML_RESTRICT s, size_t bs, const void * LM_GGML_RESTRICT x,
136
+ const void * LM_GGML_RESTRICT y, int nr, int nc);
137
+ typedef void (*lm_ggml_gemm_t) (int n, float * LM_GGML_RESTRICT s, size_t bs, const void * LM_GGML_RESTRICT x,
138
+ const void * LM_GGML_RESTRICT y, int nr, int nc);
139
+
140
+ struct lm_ggml_type_traits_cpu {
141
+ lm_ggml_from_float_t from_float;
142
+ lm_ggml_from_float_to_mat_t from_float_to_mat;
143
+ lm_ggml_vec_dot_t vec_dot;
144
+ enum lm_ggml_type vec_dot_type;
145
+ int64_t nrows; // number of rows to process simultaneously
146
+ int64_t ncols; // number of columns to process simultaneously
147
+ lm_ggml_gemv_t gemv;
148
+ lm_ggml_gemm_t gemm;
149
+ };
150
+
151
+ LM_GGML_BACKEND_API const struct lm_ggml_type_traits_cpu * lm_ggml_get_type_traits_cpu(enum lm_ggml_type type);
152
+
153
+ LM_GGML_BACKEND_API void lm_ggml_cpu_init(void);
154
+
155
+ //
156
+ // CPU backend
157
+ //
158
+
159
+ LM_GGML_BACKEND_API lm_ggml_backend_t lm_ggml_backend_cpu_init(void);
160
+
161
+ LM_GGML_BACKEND_API bool lm_ggml_backend_is_cpu (lm_ggml_backend_t backend);
162
+ LM_GGML_BACKEND_API void lm_ggml_backend_cpu_set_n_threads (lm_ggml_backend_t backend_cpu, int n_threads);
163
+ LM_GGML_BACKEND_API void lm_ggml_backend_cpu_set_threadpool (lm_ggml_backend_t backend_cpu, lm_ggml_threadpool_t threadpool);
164
+ LM_GGML_BACKEND_API void lm_ggml_backend_cpu_set_abort_callback(lm_ggml_backend_t backend_cpu, lm_ggml_abort_callback abort_callback, void * abort_callback_data);
165
+
166
+ LM_GGML_BACKEND_API lm_ggml_backend_reg_t lm_ggml_backend_cpu_reg(void);
167
+
168
+ #ifdef LM_GGML_USE_CPU_HBM
169
+ LM_GGML_BACKEND_API lm_ggml_backend_buffer_type_t lm_ggml_backend_cpu_hbm_buffer_type(void);
170
+ #endif
171
+
172
+ LM_GGML_BACKEND_API lm_ggml_backend_buffer_type_t lm_ggml_backend_cpu_aarch64_buffer_type(void);
173
+ LM_GGML_BACKEND_API bool lm_ggml_backend_cpu_buft_is_aarch64(lm_ggml_backend_buffer_type_t buft);
174
+
175
+ #ifdef __cplusplus
176
+ }
177
+ #endif