Beyond the usual line-number and index shifts, this follows two upstream file renames: llama-kv-cache-unified.cpp -> llama-kv-cache.cpp and llama-sampling.cpp -> llama-sampler.cpp. Many models/*.cpp use exceptions, for convenience, moz-overrides.h is included in models.h. As this file is included in all models/*.cpp. Moved include for models.h to last, to avoid breaking standard library includes with our try/catch/throw macros, in: - models/*.cpp - llama-model Differential Revision: https://phabricator.services.mozilla.com/D307357
219 lines
6.1 KiB
Diff
219 lines
6.1 KiB
Diff
diff --git a/ggml/src/gguf.cpp b/ggml/src/gguf.cpp
|
|
index 5e1986182515..61026df1c6ab 100644
|
|
--- a/ggml/src/gguf.cpp
|
|
+++ b/ggml/src/gguf.cpp
|
|
@@ -15,6 +15,8 @@
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
+#include "moz-overrides.h"
|
|
+
|
|
#define GGUF_MAX_STRING_LENGTH (1024*1024*1024)
|
|
#define GGUF_MAX_ARRAY_ELEMENTS (1024*1024*1024)
|
|
|
|
diff --git a/src/llama-adapter.cpp b/src/llama-adapter.cpp
|
|
index 3e0fe66afff7..95f50e05ccd8 100644
|
|
--- a/src/llama-adapter.cpp
|
|
+++ b/src/llama-adapter.cpp
|
|
@@ -9,6 +9,8 @@
|
|
#include <sstream>
|
|
#include <stdexcept>
|
|
|
|
+#include "moz-overrides.h"
|
|
+
|
|
// vec
|
|
|
|
ggml_tensor * llama_adapter_cvec::tensor_for(int il) const {
|
|
diff --git a/src/llama-chat.cpp b/src/llama-chat.cpp
|
|
index 6d822ec62d6b..c83e6b5ba0d4 100644
|
|
--- a/src/llama-chat.cpp
|
|
+++ b/src/llama-chat.cpp
|
|
@@ -6,6 +6,8 @@
|
|
#include <sstream>
|
|
#include <algorithm>
|
|
|
|
+#include "moz-overrides.h"
|
|
+
|
|
#if __cplusplus >= 202000L
|
|
#define LU8(x) (const char*)(u8##x)
|
|
#else
|
|
diff --git a/src/llama-context.cpp b/src/llama-context.cpp
|
|
index 168dbabd7667..2de0c7ad45f4 100644
|
|
--- a/src/llama-context.cpp
|
|
+++ b/src/llama-context.cpp
|
|
@@ -18,6 +18,8 @@
|
|
#include <limits>
|
|
#include <stdexcept>
|
|
|
|
+#include "moz-overrides.h"
|
|
+
|
|
//
|
|
// llama_context
|
|
//
|
|
diff --git a/src/llama-grammar.cpp b/src/llama-grammar.cpp
|
|
index badcbfd0fbb6..3872a7641f70 100644
|
|
--- a/src/llama-grammar.cpp
|
|
+++ b/src/llama-grammar.cpp
|
|
@@ -10,7 +10,10 @@
|
|
#include <set>
|
|
#include <stdexcept>
|
|
|
|
+#include "moz-overrides.h"
|
|
+
|
|
#define MAX_REPETITION_THRESHOLD 2000
|
|
+
|
|
//
|
|
// helpers
|
|
//
|
|
diff --git a/src/llama-kv-cache.cpp b/src/llama-kv-cache.cpp
|
|
index 2802103bdd82..289a6a0c086e 100644
|
|
--- a/src/llama-kv-cache.cpp
|
|
+++ b/src/llama-kv-cache.cpp
|
|
@@ -13,6 +13,8 @@
|
|
#include <map>
|
|
#include <stdexcept>
|
|
|
|
+#include "moz-overrides.h"
|
|
+
|
|
static bool ggml_is_power_of_2(int n) {
|
|
return (n & (n - 1)) == 0;
|
|
}
|
|
diff --git a/src/llama-memory-recurrent.cpp b/src/llama-memory-recurrent.cpp
|
|
index 6a4892fb471d..f300c1afacbb 100644
|
|
--- a/src/llama-memory-recurrent.cpp
|
|
+++ b/src/llama-memory-recurrent.cpp
|
|
@@ -13,6 +13,8 @@
|
|
#include <map>
|
|
#include <stdexcept>
|
|
|
|
+#include "moz-overrides.h"
|
|
+
|
|
//
|
|
// llama_memory_recurrent
|
|
//
|
|
diff --git a/src/llama-mmap.cpp b/src/llama-mmap.cpp
|
|
index ed572da7fb54..0e4c620c5dd4 100644
|
|
--- a/src/llama-mmap.cpp
|
|
+++ b/src/llama-mmap.cpp
|
|
@@ -40,6 +40,8 @@
|
|
#include <TargetConditionals.h>
|
|
#endif
|
|
|
|
+#include "moz-overrides.h"
|
|
+
|
|
#ifdef _WIN32
|
|
# define llama_mmap_ftell _ftelli64
|
|
# define llama_mmap_fseek _fseeki64
|
|
diff --git a/src/llama-model-loader.cpp b/src/llama-model-loader.cpp
|
|
index 474cabdfc095..4456259be12d 100644
|
|
--- a/src/llama-model-loader.cpp
|
|
+++ b/src/llama-model-loader.cpp
|
|
@@ -13,6 +13,8 @@
|
|
#include <future>
|
|
#include <regex>
|
|
|
|
+#include "moz-overrides.h"
|
|
+
|
|
static const size_t kiB = 1024;
|
|
static const size_t MiB = 1024*kiB;
|
|
static const size_t GiB = 1024*MiB;
|
|
diff --git a/src/llama-model-loader.h b/src/llama-model-loader.h
|
|
index c476026d3e51..1a1c4c4db4db 100644
|
|
--- a/src/llama-model-loader.h
|
|
+++ b/src/llama-model-loader.h
|
|
@@ -39,12 +39,14 @@ struct llama_model_loader {
|
|
llama_tensor_weight(const llama_file * file, uint16_t idx, const struct gguf_context * gguf_ctx, ggml_tensor * tensor) : idx(idx), tensor(tensor) {
|
|
const int tensor_idx = gguf_find_tensor(gguf_ctx, ggml_get_name(tensor));
|
|
if (tensor_idx < 0) {
|
|
- throw std::runtime_error(format("tensor '%s' not found in the model", ggml_get_name(tensor)));
|
|
+ // throw std::runtime_error(format("tensor '%s' not found in the model", ggml_get_name(tensor)));
|
|
+ std::abort();
|
|
}
|
|
|
|
offs = gguf_get_data_offset(gguf_ctx) + gguf_get_tensor_offset(gguf_ctx, tensor_idx);
|
|
if (offs + ggml_nbytes(tensor) < offs || offs + ggml_nbytes(tensor) > file->size()) {
|
|
- throw std::runtime_error(format("tensor '%s' data is not within the file bounds, model is corrupted or incomplete", ggml_get_name(tensor)));
|
|
+ //throw std::runtime_error(format("tensor '%s' data is not within the file bounds, model is corrupted or incomplete", ggml_get_name(tensor)));
|
|
+ std::abort();
|
|
}
|
|
}
|
|
};
|
|
diff --git a/src/llama-model.cpp b/src/llama-model.cpp
|
|
index c52875533905..f9a1a7a446b1 100644
|
|
--- a/src/llama-model.cpp
|
|
+++ b/src/llama-model.cpp
|
|
@@ -683,6 +683,8 @@ struct ggml_backend_meta_split_state llama_meta_device_get_split_state(const str
|
|
GGML_UNUSED(userdata);
|
|
}
|
|
|
|
+#include "moz-overrides.h"
|
|
+
|
|
const char * llm_type_name(llm_type type) {
|
|
switch (type) {
|
|
case LLM_TYPE_14M: return "14M";
|
|
diff --git a/src/llama-sampler.cpp b/src/llama-sampler.cpp
|
|
index 9bbc5dbde247..82f2babcab9b 100644
|
|
--- a/src/llama-sampler.cpp
|
|
+++ b/src/llama-sampler.cpp
|
|
@@ -20,6 +20,8 @@
|
|
#include <unordered_map>
|
|
#include <stdexcept>
|
|
|
|
+#include "moz-overrides.h"
|
|
+
|
|
// the ring buffer works similarly to std::deque, but with a fixed capacity
|
|
template<typename T>
|
|
struct ring_buffer {
|
|
diff --git a/src/llama-vocab.cpp b/src/llama-vocab.cpp
|
|
index 6e78a3f6c0ea..924957674a26 100644
|
|
--- a/src/llama-vocab.cpp
|
|
+++ b/src/llama-vocab.cpp
|
|
@@ -21,6 +21,8 @@
|
|
#include <set>
|
|
#include <unordered_map>
|
|
|
|
+#include "moz-overrides.h"
|
|
+
|
|
//
|
|
// helpers
|
|
//
|
|
diff --git a/src/llama.cpp b/src/llama.cpp
|
|
index a67fa8039a48..2b5726eb0f73 100644
|
|
--- a/src/llama.cpp
|
|
+++ b/src/llama.cpp
|
|
@@ -26,6 +26,8 @@
|
|
#include <stdexcept>
|
|
#include <vector>
|
|
|
|
+#include "moz-overrides.h"
|
|
+
|
|
#if defined(_MSC_VER)
|
|
#pragma warning(disable: 4244 4267) // possible loss of data
|
|
#endif
|
|
diff --git a/src/unicode.cpp b/src/unicode.cpp
|
|
index b02ecdc930fa..f7870412a3f4 100644
|
|
--- a/src/unicode.cpp
|
|
+++ b/src/unicode.cpp
|
|
@@ -13,6 +13,8 @@
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
+#include "moz-overrides.h"
|
|
+
|
|
size_t unicode_len_utf8(char src) {
|
|
const size_t lookup[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 4 };
|
|
uint8_t highbits = static_cast<uint8_t>(src) >> 4;
|
|
diff --git a/src/models/models.h b/src/models/models.h
|
|
index 19a4d3c5eaf4..2ac8415a3639 100644
|
|
--- a/src/models/models.h
|
|
+++ b/src/models/models.h
|
|
@@ -7,8 +7,6 @@
|
|
// note: almost all graphs require at least sqrtf, so include cmath globally
|
|
#include <cmath>
|
|
|
|
-#include "moz-overrides.h"
|
|
-
|
|
//
|
|
// base classes
|
|
//
|