* move ggml-cpu-aarch64 to repack * split quantize_row_q8_0/1 * split helper functions * split ggml_vec_dot_q4_0_q8_0 * split ggml_vec_dot_q4_1_q8_1 * split ggml_vec_dot_q5_0_q8_0 * split ggml_vec_dot_q5_1_q8_1 * split ggml_vec_dot_q8_0_q8_0 * split ggml_vec_dot_tq1_0_q8_K * split ggml_vec_dot_tq2_0_q8_K * split ggml_vec_dot_q2_K_q8_K * split ggml_vec_dot_q3_K_q8_K * split ggml_vec_dot_q4_K_q8_K * split ggml_vec_dot_q5_K_q8_K * split ggml_vec_dot_q6_K_q8_K * split ggml_vec_dot_iq2_xxs_q8_K * split ggml_vec_dot_iq2_xs_q8_K * split ggml_vec_dot_iq2_s_q8_K * split ggml_vec_dot_iq3_xxs_q8_K * split ggml_vec_dot_iq3_s_q8_K * split ggml_vec_dot_iq1_s_q8_K * split ggml_vec_dot_iq1_m_q8_K * split ggml_vec_dot_iq4_nl_q8_0 * split ggml_vec_dot_iq4_xs_q8_K * fix typos * fix missing prototypes * rename ggml-cpu-quants.c * rename ggml-cpu-traits * rename arm folder * move cpu-feats-x86.cpp * rename ggml-cpu-hbm * update arm detection macro in quants.c * move iq quant tables * split ggml_quantize_mat_q8_0/K * split ggml_gemv_* * split ggml_gemm_* * rename namespace aarch64 to repack * use weak aliases to replace test macros * rename GGML_CPU_AARCH64 to GGML_CPU_REPACK * rename more aarch64 to repack * clean up rebase leftover * fix compilation errors * remove trailing spaces * try to fix clang compilation errors * try to fix clang compilation errors again * try to fix clang compilation errors, 3rd attempt * try to fix clang compilation errors, 4th attempt * try to fix clang compilation errors, 5th attempt * try to fix clang compilation errors, 6th attempt * try to fix clang compilation errors, 7th attempt * try to fix clang compilation errors, 8th attempt * try to fix clang compilation errors, 9th attempt * more cleanup * fix compilation errors * fix apple targets * fix a typo in arm version of ggml_vec_dot_q4_K_q8_K Co-authored-by: Georgi Gerganov <ggerganov@gmail.com> --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
73 lines
1.8 KiB
C++
73 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include "ggml.h"
|
|
#include "traits.h"
|
|
#include "ggml-cpu-impl.h"
|
|
#include "ggml-impl.h"
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#include <utility>
|
|
|
|
// convenience functions/macros for use in template calls
|
|
// note: these won't be required after the 'traits' lookup table is used.
|
|
static inline ggml_fp16_t f32_to_f16(float x) {
|
|
return GGML_FP32_TO_FP16(x);
|
|
}
|
|
|
|
static inline float f16_to_f32(ggml_fp16_t x) {
|
|
return GGML_FP16_TO_FP32(x);
|
|
}
|
|
|
|
static inline ggml_bf16_t f32_to_bf16(float x) {
|
|
return GGML_FP32_TO_BF16(x);
|
|
}
|
|
|
|
static inline float bf16_to_f32(ggml_bf16_t x) {
|
|
return GGML_BF16_TO_FP32(x);
|
|
}
|
|
|
|
static inline float f32_to_f32(float x) {
|
|
return x;
|
|
}
|
|
|
|
// TODO - merge this into the traits table, after using row-based conversions
|
|
template <class T>
|
|
struct type_conversion_table;
|
|
|
|
template <>
|
|
struct type_conversion_table<ggml_fp16_t> {
|
|
static constexpr float (*to_f32)(ggml_fp16_t) = f16_to_f32;
|
|
static constexpr ggml_fp16_t (*from_f32)(float) = f32_to_f16;
|
|
};
|
|
|
|
template <>
|
|
struct type_conversion_table<float> {
|
|
static constexpr float (*to_f32)(float) = f32_to_f32;
|
|
static constexpr float (*from_f32)(float) = f32_to_f32;
|
|
};
|
|
|
|
template <>
|
|
struct type_conversion_table<ggml_bf16_t> {
|
|
static constexpr float (*to_f32)(ggml_bf16_t) = bf16_to_f32;
|
|
static constexpr ggml_bf16_t (*from_f32)(float) = f32_to_bf16;
|
|
};
|
|
|
|
static std::pair<int64_t, int64_t> get_thread_range(const struct ggml_compute_params * params, const struct ggml_tensor * src0) {
|
|
const int64_t ith = params->ith;
|
|
const int64_t nth = params->nth;
|
|
|
|
const int64_t nr = ggml_nrows(src0);
|
|
|
|
// rows per thread
|
|
const int64_t dr = (nr + nth - 1)/nth;
|
|
|
|
// row range for this thread
|
|
const int64_t ir0 = dr*ith;
|
|
const int64_t ir1 = MIN(ir0 + dr, nr);
|
|
|
|
return {ir0, ir1};
|
|
}
|
|
|
|
#endif
|