Skip to content

Commit 2c8719b

Browse files
committed
ggml : support GGML_TYPE_F32 ".from_float" trait
1 parent ddf3b31 commit 2c8719b

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

ggml/include/ggml-cpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ extern "C" {
133133

134134
GGML_BACKEND_API ggml_backend_reg_t ggml_backend_cpu_reg(void);
135135

136+
GGML_BACKEND_API void ggml_cpu_fp32_to_fp32(const float *, float *, int64_t);
136137
GGML_BACKEND_API void ggml_cpu_fp32_to_fp16(const float *, ggml_fp16_t *, int64_t);
137138
GGML_BACKEND_API void ggml_cpu_fp16_to_fp32(const ggml_fp16_t *, float *, int64_t);
138139
GGML_BACKEND_API void ggml_cpu_fp32_to_bf16(const float *, ggml_bf16_t *, int64_t);

ggml/src/ggml-cpu/ggml-cpu.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ typedef pthread_t ggml_thread_t;
192192

193193
static const struct ggml_type_traits_cpu type_traits_cpu[GGML_TYPE_COUNT] = {
194194
[GGML_TYPE_F32] = {
195+
.from_float = (ggml_from_float_t) ggml_cpu_fp32_to_fp32,
195196
.vec_dot = (ggml_vec_dot_t) ggml_vec_dot_f32,
196197
.vec_dot_type = GGML_TYPE_F32,
197198
.nrows = 1,
@@ -3126,6 +3127,10 @@ enum ggml_status ggml_graph_compute_with_ctx(struct ggml_context * ctx, struct g
31263127
return ggml_graph_compute(cgraph, &cplan);
31273128
}
31283129

3130+
void ggml_cpu_fp32_to_fp32(const float * x, float * y, int64_t n) {
3131+
memcpy(y, x, n * sizeof(float));
3132+
}
3133+
31293134
void ggml_cpu_fp32_to_fp16(const float * x, ggml_fp16_t * y, int64_t n) {
31303135
int64_t i = 0;
31313136
#if defined(__F16C__)

0 commit comments

Comments
 (0)