fix includes with help from include-what-you-use

This commit is contained in:
cebtenzzre 2023-11-01 13:09:21 -04:00
parent 2b5136e1c2
commit 635e9fadfd
57 changed files with 311 additions and 235 deletions

View File

@ -1,20 +1,28 @@
#include "common.h" #include "common.h"
#include "ggml.h"
#include "llama.h" #include "llama.h"
#include "log.h"
#include "sampling.h"
#include <algorithm> #include <algorithm>
#include <cassert> #include <cctype>
#include <chrono>
#include <cinttypes>
#include <cmath> #include <cmath>
#include <cstring> #include <cstdlib>
#include <ctime> #include <ctime>
#include <exception>
#include <fstream> #include <fstream>
#include <iterator> #include <iterator>
#include <iostream>
#include <regex> #include <regex>
#include <sstream> #include <sstream>
#include <stdexcept>
#include <string> #include <string>
#include <thread>
#include <unordered_map>
#include <unordered_set> #include <unordered_set>
#include <utility>
#include <vector> #include <vector>
#include <cinttypes>
#if defined(__APPLE__) && defined(__MACH__) #if defined(__APPLE__) && defined(__MACH__)
#include <sys/types.h> #include <sys/types.h>
@ -32,9 +40,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <io.h> #include <io.h>
#else #else
#include <sys/ioctl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h>
#endif #endif
#if defined(_MSC_VER) #if defined(_MSC_VER)

View File

@ -3,19 +3,18 @@
#pragma once #pragma once
#include "llama.h" #include "llama.h"
#include "sampling.h" #include "sampling.h"
#define LOG_NO_FILE_LINE_FUNCTION #define LOG_NO_FILE_LINE_FUNCTION
#include "log.h" #include "log.h"
#include <cmath> #include <cmath>
#include <string> #include <cstdint>
#include <vector> #include <cstdio>
#include <random> #include <random>
#include <thread> #include <string>
#include <unordered_map>
#include <tuple> #include <tuple>
#include <vector>
#ifdef _WIN32 #ifdef _WIN32
#define DIRECTORY_SEPARATOR '\\' #define DIRECTORY_SEPARATOR '\\'
@ -68,7 +67,7 @@ struct gpt_params {
int32_t yarn_orig_ctx = 0; // YaRN original context length int32_t yarn_orig_ctx = 0; // YaRN original context length
int8_t rope_scaling_type = LLAMA_ROPE_SCALING_UNSPECIFIED; int8_t rope_scaling_type = LLAMA_ROPE_SCALING_UNSPECIFIED;
// // sampling parameters // sampling parameters
struct llama_sampling_params sparams; struct llama_sampling_params sparams;
std::string model = "models/7B/ggml-model-f16.gguf"; // model path std::string model = "models/7B/ggml-model-f16.gguf"; // model path

View File

@ -14,14 +14,13 @@
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 #define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
#endif #endif
#else #else
#include <climits> #include <clocale>
#include <cstdio>
#include <cwchar>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <unistd.h>
#include <wchar.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <termios.h> #include <termios.h>
#include <unistd.h>
#endif #endif
#define ANSI_COLOR_RED "\x1b[31m" #define ANSI_COLOR_RED "\x1b[31m"

View File

@ -1,6 +1,5 @@
#include "grammar-parser.h" #include "grammar-parser.h"
#include <cstdint> #include <cstdint>
#include <cwchar>
#include <string> #include <string>
#include <utility> #include <utility>
#include <stdexcept> #include <stdexcept>

View File

@ -10,11 +10,14 @@
// space ::= [ \t\n]* // space ::= [ \t\n]*
#pragma once #pragma once
#include "llama.h" #include "llama.h"
#include <vector>
#include <map>
#include <cstdint> #include <cstdint>
#include <cstdio>
#include <map>
#include <string> #include <string>
#include <vector>
namespace grammar_parser { namespace grammar_parser {
struct parse_state { struct parse_state {

View File

@ -1,5 +1,11 @@
#include "common.h"
#include "sampling.h" #include "sampling.h"
#include <algorithm>
#include <cstdio>
#include <map>
#include <utility>
struct llama_sampling_context * llama_sampling_init(const struct llama_sampling_params & params) { struct llama_sampling_context * llama_sampling_init(const struct llama_sampling_params & params) {
struct llama_sampling_context * result = new llama_sampling_context(); struct llama_sampling_context * result = new llama_sampling_context();

View File

@ -1,12 +1,12 @@
#pragma once #pragma once
#include "grammar-parser.h"
#include "llama.h" #include "llama.h"
#include "grammar-parser.h" #include <cstdint>
#include <string> #include <string>
#include <vector>
#include <unordered_map> #include <unordered_map>
#include <vector>
// sampling parameters // sampling parameters
typedef struct llama_sampling_params { typedef struct llama_sampling_params {
@ -56,8 +56,6 @@ struct llama_sampling_context {
std::vector<llama_token_data> cur; std::vector<llama_token_data> cur;
}; };
#include "common.h"
// Create a new sampling context instance. // Create a new sampling context instance.
struct llama_sampling_context * llama_sampling_init(const struct llama_sampling_params & params); struct llama_sampling_context * llama_sampling_init(const struct llama_sampling_params & params);

View File

@ -1,9 +1,19 @@
#include "train.h"
#include "common.h" #include "common.h"
#include "ggml.h"
#include "llama.h"
#include "train.h"
#include <algorithm>
#include <cerrno>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <locale>
#include <random> #include <random>
#include <sstream> #include <sstream>
#include <functional>
struct random_normal_distribution { struct random_normal_distribution {
std::mt19937 gen; std::mt19937 gen;

View File

@ -2,13 +2,14 @@
#pragma once #pragma once
#include <string>
#include <random>
#include <vector>
#include "ggml.h"
#include "llama.h" #include "llama.h"
#include <cstddef>
#include <cstdint>
#include <random>
#include <string>
#include <vector>
typedef std::string mt19937_state; typedef std::string mt19937_state;
struct train_state { struct train_state {

View File

@ -1,11 +1,13 @@
#include "ggml.h" #include "ggml.h"
#include "train.h" #include "train.h"
#include <vector> #include <algorithm>
#include <cassert> #include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <random>
#include <vector> #include <vector>
#if defined(_MSC_VER) #if defined(_MSC_VER)

View File

@ -1,10 +1,11 @@
#include "common.h" #include "common.h"
#include "ggml.h"
#include "llama.h" #include "llama.h"
#include <algorithm> #include <algorithm>
#include <cmath> #include <cstdint>
#include <cstdio> #include <cstdio>
#include <string> #include <cstdlib>
#include <vector> #include <vector>
// mutates the input string // mutates the input string

View File

@ -1,9 +1,11 @@
#include "common.h" #include "common.h"
#include "ggml.h"
#include "llama.h" #include "llama.h"
#include <algorithm> #include <algorithm>
#include <cmath> #include <cstdint>
#include <cstdio> #include <cstdio>
#include <cstdlib>
#include <string> #include <string>
#include <vector> #include <vector>

View File

@ -1,29 +1,14 @@
#include "common.h" #include "common.h"
#include "llama.h" #include "llama.h"
#include <algorithm>
#include <cassert> #include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio> #include <cstdio>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <tuple>
#include <vector> #include <vector>
#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
#include <signal.h>
#include <unistd.h>
#elif defined (_WIN32)
#define WIN32_LEAN_AND_MEAN
#ifndef NOMINMAX
# define NOMINMAX
#endif
#include <windows.h>
#include <signal.h>
#endif
// Used for debugging to print out beam tokens. // Used for debugging to print out beam tokens.
struct ostream_beam_view { struct ostream_beam_view {
llama_context * ctx; llama_context * ctx;

View File

@ -1,20 +1,11 @@
#include "common.h" #include "common.h"
#include "ggml.h" #include "ggml.h"
#include <locale.h>
#include <assert.h>
#include <math.h>
#include <cstring>
#include <cstdio>
#include <cinttypes> #include <cinttypes>
#include <unordered_map> #include <cstdio>
#include <queue> #include <cstdlib>
#include <string.h>
#include <cassert>
#include <fstream>
#include <string> #include <string>
#include <iterator> #include <vector>
#include <algorithm>
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma warning(disable: 4244 4267) // possible loss of data #pragma warning(disable: 4244 4267) // possible loss of data

View File

@ -1,19 +1,22 @@
#include "common.h"
#include "ggml.h" #include "ggml.h"
#include "llama.h" #include "llama.h"
#include "common.h"
#include <unordered_map>
#include <vector>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdarg>
#include <ctime>
#include <random>
#include <stdexcept>
#include <sstream>
#include <algorithm> #include <algorithm>
#include <cassert>
#include <cerrno>
#include <climits>
#include <cmath>
#include <cstdarg>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <string> #include <string>
#include <unordered_map>
#include <utility>
#include <vector>
// GGUF keys & tensor names. // GGUF keys & tensor names.

View File

@ -1,7 +1,12 @@
#include "common.h" #include "common.h"
#include "llama.h" #include "llama.h"
#include <algorithm>
#include <cstdio>
#include <ctime> #include <ctime>
#include <random>
#include <tuple>
#include <vector>
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma warning(disable: 4244 4267) // possible loss of data #pragma warning(disable: 4244 4267) // possible loss of data

View File

@ -1,11 +1,16 @@
#include "common.h" #include "common.h"
#include "ggml.h" #include "ggml.h"
#include "ggml-alloc.h" #include "ggml-alloc.h"
#include <vector> #include <algorithm>
#include <cerrno>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string> #include <string>
#include <thread> #include <thread>
#include <vector>
static const size_t tensor_alignment = 32; static const size_t tensor_alignment = 32;

View File

@ -1,19 +1,19 @@
#include "ggml.h"
#include "ggml-alloc.h"
#include "llama.h"
#include "common.h" #include "common.h"
#include "ggml-alloc.h"
#include "ggml.h"
#include "llama.h"
#include "train.h" #include "train.h"
#include <unordered_map>
#include <vector>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdarg>
#include <ctime>
#include <random>
#include <stdexcept>
#include <algorithm> #include <algorithm>
#include <cerrno>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <string> #include <string>
#include <vector>
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma warning(disable: 4244 4267) // possible loss of data #pragma warning(disable: 4244 4267) // possible loss of data

View File

@ -1,19 +1,17 @@
#include "common.h" #include "common.h"
#include "console.h" #include "console.h"
#include "llama.h" #include "llama.h"
#include "grammar-parser.h" #include "sampling.h"
#include <cassert> #include <algorithm>
#include <cinttypes>
#include <cmath>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstdlib>
#include <ctime> #include <ctime>
#include <fstream> #include <fstream>
#include <iostream> #include <random>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <tuple>
#include <vector> #include <vector>
#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) #if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))

View File

@ -1,26 +1,30 @@
#include "ggml.h"
#include "llama.h"
#include "common.h"
#include "ggml-cuda.h"
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <cassert> #include <cassert>
#include <cctype>
#include <chrono> #include <chrono>
#include <cinttypes> #include <cinttypes>
#include <clocale> #include <clocale>
#include <cmath> #include <cmath>
#include <cstdio> #include <cstdio>
#include <cstdlib>
#include <cstring> #include <cstring>
#include <ctime> #include <ctime>
#include <iterator> #include <iterator>
#include <map> #include <map>
#include <memory>
#include <numeric> #include <numeric>
#include <regex> #include <regex>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <utility>
#include <vector> #include <vector>
#include "ggml.h"
#include "llama.h"
#include "common.h"
#include "ggml-cuda.h"
// utils // utils
static uint64_t get_time_ns() { static uint64_t get_time_ns() {
using clock = std::chrono::high_resolution_clock; using clock = std::chrono::high_resolution_clock;

View File

@ -2,21 +2,23 @@
// so there might be still unnecessary artifacts hanging around // so there might be still unnecessary artifacts hanging around
// I'll gradually clean and extend it // I'll gradually clean and extend it
#include <cassert> #include "clip.h"
#include "ggml-alloc.h"
#include "ggml.h"
#include <algorithm>
#include <climits>
#include <cmath> #include <cmath>
#include <cstdarg>
#include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <fstream> #include <fstream>
#include <iostream>
#include <map>
#include <regex> #include <regex>
#include <stdexcept> #include <stdexcept>
#include <string>
#include <vector> #include <vector>
#include "clip.h"
#include "ggml.h"
#include "ggml-alloc.h"
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h" #include "stb_image.h"

View File

@ -1,7 +1,8 @@
#ifndef CLIP_H #ifndef CLIP_H
#define CLIP_H #define CLIP_H
#include "ggml.h" #include <stddef.h>
#include <stdint.h>
struct clip_ctx; struct clip_ctx;

View File

@ -1,11 +1,14 @@
#include "clip.h" #include "clip.h"
#include "llava-utils.h"
#include "common.h" #include "common.h"
#include "ggml.h"
#include "llama.h" #include "llama.h"
#include "llava-utils.h"
#include <cstdint>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <vector> #include <cstring>
#include <string>
static void show_additional_info(int /*argc*/, char ** argv) { static void show_additional_info(int /*argc*/, char ** argv) {
printf("\n example usage: %s -m <llava-v1.5-7b/ggml-model-q5_k.gguf> --mmproj <llava-v1.5-7b/mmproj-model-f16.gguf> --image <path/to/an/image.jpg> [--temp 0.1] [-p \"describe the image in detail.\"]\n", argv[0]); printf("\n example usage: %s -m <llava-v1.5-7b/ggml-model-q5_k.gguf> --mmproj <llava-v1.5-7b/mmproj-model-f16.gguf> --image <path/to/an/image.jpg> [--temp 0.1] [-p \"describe the image in detail.\"]\n", argv[0]);

View File

@ -1,18 +1,17 @@
#include "common.h" #include "common.h"
#include "console.h" #include "console.h"
#include "llama.h" #include "llama.h"
#include "sampling.h"
#include <cassert> #include <algorithm>
#include <cinttypes>
#include <cmath>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstdlib>
#include <ctime> #include <ctime>
#include <fstream> #include <fstream>
#include <iostream> #include <random>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <tuple>
#include <vector> #include <vector>
#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) #if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))

View File

@ -2,13 +2,20 @@
// The clients submite requests to the server and they are processed in parallel. // The clients submite requests to the server and they are processed in parallel.
#include "common.h" #include "common.h"
#include "ggml.h"
#include "llama.h" #include "llama.h"
#include "sampling.h"
#include <cmath> #include <algorithm>
#include <cctype>
#include <cstdint>
#include <cstdio> #include <cstdio>
#include <string> #include <cstdlib>
#include <vector>
#include <ctime> #include <ctime>
#include <istream>
#include <string>
#include <tuple>
#include <vector>
// trim whitespace from the beginning and end of a string // trim whitespace from the beginning and end of a string
static std::string trim(const std::string & str) { static std::string trim(const std::string & str) {

View File

@ -1,13 +1,20 @@
#include "common.h" #include "common.h"
#include "llama.h" #include "llama.h"
#include <algorithm>
#include <chrono>
#include <cmath> #include <cmath>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <ctime> #include <ctime>
#include <sstream> #include <iterator>
#include <thread>
#include <mutex> #include <mutex>
#include <random>
#include <sstream>
#include <string>
#include <thread>
#include <tuple>
#include <utility>
#include <vector> #include <vector>
#if defined(_MSC_VER) #if defined(_MSC_VER)

View File

@ -8,15 +8,16 @@
#include <cinttypes> #include <cinttypes>
#include <cmath> #include <cmath>
#include <cstdio> #include <cstdio>
#include <cstdlib>
#include <cstring> #include <cstring>
#include <map> #include <iterator>
#include <mutex>
#include <numeric> #include <numeric>
#include <regex> #include <regex>
#include <string> #include <string>
#include <unordered_map>
#include <vector>
#include <thread> #include <thread>
#include <mutex> #include <utility>
#include <vector>
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma warning(disable: 4244 4267) // possible loss of data #pragma warning(disable: 4244 4267) // possible loss of data

View File

@ -1,10 +1,14 @@
#include "common.h" #include "common.h"
#include "llama.h" #include "llama.h"
#include <cctype>
#include <cstdint>
#include <cstdio> #include <cstdio>
#include <cstdlib>
#include <cstring> #include <cstring>
#include <vector> #include <exception>
#include <string> #include <string>
#include <vector>
struct quant_option { struct quant_option {
std::string name; std::string name;

View File

@ -1,9 +1,11 @@
#include "common.h" #include "common.h"
#include "llama.h" #include "llama.h"
#include <vector> #include <cstdint>
#include <cstdio> #include <cstdio>
#include <chrono> #include <string>
#include <tuple>
#include <vector>
int main(int argc, char ** argv) { int main(int argc, char ** argv) {
gpt_params params; gpt_params params;

View File

@ -1,6 +1,7 @@
#include "common.h" #include "common.h"
#include "ggml.h"
#include "llama.h" #include "llama.h"
#include "grammar-parser.h" #include "sampling.h"
#include "../llava/clip.h" #include "../llava/clip.h"
@ -20,10 +21,28 @@
#include "completion.js.hpp" #include "completion.js.hpp"
#include "json-schema-to-grammar.mjs.hpp" #include "json-schema-to-grammar.mjs.hpp"
#include <cstddef> #include <algorithm>
#include <thread> #include <cctype>
#include <mutex>
#include <chrono> #include <chrono>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <exception>
#include <functional>
#include <istream>
#include <iterator>
#include <mutex>
#include <numeric>
#include <stdexcept>
#include <string>
#include <thread>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#ifndef SERVER_VERBOSE #ifndef SERVER_VERBOSE
#define SERVER_VERBOSE 1 #define SERVER_VERBOSE 1

View File

@ -1,9 +1,8 @@
#include "common.h" #include "common.h"
#include "ggml.h"
#include "llama.h" #include "llama.h"
#include <cmath>
#include <cstdio> #include <cstdio>
#include <string>
#include <vector> #include <vector>
int main(int argc, char ** argv) { int main(int argc, char ** argv) {

View File

@ -1,9 +1,13 @@
#include "common.h" #include "common.h"
#include "ggml.h"
#include "llama.h" #include "llama.h"
#include "sampling.h"
#include <cmath> #include <algorithm>
#include <cstdio> #include <cstdio>
#include <cstring>
#include <string> #include <string>
#include <tuple>
#include <vector> #include <vector>
#define SPEC_VOCAB_MAX_SIZE_DIFFERENCE 100 #define SPEC_VOCAB_MAX_SIZE_DIFFERENCE 100

View File

@ -1,19 +1,18 @@
#include "ggml.h"
#include "ggml-alloc.h"
#include "common.h" #include "common.h"
#include "train.h" #include "ggml-alloc.h"
#include "ggml.h"
#include "llama.h" #include "llama.h"
#include <unordered_map> #include "train.h"
#include <vector>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdarg>
#include <ctime>
#include <random>
#include <stdexcept>
#include <algorithm> #include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <string> #include <string>
#include <vector>
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma warning(disable: 4244 4267) // possible loss of data #pragma warning(disable: 4244 4267) // possible loss of data

View File

@ -1,8 +1,9 @@
#include "ggml-alloc.h" #include "ggml-alloc.h"
#include "ggml-backend.h" #include "ggml-backend.h"
#include "ggml.h" #include "ggml.h"
#include <assert.h> #include <assert.h>
#include <stdarg.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@ -2,6 +2,9 @@
#include "ggml.h" #include "ggml.h"
#include <stdbool.h>
#include <stddef.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -1,8 +1,5 @@
#include "ggml-backend.h" #include "ggml-backend.h"
#include "ggml-alloc.h"
#include <assert.h>
#include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@ -2,6 +2,9 @@
#include "ggml.h" #include "ggml.h"
#include <stdbool.h>
#include <stddef.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
#include "ggml.h"
// GGML internal header // GGML internal header
#include "ggml.h"
#include <assert.h> #include <assert.h>
#include <stddef.h> #include <stddef.h>
#include <stdbool.h> #include <stdbool.h>

View File

@ -1,10 +1,11 @@
#include "ggml-quants.h" #include "ggml-quants.h"
#include "ggml-impl.h" #include "ggml-impl.h"
#include <math.h>
#include <string.h>
#include <assert.h> #include <assert.h>
#include <float.h> #include <float.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
#ifdef __ARM_NEON #ifdef __ARM_NEON

View File

@ -1,11 +1,11 @@
#pragma once #pragma once
#include "ggml-impl.h"
// GGML internal header // GGML internal header
#include "ggml.h"
#include <assert.h>
#include <stdint.h> #include <stdint.h>
#include <stddef.h>
#define QK4_0 32 #define QK4_0 32
typedef struct { typedef struct {

10
ggml.c
View File

@ -1,6 +1,7 @@
#define _CRT_SECURE_NO_DEPRECATE // Disables ridiculous "unsafe" warnigns on Windows #define _CRT_SECURE_NO_DEPRECATE // Disables ridiculous "unsafe" warnigns on Windows
#define _USE_MATH_DEFINES // For M_PI on MSVC #define _USE_MATH_DEFINES // For M_PI on MSVC
#include "ggml.h"
#include "ggml-impl.h" #include "ggml-impl.h"
#include "ggml-quants.h" #include "ggml-quants.h"
@ -20,9 +21,7 @@
#include <inttypes.h> #include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <float.h> #include <float.h>
#include <limits.h>
#include <stdarg.h> #include <stdarg.h>
#include <signal.h>
#ifdef GGML_USE_METAL #ifdef GGML_USE_METAL
#include <unistd.h> #include <unistd.h>
@ -85,15 +84,14 @@ static int sched_yield (void) {
return 0; return 0;
} }
#else #else
#include <pthread.h> #include <pthread.h>
#include <sched.h>
#include <stdatomic.h> #include <stdatomic.h>
#include <sys/stat.h>
typedef void * thread_ret_t; typedef void * thread_ret_t;
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#endif #endif
#ifdef GGML_USE_CPU_HBM #ifdef GGML_USE_CPU_HBM

1
ggml.h
View File

@ -300,7 +300,6 @@ extern "C" {
GGML_API void ggml_fp16_to_fp32_row(const ggml_fp16_t * x, float * y, int n); GGML_API void ggml_fp16_to_fp32_row(const ggml_fp16_t * x, float * y, int n);
GGML_API void ggml_fp32_to_fp16_row(const float * x, ggml_fp16_t * y, int n); GGML_API void ggml_fp32_to_fp16_row(const float * x, ggml_fp16_t * y, int n);
struct ggml_object;
struct ggml_context; struct ggml_context;
enum ggml_type { enum ggml_type {

View File

@ -52,29 +52,34 @@
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <cassert> #include <cassert>
#include <cerrno>
#include <cinttypes> #include <cinttypes>
#include <climits> #include <climits>
#include <cmath> #include <cmath>
#include <cstdarg> #include <cstdarg>
#include <cstddef>
#include <cstdint> #include <cstdint>
#include <cstdio> #include <cstdio>
#include <cstdlib>
#include <cstring> #include <cstring>
#include <ctime> #include <ctime>
#include <exception>
#include <forward_list> #include <forward_list>
#include <fstream> #include <fstream>
#include <functional> #include <functional>
#include <initializer_list> #include <initializer_list>
#include <iterator>
#include <limits>
#include <map> #include <map>
#include <memory> #include <memory>
#include <mutex> #include <mutex>
#include <numeric> #include <numeric>
#include <queue> #include <queue>
#include <random> #include <random>
#include <regex>
#include <set> #include <set>
#include <sstream> #include <sstream>
#include <stdexcept>
#include <thread> #include <thread>
#include <type_traits>
#include <unordered_map> #include <unordered_map>
#if defined(_MSC_VER) #if defined(_MSC_VER)

View File

@ -2,12 +2,14 @@
#define LLAMA_H #define LLAMA_H
#include "ggml.h" #include "ggml.h"
#ifdef GGML_USE_CUBLAS #ifdef GGML_USE_CUBLAS
#include "ggml-cuda.h" #include "ggml-cuda.h"
#define LLAMA_MAX_DEVICES GGML_CUDA_MAX_DEVICES #define LLAMA_MAX_DEVICES GGML_CUDA_MAX_DEVICES
#else #else
#define LLAMA_MAX_DEVICES 1 #define LLAMA_MAX_DEVICES 1
#endif // GGML_USE_CUBLAS #endif // GGML_USE_CUBLAS
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
@ -759,8 +761,9 @@ extern "C" {
// Internal API to be implemented by llama.cpp and used by tests/benchmarks only // Internal API to be implemented by llama.cpp and used by tests/benchmarks only
#ifdef LLAMA_API_INTERNAL #ifdef LLAMA_API_INTERNAL
#include <vector>
#include <string> #include <string>
#include <utility>
#include <vector>
struct ggml_tensor; struct ggml_tensor;

View File

@ -1,16 +1,13 @@
#include <cstdio> #include "ggml.h"
#include <type_traits>
#include <vector>
#include <random>
#include <chrono>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <cstring>
#include <array>
#include <type_traits>
#include <ggml.h> #include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <random>
#include <vector>
constexpr int kVecSize = 1 << 16; constexpr int kVecSize = 1 << 16;

View File

@ -1,14 +1,15 @@
#include <cstdio> #include "ggml.h"
#include <vector>
#include <random>
#include <chrono>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <cstring>
#include <array>
#include <ggml.h> #include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <random>
#include <utility>
#include <vector>
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma warning(disable: 4244 4267) // possible loss of data #pragma warning(disable: 4244 4267) // possible loss of data

View File

@ -1,10 +1,11 @@
#define _CRT_SECURE_NO_DEPRECATE // Disables ridiculous "unsafe" warnigns on Windows #define _CRT_SECURE_NO_DEPRECATE // Disables ridiculous "unsafe" warnigns on Windows
#include "ggml.h" #include "ggml.h"
#include <cassert>
#include <cmath> #include <cmath>
#include <cstdint>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cassert>
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma warning(disable: 4244 4267) // possible loss of data #pragma warning(disable: 4244 4267) // possible loss of data

View File

@ -2,10 +2,16 @@
#undef NDEBUG #undef NDEBUG
#endif #endif
#include "llama.h"
#include "grammar-parser.h" #include "grammar-parser.h"
#include "llama.h"
#include <cassert> #include <cassert>
#include <cstdint>
#include <cstdio>
#include <map>
#include <string>
#include <utility>
#include <vector>
int main() int main()
{ {

View File

@ -6,6 +6,12 @@
#include "grammar-parser.h" #include "grammar-parser.h"
#include <cassert> #include <cassert>
#include <cstdint>
#include <cstdio>
#include <map>
#include <string>
#include <utility>
#include <vector>
int main() int main()
{ {

View File

@ -2,10 +2,9 @@
#include "ggml.h" #include "ggml.h"
#undef NDEBUG #include <cmath>
#include <assert.h> #include <cstdint>
#include <math.h> #include <cstdio>
#include <stdio.h>
#include <string> #include <string>
#include <vector> #include <vector>

View File

@ -2,14 +2,12 @@
#include "ggml.h" #include "ggml.h"
#undef NDEBUG
#include <algorithm> #include <algorithm>
#include <assert.h> #include <cinttypes>
#include <cmath>
#include <cstdio>
#include <functional> #include <functional>
#include <inttypes.h>
#include <math.h>
#include <memory> #include <memory>
#include <stdio.h>
#include <string> #include <string>
#include <vector> #include <vector>

View File

@ -1,9 +1,10 @@
#include "ggml.h" #include "ggml.h"
#include <cassert>
#include <cmath> #include <cmath>
#include <cstdint>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cassert>
#include <vector> #include <vector>
#if defined(_MSC_VER) #if defined(_MSC_VER)

View File

@ -1,15 +1,9 @@
#include "ggml.h" #include "ggml.h"
#include "llama.h" #include "llama.h"
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <cmath> #include <cmath>
#include <numeric> #include <cstdio>
#include <cassert>
#include <vector> #include <vector>
#include <algorithm>
static void dump(const llama_token_data_array * candidates) { static void dump(const llama_token_data_array * candidates) {
for (size_t i = 0; i < candidates->size; i++) { for (size_t i = 0; i < candidates->size; i++) {

View File

@ -1,12 +1,14 @@
#include "llama.h"
#include "common.h" #include "common.h"
#include "console.h" #include "console.h"
#include "llama.h"
#include <cstdio> #include <cstdio>
#include <string>
#include <map>
#include <vector>
#include <fstream> #include <fstream>
#include <iterator>
#include <map>
#include <string>
#include <utility>
#include <vector>
// generate using test-tokenizer-0-falcon.py // generate using test-tokenizer-0-falcon.py
static const std::map<std::string, std::vector<llama_token>> & k_tests() { static const std::map<std::string, std::vector<llama_token>> & k_tests() {

View File

@ -1,12 +1,14 @@
#include "llama.h"
#include "common.h" #include "common.h"
#include "console.h" #include "console.h"
#include "llama.h"
#include <cstdio> #include <cstdio>
#include <string>
#include <map>
#include <vector>
#include <fstream> #include <fstream>
#include <iterator>
#include <map>
#include <string>
#include <utility>
#include <vector>
// generate using test-tokenizer-0-llama.py // generate using test-tokenizer-0-llama.py
static const std::map<std::string, std::vector<llama_token>> & k_tests() { static const std::map<std::string, std::vector<llama_token>> & k_tests() {

View File

@ -1,16 +1,14 @@
#include "llama.h"
#include "common.h" #include "common.h"
#include "unicode.h"
#include "console.h" #include "console.h"
#include "ggml.h"
#include "llama.h"
#include "unicode.h"
#include <cassert> #include <cstdint>
#include <cstdio> #include <cstdio>
#include <cstring> #include <stdexcept>
#include <string> #include <string>
#include <codecvt>
#include <map>
#include <vector> #include <vector>
#include <locale>
int main(int argc, char **argv) { int main(int argc, char **argv) {
if (argc < 2) { if (argc < 2) {

View File

@ -1,16 +1,13 @@
#include "llama.h"
#include "common.h" #include "common.h"
#include "unicode.h"
#include "console.h" #include "console.h"
#include "ggml.h"
#include "llama.h"
#include "unicode.h"
#include <cassert> #include <cstdint>
#include <cstdio> #include <cstdio>
#include <cstring>
#include <string> #include <string>
#include <codecvt>
#include <map>
#include <vector> #include <vector>
#include <locale>
int main(int argc, char **argv) { int main(int argc, char **argv) {
if (argc < 2) { if (argc < 2) {