Team Ai
Apppublic

KBaba7/llama.cpp

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
llama-impl.h62 linesDownload Raw Back to src
1#pragma once2 3#include "ggml.h" // for ggml_log_level4 5#include <string>6#include <vector>7 8#ifdef __GNUC__9#ifdef __MINGW32__10#define LLAMA_ATTRIBUTE_FORMAT(...) __attribute__((format(gnu_printf, __VA_ARGS__)))11#else12#define LLAMA_ATTRIBUTE_FORMAT(...) __attribute__((format(printf, __VA_ARGS__)))13#endif14#else15#define LLAMA_ATTRIBUTE_FORMAT(...)16#endif17 18//19// logging20//21 22LLAMA_ATTRIBUTE_FORMAT(2, 3)23void llama_log_internal        (ggml_log_level level, const char * format, ...);24void llama_log_callback_default(ggml_log_level level, const char * text, void * user_data);25 26#define LLAMA_LOG(...)       llama_log_internal(GGML_LOG_LEVEL_NONE , __VA_ARGS__)27#define LLAMA_LOG_INFO(...)  llama_log_internal(GGML_LOG_LEVEL_INFO , __VA_ARGS__)28#define LLAMA_LOG_WARN(...)  llama_log_internal(GGML_LOG_LEVEL_WARN , __VA_ARGS__)29#define LLAMA_LOG_ERROR(...) llama_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)30#define LLAMA_LOG_DEBUG(...) llama_log_internal(GGML_LOG_LEVEL_DEBUG, __VA_ARGS__)31#define LLAMA_LOG_CONT(...)  llama_log_internal(GGML_LOG_LEVEL_CONT , __VA_ARGS__)32 33//34// helpers35//36 37template <typename T>38struct no_init {39    T value;40    no_init() { /* do nothing */ }41};42 43struct time_meas {44    time_meas(int64_t & t_acc, bool disable = false);45    ~time_meas();46 47    const int64_t t_start_us;48 49    int64_t & t_acc;50};51 52void replace_all(std::string & s, const std::string & search, const std::string & replace);53 54// TODO: rename to llama_format ?55LLAMA_ATTRIBUTE_FORMAT(1, 2)56std::string format(const char * fmt, ...);57 58std::string llama_format_tensor_shape(const std::vector<int64_t> & ne);59std::string llama_format_tensor_shape(const struct ggml_tensor * t);60 61std::string gguf_kv_to_str(const struct gguf_context * ctx_gguf, int i);62