Skip to content

Commit

Permalink
fix includes with help from include-what-you-use
Browse files Browse the repository at this point in the history
  • Loading branch information
cebtenzzre committed Nov 2, 2023
1 parent 2b5136e commit 635e9fa
Show file tree
Hide file tree
Showing 57 changed files with 298 additions and 222 deletions.
18 changes: 12 additions & 6 deletions common/common.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
#include "common.h"
#include "ggml.h"
#include "llama.h"
#include "log.h"
#include "sampling.h"

#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cinttypes>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <exception>
#include <fstream>
#include <iterator>
#include <iostream>
#include <regex>
#include <sstream>
#include <stdexcept>
#include <string>
#include <thread>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cinttypes>

#if defined(__APPLE__) && defined(__MACH__)
#include <sys/types.h>
Expand All @@ -32,9 +40,7 @@
#include <fcntl.h>
#include <io.h>
#else
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <unistd.h>
#endif

#if defined(_MSC_VER)
Expand Down
11 changes: 5 additions & 6 deletions common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
#pragma once

#include "llama.h"

#include "sampling.h"

#define LOG_NO_FILE_LINE_FUNCTION
#include "log.h"

#include <cmath>
#include <string>
#include <vector>
#include <cstdint>
#include <cstdio>
#include <random>
#include <thread>
#include <unordered_map>
#include <string>
#include <tuple>
#include <vector>

#ifdef _WIN32
#define DIRECTORY_SEPARATOR '\\'
Expand Down Expand Up @@ -68,7 +67,7 @@ struct gpt_params {
int32_t yarn_orig_ctx = 0; // YaRN original context length
int8_t rope_scaling_type = LLAMA_ROPE_SCALING_UNSPECIFIED;

// // sampling parameters
// sampling parameters
struct llama_sampling_params sparams;

std::string model = "models/7B/ggml-model-f16.gguf"; // model path
Expand Down
11 changes: 5 additions & 6 deletions common/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
#endif
#else
#include <climits>
#include <clocale>
#include <cstdio>
#include <cwchar>

#include <sys/ioctl.h>
#include <unistd.h>
#include <wchar.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <termios.h>
#include <unistd.h>
#endif

#define ANSI_COLOR_RED "\x1b[31m"
Expand Down
1 change: 0 additions & 1 deletion common/grammar-parser.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "grammar-parser.h"
#include <cstdint>
#include <cwchar>
#include <string>
#include <utility>
#include <stdexcept>
Expand Down
7 changes: 5 additions & 2 deletions common/grammar-parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
// space ::= [ \t\n]*

#pragma once

#include "llama.h"
#include <vector>
#include <map>

#include <cstdint>
#include <cstdio>
#include <map>
#include <string>
#include <vector>

namespace grammar_parser {
struct parse_state {
Expand Down
6 changes: 6 additions & 0 deletions common/sampling.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#include "common.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 * result = new llama_sampling_context();

Expand Down
8 changes: 3 additions & 5 deletions common/sampling.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma once

#include "llama.h"

#include "grammar-parser.h"
#include "llama.h"

#include <cstdint>
#include <string>
#include <vector>
#include <unordered_map>
#include <vector>

// sampling parameters
typedef struct llama_sampling_params {
Expand Down Expand Up @@ -56,8 +56,6 @@ struct llama_sampling_context {
std::vector<llama_token_data> cur;
};

#include "common.h"

// Create a new sampling context instance.
struct llama_sampling_context * llama_sampling_init(const struct llama_sampling_params & params);

Expand Down
14 changes: 12 additions & 2 deletions common/train.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
#include "train.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 <sstream>
#include <functional>

struct random_normal_distribution {
std::mt19937 gen;
Expand Down
9 changes: 5 additions & 4 deletions common/train.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

#pragma once

#include <string>
#include "llama.h"

#include <cstddef>
#include <cstdint>
#include <random>
#include <string>
#include <vector>

#include "ggml.h"
#include "llama.h"

typedef std::string mt19937_state;

struct train_state {
Expand Down
6 changes: 4 additions & 2 deletions examples/baby-llama/baby-llama.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#include "ggml.h"
#include "train.h"

#include <vector>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <random>
#include <vector>

#if defined(_MSC_VER)
Expand Down
5 changes: 3 additions & 2 deletions examples/batched-bench/batched-bench.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include "common.h"
#include "ggml.h"
#include "llama.h"

#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>

// mutates the input string
Expand Down
4 changes: 3 additions & 1 deletion examples/batched/batched.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include "common.h"
#include "ggml.h"
#include "llama.h"

#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>

Expand Down
19 changes: 2 additions & 17 deletions examples/beam-search/beam-search.cpp
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
#include "common.h"
#include "llama.h"

#include <algorithm>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iostream>
#include <string>
#include <tuple>
#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.
struct ostream_beam_view {
llama_context * ctx;
Expand Down
15 changes: 3 additions & 12 deletions examples/benchmark/benchmark-matmult.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
#include "common.h"
#include "ggml.h"

#include <locale.h>
#include <assert.h>
#include <math.h>
#include <cstring>
#include <cstdio>
#include <cinttypes>
#include <unordered_map>
#include <queue>
#include <string.h>
#include <cassert>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iterator>
#include <algorithm>
#include <vector>

#if defined(_MSC_VER)
#pragma warning(disable: 4244 4267) // possible loss of data
Expand Down
19 changes: 11 additions & 8 deletions examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#include "common.h"
#include "ggml.h"
#include "llama.h"
#include "common.h"

#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cassert>
#include <cerrno>
#include <climits>
#include <cstring>
#include <cmath>
#include <cstdarg>
#include <ctime>
#include <random>
#include <stdexcept>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

// GGUF keys & tensor names.

Expand Down
5 changes: 5 additions & 0 deletions examples/embedding/embedding.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#include "common.h"
#include "llama.h"

#include <algorithm>
#include <cstdio>
#include <ctime>
#include <random>
#include <tuple>
#include <vector>

#if defined(_MSC_VER)
#pragma warning(disable: 4244 4267) // possible loss of data
Expand Down
9 changes: 7 additions & 2 deletions examples/export-lora/export-lora.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@

#include "common.h"
#include "ggml.h"
#include "ggml-alloc.h"

#include <vector>
#include <algorithm>
#include <cerrno>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <thread>
#include <vector>

static const size_t tensor_alignment = 32;

Expand Down
20 changes: 10 additions & 10 deletions examples/finetune/finetune.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#include "ggml.h"
#include "common.h"
#include "ggml-alloc.h"
#include "ggml.h"
#include "llama.h"
#include "common.h"
#include "train.h"
#include <unordered_map>
#include <vector>
#include <cassert>
#include <climits>

#include <algorithm>
#include <cerrno>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cstdarg>
#include <ctime>
#include <random>
#include <stdexcept>
#include <algorithm>
#include <string>
#include <vector>

#if defined(_MSC_VER)
#pragma warning(disable: 4244 4267) // possible loss of data
Expand Down
Loading

0 comments on commit 635e9fa

Please sign in to comment.