mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-10-31 08:51:55 +00:00 
			
		
		
		
	ggml : support GGML_TYPE_F32 ".from_float" trait
This commit is contained in:
		| @@ -133,6 +133,7 @@ extern "C" { | |||||||
|  |  | ||||||
|     GGML_BACKEND_API ggml_backend_reg_t ggml_backend_cpu_reg(void); |     GGML_BACKEND_API ggml_backend_reg_t ggml_backend_cpu_reg(void); | ||||||
|  |  | ||||||
|  |     GGML_BACKEND_API void ggml_cpu_fp32_to_fp32(const float *,       float *, int64_t); | ||||||
|     GGML_BACKEND_API void ggml_cpu_fp32_to_fp16(const float *, ggml_fp16_t *, int64_t); |     GGML_BACKEND_API void ggml_cpu_fp32_to_fp16(const float *, ggml_fp16_t *, int64_t); | ||||||
|     GGML_BACKEND_API void ggml_cpu_fp16_to_fp32(const ggml_fp16_t *, float *, int64_t); |     GGML_BACKEND_API void ggml_cpu_fp16_to_fp32(const ggml_fp16_t *, float *, int64_t); | ||||||
|     GGML_BACKEND_API void ggml_cpu_fp32_to_bf16(const float *, ggml_bf16_t *, int64_t); |     GGML_BACKEND_API void ggml_cpu_fp32_to_bf16(const float *, ggml_bf16_t *, int64_t); | ||||||
|   | |||||||
| @@ -192,6 +192,7 @@ typedef pthread_t ggml_thread_t; | |||||||
|  |  | ||||||
| static const struct ggml_type_traits_cpu type_traits_cpu[GGML_TYPE_COUNT] = { | static const struct ggml_type_traits_cpu type_traits_cpu[GGML_TYPE_COUNT] = { | ||||||
|     [GGML_TYPE_F32] = { |     [GGML_TYPE_F32] = { | ||||||
|  |         .from_float               = (ggml_from_float_t) ggml_cpu_fp32_to_fp32, | ||||||
|         .vec_dot                  = (ggml_vec_dot_t) ggml_vec_dot_f32, |         .vec_dot                  = (ggml_vec_dot_t) ggml_vec_dot_f32, | ||||||
|         .vec_dot_type             = GGML_TYPE_F32, |         .vec_dot_type             = GGML_TYPE_F32, | ||||||
|         .nrows                    = 1, |         .nrows                    = 1, | ||||||
| @@ -3126,6 +3127,10 @@ enum ggml_status ggml_graph_compute_with_ctx(struct ggml_context * ctx, struct g | |||||||
|     return ggml_graph_compute(cgraph, &cplan); |     return ggml_graph_compute(cgraph, &cplan); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void ggml_cpu_fp32_to_fp32(const float * x, float * y, int64_t n) { | ||||||
|  |     memcpy(y, x, n * sizeof(float)); | ||||||
|  | } | ||||||
|  |  | ||||||
| void ggml_cpu_fp32_to_fp16(const float * x, ggml_fp16_t * y, int64_t n) { | void ggml_cpu_fp32_to_fp16(const float * x, ggml_fp16_t * y, int64_t n) { | ||||||
|     int64_t i = 0; |     int64_t i = 0; | ||||||
| #if defined(__F16C__) | #if defined(__F16C__) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Georgi Gerganov
					Georgi Gerganov