cui-llama.rn 1.3.3 → 1.3.4
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.
- package/android/src/main/CMakeLists.txt +5 -7
- package/android/src/main/java/com/rnllama/LlamaContext.java +4 -4
- package/android/src/main/jni.cpp +9 -9
- package/cpp/common.cpp +21 -40
- package/cpp/common.h +21 -12
- package/cpp/ggml-backend-impl.h +38 -20
- package/cpp/ggml-backend-reg.cpp +216 -87
- package/cpp/ggml-backend.h +1 -0
- package/cpp/ggml-common.h +42 -48
- package/cpp/{ggml-cpu-aarch64.c → ggml-cpu-aarch64.cpp} +591 -152
- package/cpp/ggml-cpu-aarch64.h +2 -26
- package/cpp/ggml-cpu-traits.cpp +36 -0
- package/cpp/ggml-cpu-traits.h +38 -0
- package/cpp/ggml-cpu.c +14122 -13971
- package/cpp/ggml-cpu.cpp +618 -715
- package/cpp/ggml-cpu.h +0 -17
- package/cpp/ggml-impl.h +6 -6
- package/cpp/ggml-metal.m +482 -24
- package/cpp/ggml-quants.c +0 -9
- package/cpp/ggml-threading.h +4 -2
- package/cpp/ggml.c +132 -43
- package/cpp/ggml.h +44 -13
- package/cpp/llama-sampling.cpp +35 -90
- package/cpp/llama-vocab.cpp +2 -1
- package/cpp/llama.cpp +737 -233
- package/cpp/llama.h +20 -16
- package/cpp/sampling.cpp +11 -16
- package/cpp/speculative.cpp +4 -0
- package/cpp/unicode.cpp +51 -51
- package/cpp/unicode.h +9 -10
- package/lib/commonjs/index.js +38 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +36 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/NativeRNLlama.d.ts +2 -3
- package/lib/typescript/NativeRNLlama.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +36 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NativeRNLlama.ts +3 -3
- package/src/index.ts +46 -2
- package/cpp/amx/amx.cpp +0 -196
- package/cpp/amx/amx.h +0 -20
- package/cpp/amx/common.h +0 -101
- package/cpp/amx/mmq.cpp +0 -2524
- package/cpp/amx/mmq.h +0 -16
- package/cpp/ggml-aarch64.c +0 -129
- package/cpp/ggml-aarch64.h +0 -19
package/cpp/ggml-cpu-aarch64.h
CHANGED
@@ -1,32 +1,8 @@
|
|
1
1
|
#pragma once
|
2
2
|
|
3
|
+
#include "ggml-cpu-traits.h"
|
3
4
|
#include "ggml.h"
|
4
5
|
|
5
6
|
// GGML internal header
|
6
7
|
|
7
|
-
|
8
|
-
extern "C" {
|
9
|
-
#endif
|
10
|
-
|
11
|
-
// Quantization
|
12
|
-
void quantize_mat_q8_0(const float * LM_GGML_RESTRICT x, void * LM_GGML_RESTRICT y, int64_t nrows, int64_t n_per_row, int64_t blck_size_interleave);
|
13
|
-
|
14
|
-
// GEMV
|
15
|
-
void lm_ggml_gemv_q4_0_4x4_q8_0(int n, float * LM_GGML_RESTRICT s, size_t bs, const void * LM_GGML_RESTRICT vx, const void * LM_GGML_RESTRICT vy, int nr, int nc);
|
16
|
-
void lm_ggml_gemv_q4_0_4x8_q8_0(int n, float * LM_GGML_RESTRICT s, size_t bs, const void * LM_GGML_RESTRICT vx, const void * LM_GGML_RESTRICT vy, int nr, int nc);
|
17
|
-
void lm_ggml_gemv_q4_0_8x8_q8_0(int n, float * LM_GGML_RESTRICT s, size_t bs, const void * LM_GGML_RESTRICT vx, const void * LM_GGML_RESTRICT vy, int nr, int nc);
|
18
|
-
void lm_ggml_gemv_iq4_nl_4x4_q8_0(int n, float * LM_GGML_RESTRICT s, size_t bs, const void * LM_GGML_RESTRICT vx, const void * LM_GGML_RESTRICT vy, int nr, int nc);
|
19
|
-
|
20
|
-
// GEMM
|
21
|
-
void lm_ggml_gemm_q4_0_4x4_q8_0(int n, float * LM_GGML_RESTRICT s, size_t bs, const void * LM_GGML_RESTRICT vx, const void * LM_GGML_RESTRICT vy, int nr, int nc);
|
22
|
-
void lm_ggml_gemm_q4_0_4x8_q8_0(int n, float * LM_GGML_RESTRICT s, size_t bs, const void * LM_GGML_RESTRICT vx, const void * LM_GGML_RESTRICT vy, int nr, int nc);
|
23
|
-
void lm_ggml_gemm_q4_0_8x8_q8_0(int n, float * LM_GGML_RESTRICT s, size_t bs, const void * LM_GGML_RESTRICT vx, const void * LM_GGML_RESTRICT vy, int nr, int nc);
|
24
|
-
void lm_ggml_gemm_iq4_nl_4x4_q8_0(int n, float * LM_GGML_RESTRICT s, size_t bs, const void * LM_GGML_RESTRICT vx, const void * LM_GGML_RESTRICT vy, int nr, int nc);
|
25
|
-
|
26
|
-
void lm_ggml_aarch64_repack_tensor(struct lm_ggml_tensor * cur, enum lm_ggml_type repack_type, const void * data, size_t data_size);
|
27
|
-
enum lm_ggml_type lm_ggml_aarch64_get_optimal_repack_type(const struct lm_ggml_tensor * cur);
|
28
|
-
|
29
|
-
#ifdef __cplusplus
|
30
|
-
}
|
31
|
-
#endif
|
32
|
-
|
8
|
+
lm_ggml_backend_buffer_type_t lm_ggml_backend_cpu_aarch64_buffer_type(void);
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#include "ggml-cpu-traits.h"
|
2
|
+
|
3
|
+
#include "ggml-backend-impl.h"
|
4
|
+
#include "ggml-backend.h"
|
5
|
+
|
6
|
+
namespace ggml::cpu {
|
7
|
+
tensor_traits::~tensor_traits() {}
|
8
|
+
|
9
|
+
extra_buffer_type::~extra_buffer_type() {}
|
10
|
+
} // namespace ggml::cpu
|
11
|
+
|
12
|
+
bool lm_ggml_cpu_extra_compute_forward(struct lm_ggml_compute_params * params, struct lm_ggml_tensor * op) {
|
13
|
+
for (auto extra : lm_ggml_backend_cpu_get_extra_buffers_type()) {
|
14
|
+
if (extra && extra->context) {
|
15
|
+
auto buf_extra = (ggml::cpu::extra_buffer_type *) extra->context;
|
16
|
+
auto tensor_traits = buf_extra->get_tensor_traits(op);
|
17
|
+
if (tensor_traits && tensor_traits->compute_forward(params, op)) {
|
18
|
+
return true;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
return false;
|
23
|
+
}
|
24
|
+
|
25
|
+
bool lm_ggml_cpu_extra_work_size(int n_threads, const struct lm_ggml_tensor * op, size_t * size) {
|
26
|
+
for (auto extra : lm_ggml_backend_cpu_get_extra_buffers_type()) {
|
27
|
+
if (extra && extra->context) {
|
28
|
+
auto buf_extra = (ggml::cpu::extra_buffer_type *) extra->context;
|
29
|
+
auto tensor_traits = buf_extra->get_tensor_traits(op);
|
30
|
+
if (tensor_traits && tensor_traits->work_size(n_threads, op, *size)) {
|
31
|
+
return true;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
return false;
|
36
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#pragma once
|
2
|
+
#include "ggml-backend-impl.h"
|
3
|
+
#include "ggml-cpu-impl.h"
|
4
|
+
#include "ggml.h"
|
5
|
+
|
6
|
+
#ifdef __cplusplus
|
7
|
+
# include <vector>
|
8
|
+
extern "C" {
|
9
|
+
#endif
|
10
|
+
|
11
|
+
// return true if op part of extra "accelerator"
|
12
|
+
bool lm_ggml_cpu_extra_compute_forward(struct lm_ggml_compute_params * params, struct lm_ggml_tensor * op);
|
13
|
+
bool lm_ggml_cpu_extra_work_size(int n_threads, const struct lm_ggml_tensor * op, size_t * size);
|
14
|
+
|
15
|
+
#ifdef __cplusplus
|
16
|
+
}
|
17
|
+
|
18
|
+
namespace ggml::cpu {
|
19
|
+
// register in tensor->extra
|
20
|
+
class tensor_traits {
|
21
|
+
public:
|
22
|
+
virtual ~tensor_traits();
|
23
|
+
virtual bool work_size(int n_threads, const struct lm_ggml_tensor * op, size_t & size) = 0;
|
24
|
+
virtual bool compute_forward(struct lm_ggml_compute_params * params, struct lm_ggml_tensor * op) = 0;
|
25
|
+
};
|
26
|
+
|
27
|
+
class extra_buffer_type {
|
28
|
+
public:
|
29
|
+
virtual ~extra_buffer_type();
|
30
|
+
virtual bool supports_op(lm_ggml_backend_dev_t dev, const struct lm_ggml_tensor * op) = 0;
|
31
|
+
virtual tensor_traits * get_tensor_traits(const struct lm_ggml_tensor * op) = 0;
|
32
|
+
};
|
33
|
+
} // namespace ggml::cpu
|
34
|
+
|
35
|
+
// implemented in ggml-cpu.cpp.
|
36
|
+
std::vector<lm_ggml_backend_buffer_type_t> & lm_ggml_backend_cpu_get_extra_buffers_type();
|
37
|
+
|
38
|
+
#endif
|