Files
wehub-resource-sync ec436095dd
Book-CI / test (macos-latest) (push) Has been cancelled
Book-CI / test (ubuntu-latest) (push) Has been cancelled
Book-CI / test (windows-latest) (push) Has been cancelled
Release Fake Tag / publish (push) Has been cancelled
Deploy / deploy (macos-latest) (push) Has been cancelled
Deploy / deploy (ubuntu-latest) (push) Has been cancelled
Deploy / deploy (windows-latest) (push) Has been cancelled
Release to PyPI / Build & publish sglang-kt (push) Has been cancelled
Release to PyPI / Build kt-kernel (Python 3.11) (push) Has been cancelled
Release to PyPI / Build kt-kernel (Python 3.12) (push) Has been cancelled
Release to PyPI / Publish kt-kernel to PyPI (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:30:03 +08:00

38 lines
1.0 KiB
C

/**
* @Description :
* @Author : chenht2022
* @Date : 2024-07-12 10:07:58
* @Version : 1.0.0
* @LastEditors : chenht2022
* @LastEditTime : 2024-07-25 10:34:55
* @Copyright (c) 2024 by KVCache.AI, All Rights Reserved.
**/
#ifndef CPUINFER_CONVERSION_H
#define CPUINFER_CONVERSION_H
#include <memory.h>
#include "llama.cpp/ggml-quants.h"
#include "llama.cpp/ggml.h"
inline void to_float(const void* input, float* output, int size, ggml_type type) {
if (type == ggml_type::GGML_TYPE_F32) {
memcpy(output, input, size * sizeof(float));
} else {
if (type == ggml_type::GGML_TYPE_Q8_K) {
dequantize_row_q8_K((block_q8_K*)input, output, size);
} else {
ggml_internal_get_type_traits(type).to_float(input, output, size);
}
}
}
inline void from_float(const float* input, void* output, int size, ggml_type type) {
if (type == ggml_type::GGML_TYPE_F32) {
memcpy(output, input, size * sizeof(float));
} else {
ggml_internal_get_type_traits(type).from_float(input, output, size);
}
}
#endif