diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 945df42f8..992c34a03 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -98,40 +98,40 @@ jobs:
cd build
ctest -L main --verbose --timeout 900
- ubuntu-latest-cmake-sanitizer:
- runs-on: ubuntu-latest
-
- continue-on-error: true
-
- strategy:
- matrix:
- sanitizer: [ADDRESS, THREAD, UNDEFINED]
- build_type: [Debug, Release]
-
- steps:
- - name: Clone
- id: checkout
- uses: actions/checkout@v3
-
- - name: Dependencies
- id: depends
- run: |
- sudo apt-get update
- sudo apt-get install build-essential
-
- - name: Build
- id: cmake_build
- run: |
- mkdir build
- cd build
- cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
- cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
-
- - name: Test
- id: cmake_test
- run: |
- cd build
- ctest -L main --verbose --timeout 900
+# ubuntu-latest-cmake-sanitizer:
+# runs-on: ubuntu-latest
+#
+# continue-on-error: true
+#
+# strategy:
+# matrix:
+# sanitizer: [ADDRESS, THREAD, UNDEFINED]
+# build_type: [Debug, Release]
+#
+# steps:
+# - name: Clone
+# id: checkout
+# uses: actions/checkout@v3
+#
+# - name: Dependencies
+# id: depends
+# run: |
+# sudo apt-get update
+# sudo apt-get install build-essential
+#
+# - name: Build
+# id: cmake_build
+# run: |
+# mkdir build
+# cd build
+# cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
+# cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
+#
+# - name: Test
+# id: cmake_test
+# run: |
+# cd build
+# ctest -L main --verbose --timeout 900
ubuntu-latest-cmake-mpi:
runs-on: ubuntu-latest
diff --git a/.github/workflows/close-issue.yml b/.github/workflows/close-issue.yml
index 2682f308c..a151c6780 100644
--- a/.github/workflows/close-issue.yml
+++ b/.github/workflows/close-issue.yml
@@ -12,10 +12,10 @@ jobs:
steps:
- uses: actions/stale@v5
with:
+ exempt-issue-labels: "refactor,help wanted,good first issue,research"
days-before-issue-stale: 30
days-before-issue-close: 14
stale-issue-label: "stale"
- stale-issue-message: "This issue is stale because it has been open for 30 days with no activity."
close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
days-before-pr-stale: -1
days-before-pr-close: -1
diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml
index 4ea09115a..65ca7d9ca 100644
--- a/.github/workflows/server.yml
+++ b/.github/workflows/server.yml
@@ -24,13 +24,13 @@ jobs:
strategy:
matrix:
- sanitizer: [ADDRESS, THREAD, UNDEFINED]
+ # TODO: temporary disabled due to linux kernel issues
+ #sanitizer: [ADDRESS, THREAD, UNDEFINED]
+ sanitizer: [UNDEFINED]
build_type: [Debug]
include:
- build_type: Release
sanitizer: ""
- - build_type: Debug
- sanitizer: THREAD
disabled_on_pr: true
fail-fast: false # While -DLLAMA_SANITIZE_THREAD=ON is broken
diff --git a/.gitignore b/.gitignore
index bdd72c3e1..51aa84222 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,8 @@
*.bat
*.tmp
*.metallib
+*.etag
+*.lastModified
.DS_Store
.build/
.cache/
diff --git a/Makefile b/Makefile
index 951b84807..9b72e1dbd 100644
--- a/Makefile
+++ b/Makefile
@@ -757,6 +757,10 @@ gguf: examples/gguf/gguf.cpp ggml.o $(OBJS)
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
+gguf-split: examples/gguf-split/gguf-split.cpp ggml.o llama.o $(COMMON_DEPS) $(OBJS)
+ $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
+ $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
+
train-text-from-scratch: examples/train-text-from-scratch/train-text-from-scratch.cpp ggml.o llama.o $(COMMON_DEPS) train.o $(OBJS)
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
diff --git a/README-sycl.md b/README-sycl.md
index 9359a9490..32adfda47 100644
--- a/README-sycl.md
+++ b/README-sycl.md
@@ -29,6 +29,7 @@ For Intel CPU, recommend to use llama.cpp for X86 (Intel MKL building).
## News
- 2024.3
+ - New base line is ready: [tag b2437](https://github.com/ggerganov/llama.cpp/tree/b2437).
- Support multiple cards: **--split-mode**: [none|layer]; not support [row], it's on developing.
- Support to assign main GPU by **--main-gpu**, replace $GGML_SYCL_DEVICE.
- Support detecting all GPUs with level-zero and same top **Max compute units**.
@@ -81,7 +82,7 @@ For dGPU, please make sure the device memory is enough. For llama-2-7b.Q4_0, rec
|-|-|-|
|Ampere Series| Support| A100|
-### oneMKL
+### oneMKL for CUDA
The current oneMKL release does not contain the oneMKL cuBlas backend.
As a result for Nvidia GPU's oneMKL must be built from source.
@@ -254,16 +255,16 @@ Run without parameter:
Check the ID in startup log, like:
```
-found 4 SYCL devices:
- Device 0: Intel(R) Arc(TM) A770 Graphics, compute capability 1.3,
- max compute_units 512, max work group size 1024, max sub group size 32, global mem size 16225243136
- Device 1: Intel(R) FPGA Emulation Device, compute capability 1.2,
- max compute_units 24, max work group size 67108864, max sub group size 64, global mem size 67065057280
- Device 2: 13th Gen Intel(R) Core(TM) i7-13700K, compute capability 3.0,
- max compute_units 24, max work group size 8192, max sub group size 64, global mem size 67065057280
- Device 3: Intel(R) Arc(TM) A770 Graphics, compute capability 3.0,
- max compute_units 512, max work group size 1024, max sub group size 32, global mem size 16225243136
-
+found 6 SYCL devices:
+| | | |Compute |Max compute|Max work|Max sub| |
+|ID| Device Type| Name|capability|units |group |group |Global mem size|
+|--|------------------|---------------------------------------------|----------|-----------|--------|-------|---------------|
+| 0|[level_zero:gpu:0]| Intel(R) Arc(TM) A770 Graphics| 1.3| 512| 1024| 32| 16225243136|
+| 1|[level_zero:gpu:1]| Intel(R) UHD Graphics 770| 1.3| 32| 512| 32| 53651849216|
+| 2| [opencl:gpu:0]| Intel(R) Arc(TM) A770 Graphics| 3.0| 512| 1024| 32| 16225243136|
+| 3| [opencl:gpu:1]| Intel(R) UHD Graphics 770| 3.0| 32| 512| 32| 53651849216|
+| 4| [opencl:cpu:0]| 13th Gen Intel(R) Core(TM) i7-13700K| 3.0| 24| 8192| 64| 67064815616|
+| 5| [opencl:acc:0]| Intel(R) FPGA Emulation Device| 1.2| 24|67108864| 64| 67064815616|
```
|Attribute|Note|
@@ -271,12 +272,35 @@ found 4 SYCL devices:
|compute capability 1.3|Level-zero running time, recommended |
|compute capability 3.0|OpenCL running time, slower than level-zero in most cases|
-4. Set device ID and execute llama.cpp
+4. Device selection and execution of llama.cpp
-Set device ID = 0 by **GGML_SYCL_DEVICE=0**
+There are two device selection modes:
+
+- Single device: Use one device assigned by user.
+- Multiple devices: Automatically choose the devices with the same biggest Max compute units.
+
+|Device selection|Parameter|
+|-|-|
+|Single device|--split-mode none --main-gpu DEVICE_ID |
+|Multiple devices|--split-mode layer (default)|
+
+Examples:
+
+- Use device 0:
```sh
-GGML_SYCL_DEVICE=0 ./build/bin/main -m models/llama-2-7b.Q4_0.gguf -p "Building a website can be done in 10 simple steps:" -n 400 -e -ngl 33
+ZES_ENABLE_SYSMAN=1 ./build/bin/main -m models/llama-2-7b.Q4_0.gguf -p "Building a website can be done in 10 simple steps:" -n 400 -e -ngl 33 -sm none -mg 0
+```
+or run by script:
+
+```sh
+./examples/sycl/run_llama2.sh 0
+```
+
+- Use multiple devices:
+
+```sh
+ZES_ENABLE_SYSMAN=1 ./build/bin/main -m models/llama-2-7b.Q4_0.gguf -p "Building a website can be done in 10 simple steps:" -n 400 -e -ngl 33 -sm layer
```
or run by script:
@@ -289,12 +313,18 @@ Note:
- By default, mmap is used to read model file. In some cases, it leads to the hang issue. Recommend to use parameter **--no-mmap** to disable mmap() to skip this issue.
-5. Check the device ID in output
+5. Verify the device ID in output
+
+Verify to see if the selected GPU is shown in the output, like:
-Like:
```
-Using device **0** (Intel(R) Arc(TM) A770 Graphics) as main device
+detect 1 SYCL GPUs: [0] with top Max compute units:512
```
+Or
+```
+use 1 SYCL GPUs: [0] with Max compute units:512
+```
+
## Windows
@@ -355,7 +385,7 @@ a. Download & install cmake for Windows: https://cmake.org/download/
b. Download & install mingw-w64 make for Windows provided by w64devkit
-- Download the latest fortran version of [w64devkit](https://github.com/skeeto/w64devkit/releases).
+- Download the 1.19.0 version of [w64devkit](https://github.com/skeeto/w64devkit/releases/download/v1.19.0/w64devkit-1.19.0.zip).
- Extract `w64devkit` on your pc.
@@ -430,15 +460,16 @@ build\bin\main.exe
Check the ID in startup log, like:
```
-found 4 SYCL devices:
- Device 0: Intel(R) Arc(TM) A770 Graphics, compute capability 1.3,
- max compute_units 512, max work group size 1024, max sub group size 32, global mem size 16225243136
- Device 1: Intel(R) FPGA Emulation Device, compute capability 1.2,
- max compute_units 24, max work group size 67108864, max sub group size 64, global mem size 67065057280
- Device 2: 13th Gen Intel(R) Core(TM) i7-13700K, compute capability 3.0,
- max compute_units 24, max work group size 8192, max sub group size 64, global mem size 67065057280
- Device 3: Intel(R) Arc(TM) A770 Graphics, compute capability 3.0,
- max compute_units 512, max work group size 1024, max sub group size 32, global mem size 16225243136
+found 6 SYCL devices:
+| | | |Compute |Max compute|Max work|Max sub| |
+|ID| Device Type| Name|capability|units |group |group |Global mem size|
+|--|------------------|---------------------------------------------|----------|-----------|--------|-------|---------------|
+| 0|[level_zero:gpu:0]| Intel(R) Arc(TM) A770 Graphics| 1.3| 512| 1024| 32| 16225243136|
+| 1|[level_zero:gpu:1]| Intel(R) UHD Graphics 770| 1.3| 32| 512| 32| 53651849216|
+| 2| [opencl:gpu:0]| Intel(R) Arc(TM) A770 Graphics| 3.0| 512| 1024| 32| 16225243136|
+| 3| [opencl:gpu:1]| Intel(R) UHD Graphics 770| 3.0| 32| 512| 32| 53651849216|
+| 4| [opencl:cpu:0]| 13th Gen Intel(R) Core(TM) i7-13700K| 3.0| 24| 8192| 64| 67064815616|
+| 5| [opencl:acc:0]| Intel(R) FPGA Emulation Device| 1.2| 24|67108864| 64| 67064815616|
```
@@ -447,13 +478,31 @@ found 4 SYCL devices:
|compute capability 1.3|Level-zero running time, recommended |
|compute capability 3.0|OpenCL running time, slower than level-zero in most cases|
-4. Set device ID and execute llama.cpp
-Set device ID = 0 by **set GGML_SYCL_DEVICE=0**
+4. Device selection and execution of llama.cpp
+
+There are two device selection modes:
+
+- Single device: Use one device assigned by user.
+- Multiple devices: Automatically choose the devices with the same biggest Max compute units.
+
+|Device selection|Parameter|
+|-|-|
+|Single device|--split-mode none --main-gpu DEVICE_ID |
+|Multiple devices|--split-mode layer (default)|
+
+Examples:
+
+- Use device 0:
```
-set GGML_SYCL_DEVICE=0
-build\bin\main.exe -m models\llama-2-7b.Q4_0.gguf -p "Building a website can be done in 10 simple steps:\nStep 1:" -n 400 -e -ngl 33 -s 0
+build\bin\main.exe -m models\llama-2-7b.Q4_0.gguf -p "Building a website can be done in 10 simple steps:\nStep 1:" -n 400 -e -ngl 33 -s 0 -sm none -mg 0
+```
+
+- Use multiple devices:
+
+```
+build\bin\main.exe -m models\llama-2-7b.Q4_0.gguf -p "Building a website can be done in 10 simple steps:\nStep 1:" -n 400 -e -ngl 33 -s 0 -sm layer
```
or run by script:
@@ -466,11 +515,17 @@ Note:
- By default, mmap is used to read model file. In some cases, it leads to the hang issue. Recommend to use parameter **--no-mmap** to disable mmap() to skip this issue.
-5. Check the device ID in output
-Like:
+5. Verify the device ID in output
+
+Verify to see if the selected GPU is shown in the output, like:
+
```
-Using device **0** (Intel(R) Arc(TM) A770 Graphics) as main device
+detect 1 SYCL GPUs: [0] with top Max compute units:512
+```
+Or
+```
+use 1 SYCL GPUs: [0] with Max compute units:512
```
## Environment Variable
@@ -489,7 +544,6 @@ Using device **0** (Intel(R) Arc(TM) A770 Graphics) as main device
|Name|Value|Function|
|-|-|-|
-|GGML_SYCL_DEVICE|0 (default) or 1|Set the device id used. Check the device ids by default running output|
|GGML_SYCL_DEBUG|0 (default) or 1|Enable log function by macro: GGML_SYCL_DEBUG|
|ZES_ENABLE_SYSMAN| 0 (default) or 1|Support to get free memory of GPU by sycl::aspect::ext_intel_free_memory.
Recommended to use when --split-mode = layer|
@@ -507,6 +561,9 @@ Using device **0** (Intel(R) Arc(TM) A770 Graphics) as main device
## Q&A
+Note: please add prefix **[SYCL]** in issue title, so that we will check it as soon as possible.
+
+
- Error: `error while loading shared libraries: libsycl.so.7: cannot open shared object file: No such file or directory`.
Miss to enable oneAPI running environment.
@@ -538,4 +595,4 @@ Using device **0** (Intel(R) Arc(TM) A770 Graphics) as main device
## Todo
-- Support multiple cards.
+- Support row layer split for multiple card runs.
diff --git a/common/common.cpp b/common/common.cpp
index 2f5d965d6..5f10718ec 100644
--- a/common/common.cpp
+++ b/common/common.cpp
@@ -154,6 +154,1041 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
return result;
}
+static bool gpt_params_find_arg(int argc, char ** argv, gpt_params & params, int & i, bool & invalid_param) {
+ std::string arg = argv[i];
+ llama_sampling_params& sparams = params.sparams;
+
+ if (arg == "-s" || arg == "--seed") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.seed = std::stoul(argv[i]);
+ return true;
+ }
+ if (arg == "-t" || arg == "--threads") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.n_threads = std::stoi(argv[i]);
+ if (params.n_threads <= 0) {
+ params.n_threads = std::thread::hardware_concurrency();
+ }
+ return true;
+ }
+ if (arg == "-tb" || arg == "--threads-batch") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.n_threads_batch = std::stoi(argv[i]);
+ if (params.n_threads_batch <= 0) {
+ params.n_threads_batch = std::thread::hardware_concurrency();
+ }
+ return true;
+ }
+ if (arg == "-td" || arg == "--threads-draft") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.n_threads_draft = std::stoi(argv[i]);
+ if (params.n_threads_draft <= 0) {
+ params.n_threads_draft = std::thread::hardware_concurrency();
+ }
+ return true;
+ }
+ if (arg == "-tbd" || arg == "--threads-batch-draft") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.n_threads_batch_draft = std::stoi(argv[i]);
+ if (params.n_threads_batch_draft <= 0) {
+ params.n_threads_batch_draft = std::thread::hardware_concurrency();
+ }
+ return true;
+ }
+ if (arg == "-p" || arg == "--prompt") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.prompt = argv[i];
+ return true;
+ }
+ if (arg == "-e" || arg == "--escape") {
+ params.escape = true;
+ return true;
+ }
+ if (arg == "--prompt-cache") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.path_prompt_cache = argv[i];
+ return true;
+ }
+ if (arg == "--prompt-cache-all") {
+ params.prompt_cache_all = true;
+ return true;
+ }
+ if (arg == "--prompt-cache-ro") {
+ params.prompt_cache_ro = true;
+ return true;
+ }
+ if (arg == "-bf" || arg == "--binary-file") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ std::ifstream file(argv[i], std::ios::binary);
+ if (!file) {
+ fprintf(stderr, "error: failed to open file '%s'\n", argv[i]);
+ invalid_param = true;
+ return true;
+ }
+ // store the external file name in params
+ params.prompt_file = argv[i];
+ std::ostringstream ss;
+ ss << file.rdbuf();
+ params.prompt = ss.str();
+ fprintf(stderr, "Read %zu bytes from binary file %s\n", params.prompt.size(), argv[i]);
+ return true;
+ }
+ if (arg == "-f" || arg == "--file") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ std::ifstream file(argv[i]);
+ if (!file) {
+ fprintf(stderr, "error: failed to open file '%s'\n", argv[i]);
+ invalid_param = true;
+ return true;
+ }
+ // store the external file name in params
+ params.prompt_file = argv[i];
+ std::copy(std::istreambuf_iterator(file), std::istreambuf_iterator(), back_inserter(params.prompt));
+ if (!params.prompt.empty() && params.prompt.back() == '\n') {
+ params.prompt.pop_back();
+ }
+ return true;
+ }
+ if (arg == "-n" || arg == "--n-predict") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.n_predict = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "--top-k") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.top_k = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "-c" || arg == "--ctx-size") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.n_ctx = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "--grp-attn-n" || arg == "-gan") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.grp_attn_n = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "--grp-attn-w" || arg == "-gaw") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.grp_attn_w = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "--rope-freq-base") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.rope_freq_base = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--rope-freq-scale") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.rope_freq_scale = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--rope-scaling") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ std::string value(argv[i]);
+ /**/ if (value == "none") { params.rope_scaling_type = LLAMA_ROPE_SCALING_TYPE_NONE; }
+ else if (value == "linear") { params.rope_scaling_type = LLAMA_ROPE_SCALING_TYPE_LINEAR; }
+ else if (value == "yarn") { params.rope_scaling_type = LLAMA_ROPE_SCALING_TYPE_YARN; }
+ else { invalid_param = true; }
+ return true;
+ }
+ if (arg == "--rope-scale") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.rope_freq_scale = 1.0f / std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--yarn-orig-ctx") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.yarn_orig_ctx = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "--yarn-ext-factor") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.yarn_ext_factor = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--yarn-attn-factor") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.yarn_attn_factor = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--yarn-beta-fast") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.yarn_beta_fast = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--yarn-beta-slow") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.yarn_beta_slow = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--pooling") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ std::string value(argv[i]);
+ /**/ if (value == "none") { params.pooling_type = LLAMA_POOLING_TYPE_NONE; }
+ else if (value == "mean") { params.pooling_type = LLAMA_POOLING_TYPE_MEAN; }
+ else if (value == "cls") { params.pooling_type = LLAMA_POOLING_TYPE_CLS; }
+ else { invalid_param = true; }
+ return true;
+ }
+ if (arg == "--defrag-thold" || arg == "-dt") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.defrag_thold = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--samplers") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ const auto sampler_names = string_split(argv[i], ';');
+ sparams.samplers_sequence = sampler_types_from_names(sampler_names, true);
+ return true;
+ }
+ if (arg == "--sampling-seq") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.samplers_sequence = sampler_types_from_chars(argv[i]);
+ return true;
+ }
+ if (arg == "--top-p") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.top_p = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--min-p") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.min_p = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--temp") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.temp = std::stof(argv[i]);
+ sparams.temp = std::max(sparams.temp, 0.0f);
+ return true;
+ }
+ if (arg == "--tfs") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.tfs_z = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--typical") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.typical_p = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--repeat-last-n") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.penalty_last_n = std::stoi(argv[i]);
+ sparams.n_prev = std::max(sparams.n_prev, sparams.penalty_last_n);
+ return true;
+ }
+ if (arg == "--repeat-penalty") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.penalty_repeat = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--frequency-penalty") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.penalty_freq = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--presence-penalty") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.penalty_present = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--dynatemp-range") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.dynatemp_range = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--dynatemp-exp") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.dynatemp_exponent = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--mirostat") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.mirostat = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "--mirostat-lr") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.mirostat_eta = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--mirostat-ent") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.mirostat_tau = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "--cfg-negative-prompt") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.cfg_negative_prompt = argv[i];
+ return true;
+ }
+ if (arg == "--cfg-negative-prompt-file") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ std::ifstream file(argv[i]);
+ if (!file) {
+ fprintf(stderr, "error: failed to open file '%s'\n", argv[i]);
+ invalid_param = true;
+ return true;
+ }
+ std::copy(std::istreambuf_iterator(file), std::istreambuf_iterator(), back_inserter(sparams.cfg_negative_prompt));
+ if (!sparams.cfg_negative_prompt.empty() && sparams.cfg_negative_prompt.back() == '\n') {
+ sparams.cfg_negative_prompt.pop_back();
+ }
+ return true;
+ }
+ if (arg == "--cfg-scale") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.cfg_scale = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "-b" || arg == "--batch-size") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.n_batch = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "-ub" || arg == "--ubatch-size") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.n_ubatch = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "--keep") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.n_keep = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "--draft") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.n_draft = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "--chunks") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.n_chunks = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "-np" || arg == "--parallel") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.n_parallel = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "-ns" || arg == "--sequences") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.n_sequences = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "--p-split" || arg == "-ps") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.p_split = std::stof(argv[i]);
+ return true;
+ }
+ if (arg == "-m" || arg == "--model") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.model = argv[i];
+ return true;
+ }
+ if (arg == "-mu" || arg == "--model-url") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.model_url = argv[i];
+ return true;
+ }
+ if (arg == "-md" || arg == "--model-draft") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.model_draft = argv[i];
+ return true;
+ }
+ if (arg == "-a" || arg == "--alias") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.model_alias = argv[i];
+ return true;
+ }
+ if (arg == "--lora") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.lora_adapter.emplace_back(argv[i], 1.0f);
+ params.use_mmap = false;
+ return true;
+ }
+ if (arg == "--lora-scaled") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ const char* lora_adapter = argv[i];
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.lora_adapter.emplace_back(lora_adapter, std::stof(argv[i]));
+ params.use_mmap = false;
+ return true;
+ }
+ if (arg == "--lora-base") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.lora_base = argv[i];
+ return true;
+ }
+ if (arg == "--control-vector") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.control_vectors.push_back({ 1.0f, argv[i], });
+ return true;
+ }
+ if (arg == "--control-vector-scaled") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ const char* fname = argv[i];
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.control_vectors.push_back({ std::stof(argv[i]), fname, });
+ return true;
+ }
+ if (arg == "--control-vector-layer-range") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.control_vector_layer_start = std::stoi(argv[i]);
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.control_vector_layer_end = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "--mmproj") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.mmproj = argv[i];
+ return true;
+ }
+ if (arg == "--image") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.image = argv[i];
+ return true;
+ }
+ if (arg == "-i" || arg == "--interactive") {
+ params.interactive = true;
+ return true;
+ }
+ if (arg == "--embedding") {
+ params.embedding = true;
+ return true;
+ }
+ if (arg == "--interactive-first") {
+ params.interactive_first = true;
+ return true;
+ }
+ if (arg == "-ins" || arg == "--instruct") {
+ params.instruct = true;
+ return true;
+ }
+ if (arg == "-cml" || arg == "--chatml") {
+ params.chatml = true;
+ return true;
+ }
+ if (arg == "--infill") {
+ params.infill = true;
+ return true;
+ }
+ if (arg == "-dkvc" || arg == "--dump-kv-cache") {
+ params.dump_kv_cache = true;
+ return true;
+ }
+ if (arg == "-nkvo" || arg == "--no-kv-offload") {
+ params.no_kv_offload = true;
+ return true;
+ }
+ if (arg == "-ctk" || arg == "--cache-type-k") {
+ params.cache_type_k = argv[++i];
+ return true;
+ }
+ if (arg == "-ctv" || arg == "--cache-type-v") {
+ params.cache_type_v = argv[++i];
+ return true;
+ }
+ if (arg == "--multiline-input") {
+ params.multiline_input = true;
+ return true;
+ }
+ if (arg == "--simple-io") {
+ params.simple_io = true;
+ return true;
+ }
+ if (arg == "-cb" || arg == "--cont-batching") {
+ params.cont_batching = true;
+ return true;
+ }
+ if (arg == "--color") {
+ params.use_color = true;
+ return true;
+ }
+ if (arg == "--mlock") {
+ params.use_mlock = true;
+ return true;
+ }
+ if (arg == "--gpu-layers" || arg == "-ngl" || arg == "--n-gpu-layers") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.n_gpu_layers = std::stoi(argv[i]);
+ if (!llama_supports_gpu_offload()) {
+ fprintf(stderr, "warning: not compiled with GPU offload support, --n-gpu-layers option will be ignored\n");
+ fprintf(stderr, "warning: see main README.md for information on enabling GPU BLAS support\n");
+ }
+ return true;
+ }
+ if (arg == "--gpu-layers-draft" || arg == "-ngld" || arg == "--n-gpu-layers-draft") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.n_gpu_layers_draft = std::stoi(argv[i]);
+ if (!llama_supports_gpu_offload()) {
+ fprintf(stderr, "warning: not compiled with GPU offload support, --n-gpu-layers-draft option will be ignored\n");
+ fprintf(stderr, "warning: see main README.md for information on enabling GPU BLAS support\n");
+ }
+ return true;
+ }
+ if (arg == "--main-gpu" || arg == "-mg") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.main_gpu = std::stoi(argv[i]);
+#ifndef GGML_USE_CUBLAS_SYCL
+ fprintf(stderr, "warning: llama.cpp was compiled without cuBLAS/SYCL. Setting the main GPU has no effect.\n");
+#endif // GGML_USE_CUBLAS_SYCL
+ return true;
+ }
+ if (arg == "--split-mode" || arg == "-sm") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ std::string arg_next = argv[i];
+ if (arg_next == "none") {
+ params.split_mode = LLAMA_SPLIT_MODE_NONE;
+ }
+ else if (arg_next == "layer") {
+ params.split_mode = LLAMA_SPLIT_MODE_LAYER;
+ }
+ else if (arg_next == "row") {
+#ifdef GGML_USE_SYCL
+ fprintf(stderr, "warning: The split mode value:[row] is not supported by llama.cpp with SYCL. It's developing.\nExit!\n");
+ exit(1);
+#endif // GGML_USE_SYCL
+ params.split_mode = LLAMA_SPLIT_MODE_ROW;
+ }
+ else {
+ invalid_param = true;
+ return true;
+ }
+#ifndef GGML_USE_CUBLAS_SYCL
+ fprintf(stderr, "warning: llama.cpp was compiled without cuBLAS/SYCL. Setting the split mode has no effect.\n");
+#endif // GGML_USE_CUBLAS_SYCL
+ return true;
+ }
+ if (arg == "--tensor-split" || arg == "-ts") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ std::string arg_next = argv[i];
+
+ // split string by , and /
+ const std::regex regex{ R"([,/]+)" };
+ std::sregex_token_iterator it{ arg_next.begin(), arg_next.end(), regex, -1 };
+ std::vector split_arg{ it, {} };
+ if (split_arg.size() >= llama_max_devices()) {
+ invalid_param = true;
+ return true;
+ }
+ for (size_t i = 0; i < llama_max_devices(); ++i) {
+ if (i < split_arg.size()) {
+ params.tensor_split[i] = std::stof(split_arg[i]);
+ }
+ else {
+ params.tensor_split[i] = 0.0f;
+ }
+ }
+#ifndef GGML_USE_CUBLAS_SYCL_VULKAN
+ fprintf(stderr, "warning: llama.cpp was compiled without cuBLAS/SYCL/Vulkan. Setting a tensor split has no effect.\n");
+#endif // GGML_USE_CUBLAS_SYCL
+ return true;
+ }
+ if (arg == "--no-mmap") {
+ params.use_mmap = false;
+ return true;
+ }
+ if (arg == "--numa") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ std::string value(argv[i]);
+ /**/ if (value == "distribute" || value == "") { params.numa = GGML_NUMA_STRATEGY_DISTRIBUTE; }
+ else if (value == "isolate") { params.numa = GGML_NUMA_STRATEGY_ISOLATE; }
+ else if (value == "numactl") { params.numa = GGML_NUMA_STRATEGY_NUMACTL; }
+ else { invalid_param = true; }
+ return true;
+ }
+ if (arg == "--verbose-prompt") {
+ params.verbose_prompt = true;
+ return true;
+ }
+ if (arg == "--no-display-prompt") {
+ params.display_prompt = false;
+ return true;
+ }
+ if (arg == "-r" || arg == "--reverse-prompt") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.antiprompt.emplace_back(argv[i]);
+ return true;
+ }
+ if (arg == "-ld" || arg == "--logdir") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.logdir = argv[i];
+
+ if (params.logdir.back() != DIRECTORY_SEPARATOR) {
+ params.logdir += DIRECTORY_SEPARATOR;
+ }
+ return true;
+ }
+ if (arg == "--save-all-logits" || arg == "--kl-divergence-base") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.logits_file = argv[i];
+ return true;
+ }
+ if (arg == "--perplexity" || arg == "--all-logits") {
+ params.logits_all = true;
+ return true;
+ }
+ if (arg == "--ppl-stride") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.ppl_stride = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "-ptc" || arg == "--print-token-count") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.n_print = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "--ppl-output-type") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.ppl_output_type = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "--hellaswag") {
+ params.hellaswag = true;
+ return true;
+ }
+ if (arg == "--hellaswag-tasks") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.hellaswag_tasks = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "--winogrande") {
+ params.winogrande = true;
+ return true;
+ }
+ if (arg == "--winogrande-tasks") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.winogrande_tasks = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "--multiple-choice") {
+ params.multiple_choice = true;
+ return true;
+ }
+ if (arg == "--multiple-choice-tasks") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.multiple_choice_tasks = std::stoi(argv[i]);
+ return true;
+ }
+ if (arg == "--kl-divergence") {
+ params.kl_divergence = true;
+ return true;
+ }
+ if (arg == "--ignore-eos") {
+ params.ignore_eos = true;
+ return true;
+ }
+ if (arg == "--no-penalize-nl") {
+ sparams.penalize_nl = false;
+ return true;
+ }
+ if (arg == "-l" || arg == "--logit-bias") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ std::stringstream ss(argv[i]);
+ llama_token key;
+ char sign;
+ std::string value_str;
+ try {
+ if (ss >> key && ss >> sign && std::getline(ss, value_str) && (sign == '+' || sign == '-')) {
+ sparams.logit_bias[key] = std::stof(value_str) * ((sign == '-') ? -1.0f : 1.0f);
+ }
+ else {
+ throw std::exception();
+ }
+ }
+ catch (const std::exception&) {
+ invalid_param = true;
+ return true;
+ }
+ return true;
+ }
+ if (arg == "-h" || arg == "--help") {
+ gpt_print_usage(argc, argv, gpt_params());
+ exit(0);
+ }
+ if (arg == "--version") {
+ fprintf(stderr, "version: %d (%s)\n", LLAMA_BUILD_NUMBER, LLAMA_COMMIT);
+ fprintf(stderr, "built with %s for %s\n", LLAMA_COMPILER, LLAMA_BUILD_TARGET);
+ exit(0);
+ }
+ if (arg == "--random-prompt") {
+ params.random_prompt = true;
+ return true;
+ }
+ if (arg == "--in-prefix-bos") {
+ params.input_prefix_bos = true;
+ return true;
+ }
+ if (arg == "--in-prefix") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.input_prefix = argv[i];
+ return true;
+ }
+ if (arg == "--in-suffix") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ params.input_suffix = argv[i];
+ return true;
+ }
+ if (arg == "--grammar") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ sparams.grammar = argv[i];
+ return true;
+ }
+ if (arg == "--grammar-file") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ std::ifstream file(argv[i]);
+ if (!file) {
+ fprintf(stderr, "error: failed to open file '%s'\n", argv[i]);
+ invalid_param = true;
+ return true;
+ }
+ std::copy(
+ std::istreambuf_iterator(file),
+ std::istreambuf_iterator(),
+ std::back_inserter(sparams.grammar)
+ );
+ return true;
+ }
+ if (arg == "--override-kv") {
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ char* sep = strchr(argv[i], '=');
+ if (sep == nullptr || sep - argv[i] >= 128) {
+ fprintf(stderr, "error: Malformed KV override: %s\n", argv[i]);
+ invalid_param = true;
+ return true;
+ }
+ struct llama_model_kv_override kvo;
+ std::strncpy(kvo.key, argv[i], sep - argv[i]);
+ kvo.key[sep - argv[i]] = 0;
+ sep++;
+ if (strncmp(sep, "int:", 4) == 0) {
+ sep += 4;
+ kvo.tag = LLAMA_KV_OVERRIDE_TYPE_INT;
+ kvo.int_value = std::atol(sep);
+ }
+ else if (strncmp(sep, "float:", 6) == 0) {
+ sep += 6;
+ kvo.tag = LLAMA_KV_OVERRIDE_TYPE_FLOAT;
+ kvo.float_value = std::atof(sep);
+ }
+ else if (strncmp(sep, "bool:", 5) == 0) {
+ sep += 5;
+ kvo.tag = LLAMA_KV_OVERRIDE_TYPE_BOOL;
+ if (std::strcmp(sep, "true") == 0) {
+ kvo.bool_value = true;
+ }
+ else if (std::strcmp(sep, "false") == 0) {
+ kvo.bool_value = false;
+ }
+ else {
+ fprintf(stderr, "error: Invalid boolean value for KV override: %s\n", argv[i]);
+ invalid_param = true;
+ return true;
+ }
+ }
+ else {
+ fprintf(stderr, "error: Invalid type for KV override: %s\n", argv[i]);
+ invalid_param = true;
+ return true;
+ }
+ params.kv_overrides.push_back(kvo);
+ return true;
+ }
+#ifndef LOG_DISABLE_LOGS
+ // Parse args for logging parameters
+ if (log_param_single_parse(argv[i])) {
+ // Do nothing, log_param_single_parse automatically does it's thing
+ // and returns if a match was found and parsed.
+ return true;
+ }
+ if (log_param_pair_parse( /*check_but_dont_parse*/ true, argv[i])) {
+ // We have a matching known parameter requiring an argument,
+ // now we need to check if there is anything after this argv
+ // and flag invalid_param or parse it.
+ if (++i >= argc) {
+ invalid_param = true;
+ return true;
+ }
+ if (!log_param_pair_parse( /*check_but_dont_parse*/ false, argv[i - 1], argv[i])) {
+ invalid_param = true;
+ return true;
+ }
+ return true;
+ }
+ // End of Parse args for logging parameters
+#endif // LOG_DISABLE_LOGS
+
+ return false;
+}
+
bool gpt_params_parse_ex(int argc, char ** argv, gpt_params & params) {
bool invalid_param = false;
std::string arg;
@@ -166,1028 +1201,7 @@ bool gpt_params_parse_ex(int argc, char ** argv, gpt_params & params) {
std::replace(arg.begin(), arg.end(), '_', '-');
}
- bool arg_found = false;
- if (arg == "-s" || arg == "--seed") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.seed = std::stoul(argv[i]);
- }
- if (arg == "-t" || arg == "--threads") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.n_threads = std::stoi(argv[i]);
- if (params.n_threads <= 0) {
- params.n_threads = std::thread::hardware_concurrency();
- }
- }
- if (arg == "-tb" || arg == "--threads-batch") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.n_threads_batch = std::stoi(argv[i]);
- if (params.n_threads_batch <= 0) {
- params.n_threads_batch = std::thread::hardware_concurrency();
- }
- }
- if (arg == "-td" || arg == "--threads-draft") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.n_threads_draft = std::stoi(argv[i]);
- if (params.n_threads_draft <= 0) {
- params.n_threads_draft = std::thread::hardware_concurrency();
- }
- }
- if (arg == "-tbd" || arg == "--threads-batch-draft") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.n_threads_batch_draft = std::stoi(argv[i]);
- if (params.n_threads_batch_draft <= 0) {
- params.n_threads_batch_draft = std::thread::hardware_concurrency();
- }
- }
- if (arg == "-p" || arg == "--prompt") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.prompt = argv[i];
- }
- if (arg == "-e" || arg == "--escape") {
- arg_found = true;
- params.escape = true;
- }
- if (arg == "--prompt-cache") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.path_prompt_cache = argv[i];
- }
- if (arg == "--prompt-cache-all") {
- arg_found = true;
- params.prompt_cache_all = true;
- }
- if (arg == "--prompt-cache-ro") {
- arg_found = true;
- params.prompt_cache_ro = true;
- }
- if (arg == "-bf" || arg == "--binary-file") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- std::ifstream file(argv[i], std::ios::binary);
- if (!file) {
- fprintf(stderr, "error: failed to open file '%s'\n", argv[i]);
- invalid_param = true;
- break;
- }
- // store the external file name in params
- params.prompt_file = argv[i];
- std::ostringstream ss;
- ss << file.rdbuf();
- params.prompt = ss.str();
- fprintf(stderr, "Read %zu bytes from binary file %s\n", params.prompt.size(), argv[i]);
- }
- if (arg == "-f" || arg == "--file") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- std::ifstream file(argv[i]);
- if (!file) {
- fprintf(stderr, "error: failed to open file '%s'\n", argv[i]);
- invalid_param = true;
- break;
- }
- // store the external file name in params
- params.prompt_file = argv[i];
- std::copy(std::istreambuf_iterator(file), std::istreambuf_iterator(), back_inserter(params.prompt));
- if (!params.prompt.empty() && params.prompt.back() == '\n') {
- params.prompt.pop_back();
- }
- }
- if (arg == "-n" || arg == "--n-predict") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.n_predict = std::stoi(argv[i]);
- }
- if (arg == "--top-k") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.top_k = std::stoi(argv[i]);
- }
- if (arg == "-c" || arg == "--ctx-size") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.n_ctx = std::stoi(argv[i]);
- }
- if (arg == "--grp-attn-n" || arg == "-gan") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
-
- params.grp_attn_n = std::stoi(argv[i]);
- }
- if (arg == "--grp-attn-w" || arg == "-gaw") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
-
- params.grp_attn_w = std::stoi(argv[i]);
- }
- if (arg == "--rope-freq-base") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.rope_freq_base = std::stof(argv[i]);
- }
- if (arg == "--rope-freq-scale") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.rope_freq_scale = std::stof(argv[i]);
- }
- if (arg == "--rope-scaling") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- std::string value(argv[i]);
- /**/ if (value == "none") { params.rope_scaling_type = LLAMA_ROPE_SCALING_TYPE_NONE; }
- else if (value == "linear") { params.rope_scaling_type = LLAMA_ROPE_SCALING_TYPE_LINEAR; }
- else if (value == "yarn") { params.rope_scaling_type = LLAMA_ROPE_SCALING_TYPE_YARN; }
- else { invalid_param = true; break; }
- }
- if (arg == "--rope-scale") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.rope_freq_scale = 1.0f/std::stof(argv[i]);
- }
- if (arg == "--yarn-orig-ctx") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.yarn_orig_ctx = std::stoi(argv[i]);
- }
- if (arg == "--yarn-ext-factor") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.yarn_ext_factor = std::stof(argv[i]);
- }
- if (arg == "--yarn-attn-factor") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.yarn_attn_factor = std::stof(argv[i]);
- }
- if (arg == "--yarn-beta-fast") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.yarn_beta_fast = std::stof(argv[i]);
- }
- if (arg == "--yarn-beta-slow") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.yarn_beta_slow = std::stof(argv[i]);
- }
- if (arg == "--pooling") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- std::string value(argv[i]);
- /**/ if (value == "none") { params.pooling_type = LLAMA_POOLING_TYPE_NONE; }
- else if (value == "mean") { params.pooling_type = LLAMA_POOLING_TYPE_MEAN; }
- else if (value == "cls") { params.pooling_type = LLAMA_POOLING_TYPE_CLS; }
- else { invalid_param = true; break; }
- }
- if (arg == "--defrag-thold" || arg == "-dt") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.defrag_thold = std::stof(argv[i]);
- }
- if (arg == "--samplers") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- const auto sampler_names = string_split(argv[i], ';');
- sparams.samplers_sequence = sampler_types_from_names(sampler_names, true);
- }
- if (arg == "--sampling-seq") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.samplers_sequence = sampler_types_from_chars(argv[i]);
- }
- if (arg == "--top-p") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.top_p = std::stof(argv[i]);
- }
- if (arg == "--min-p") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.min_p = std::stof(argv[i]);
- }
- if (arg == "--temp") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.temp = std::stof(argv[i]);
- sparams.temp = std::max(sparams.temp, 0.0f);
- }
- if (arg == "--tfs") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.tfs_z = std::stof(argv[i]);
- }
- if (arg == "--typical") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.typical_p = std::stof(argv[i]);
- }
- if (arg == "--repeat-last-n") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.penalty_last_n = std::stoi(argv[i]);
- sparams.n_prev = std::max(sparams.n_prev, sparams.penalty_last_n);
- }
- if (arg == "--repeat-penalty") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.penalty_repeat = std::stof(argv[i]);
- }
- if (arg == "--frequency-penalty") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.penalty_freq = std::stof(argv[i]);
- }
- if (arg == "--presence-penalty") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.penalty_present = std::stof(argv[i]);
- }
- if (arg == "--dynatemp-range") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.dynatemp_range = std::stof(argv[i]);
- }
- if (arg == "--dynatemp-exp") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.dynatemp_exponent = std::stof(argv[i]);
- }
- if (arg == "--mirostat") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.mirostat = std::stoi(argv[i]);
- }
- if (arg == "--mirostat-lr") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.mirostat_eta = std::stof(argv[i]);
- }
- if (arg == "--mirostat-ent") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.mirostat_tau = std::stof(argv[i]);
- }
- if (arg == "--cfg-negative-prompt") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.cfg_negative_prompt = argv[i];
- }
- if (arg == "--cfg-negative-prompt-file") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- std::ifstream file(argv[i]);
- if (!file) {
- fprintf(stderr, "error: failed to open file '%s'\n", argv[i]);
- invalid_param = true;
- break;
- }
- std::copy(std::istreambuf_iterator(file), std::istreambuf_iterator(), back_inserter(sparams.cfg_negative_prompt));
- if (!sparams.cfg_negative_prompt.empty() && sparams.cfg_negative_prompt.back() == '\n') {
- sparams.cfg_negative_prompt.pop_back();
- }
- }
- if (arg == "--cfg-scale") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.cfg_scale = std::stof(argv[i]);
- }
- if (arg == "-b" || arg == "--batch-size") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.n_batch = std::stoi(argv[i]);
- }
- if (arg == "-ub" || arg == "--ubatch-size") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.n_ubatch = std::stoi(argv[i]);
- }
- if (arg == "--keep") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.n_keep = std::stoi(argv[i]);
- }
- if (arg == "--draft") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.n_draft = std::stoi(argv[i]);
- }
- if (arg == "--chunks") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.n_chunks = std::stoi(argv[i]);
- }
- if (arg == "-np" || arg == "--parallel") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.n_parallel = std::stoi(argv[i]);
- }
- if (arg == "-ns" || arg == "--sequences") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.n_sequences = std::stoi(argv[i]);
- }
- if (arg == "--p-split" || arg == "-ps") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.p_split = std::stof(argv[i]);
- }
- if (arg == "-m" || arg == "--model") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.model = argv[i];
- }
- if (arg == "-mu" || arg == "--model-url") {
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.model_url = argv[i];
- }
- if (arg == "-md" || arg == "--model-draft") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.model_draft = argv[i];
- }
- if (arg == "-a" || arg == "--alias") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.model_alias = argv[i];
- }
- if (arg == "--lora") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.lora_adapter.emplace_back(argv[i], 1.0f);
- params.use_mmap = false;
- }
- if (arg == "--lora-scaled") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- const char * lora_adapter = argv[i];
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.lora_adapter.emplace_back(lora_adapter, std::stof(argv[i]));
- params.use_mmap = false;
- }
- if (arg == "--lora-base") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.lora_base = argv[i];
- }
- if (arg == "--control-vector") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.control_vectors.push_back({ 1.0f, argv[i], });
- }
- if (arg == "--control-vector-scaled") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- const char * fname = argv[i];
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.control_vectors.push_back({ std::stof(argv[i]), fname, });
- }
- if (arg == "--control-vector-layer-range") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.control_vector_layer_start = std::stoi(argv[i]);
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.control_vector_layer_end = std::stoi(argv[i]);
- }
- if (arg == "--mmproj") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.mmproj = argv[i];
- }
- if (arg == "--image") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.image = argv[i];
- }
- if (arg == "-i" || arg == "--interactive") {
- arg_found = true;
- params.interactive = true;
- }
- if (arg == "--embedding") {
- arg_found = true;
- params.embedding = true;
- }
- if (arg == "--interactive-first") {
- arg_found = true;
- params.interactive_first = true;
- }
- if (arg == "-ins" || arg == "--instruct") {
- arg_found = true;
- params.instruct = true;
- }
- if (arg == "-cml" || arg == "--chatml") {
- arg_found = true;
- params.chatml = true;
- }
- if (arg == "--infill") {
- arg_found = true;
- params.infill = true;
- }
- if (arg == "-dkvc" || arg == "--dump-kv-cache") {
- arg_found = true;
- params.dump_kv_cache = true;
- }
- if (arg == "-nkvo" || arg == "--no-kv-offload") {
- arg_found = true;
- params.no_kv_offload = true;
- }
- if (arg == "-ctk" || arg == "--cache-type-k") {
- arg_found = true;
- params.cache_type_k = argv[++i];
- }
- if (arg == "-ctv" || arg == "--cache-type-v") {
- arg_found = true;
- params.cache_type_v = argv[++i];
- }
- if (arg == "--multiline-input") {
- arg_found = true;
- params.multiline_input = true;
- }
- if (arg == "--simple-io") {
- arg_found = true;
- params.simple_io = true;
- }
- if (arg == "-cb" || arg == "--cont-batching") {
- arg_found = true;
- params.cont_batching = true;
- }
- if (arg == "--color") {
- arg_found = true;
- params.use_color = true;
- }
- if (arg == "--mlock") {
- arg_found = true;
- params.use_mlock = true;
- }
- if (arg == "--gpu-layers" || arg == "-ngl" || arg == "--n-gpu-layers") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.n_gpu_layers = std::stoi(argv[i]);
- if (!llama_supports_gpu_offload()) {
- fprintf(stderr, "warning: not compiled with GPU offload support, --n-gpu-layers option will be ignored\n");
- fprintf(stderr, "warning: see main README.md for information on enabling GPU BLAS support\n");
- }
- }
- if (arg == "--gpu-layers-draft" || arg == "-ngld" || arg == "--n-gpu-layers-draft") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.n_gpu_layers_draft = std::stoi(argv[i]);
- if (!llama_supports_gpu_offload()) {
- fprintf(stderr, "warning: not compiled with GPU offload support, --n-gpu-layers-draft option will be ignored\n");
- fprintf(stderr, "warning: see main README.md for information on enabling GPU BLAS support\n");
- }
- }
- if (arg == "--main-gpu" || arg == "-mg") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.main_gpu = std::stoi(argv[i]);
-#ifndef GGML_USE_CUBLAS_SYCL
- fprintf(stderr, "warning: llama.cpp was compiled without cuBLAS/SYCL. Setting the main GPU has no effect.\n");
-#endif // GGML_USE_CUBLAS_SYCL
- }
- if (arg == "--split-mode" || arg == "-sm") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- std::string arg_next = argv[i];
- if (arg_next == "none") {
- params.split_mode = LLAMA_SPLIT_MODE_NONE;
- } else if (arg_next == "layer") {
- params.split_mode = LLAMA_SPLIT_MODE_LAYER;
- } else if (arg_next == "row") {
-#ifdef GGML_USE_SYCL
- fprintf(stderr, "warning: The split mode value:[row] is not supported by llama.cpp with SYCL. It's developing.\nExit!\n");
- exit(1);
-#endif // GGML_USE_SYCL
- params.split_mode = LLAMA_SPLIT_MODE_ROW;
- } else {
- invalid_param = true;
- break;
- }
-#ifndef GGML_USE_CUBLAS_SYCL
- fprintf(stderr, "warning: llama.cpp was compiled without cuBLAS/SYCL. Setting the split mode has no effect.\n");
-#endif // GGML_USE_CUBLAS_SYCL
-
- }
- if (arg == "--tensor-split" || arg == "-ts") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- std::string arg_next = argv[i];
-
- // split string by , and /
- const std::regex regex{R"([,/]+)"};
- std::sregex_token_iterator it{arg_next.begin(), arg_next.end(), regex, -1};
- std::vector split_arg{it, {}};
- if (split_arg.size() >= llama_max_devices()) {
- invalid_param = true;
- break;
- }
- for (size_t i = 0; i < llama_max_devices(); ++i) {
- if (i < split_arg.size()) {
- params.tensor_split[i] = std::stof(split_arg[i]);
- } else {
- params.tensor_split[i] = 0.0f;
- }
- }
-#ifndef GGML_USE_CUBLAS_SYCL_VULKAN
- fprintf(stderr, "warning: llama.cpp was compiled without cuBLAS/SYCL/Vulkan. Setting a tensor split has no effect.\n");
-#endif // GGML_USE_CUBLAS_SYCL
- }
- if (arg == "--no-mmap") {
- arg_found = true;
- params.use_mmap = false;
- }
- if (arg == "--numa") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- std::string value(argv[i]);
- /**/ if (value == "distribute" || value == "") { params.numa = GGML_NUMA_STRATEGY_DISTRIBUTE; }
- else if (value == "isolate") { params.numa = GGML_NUMA_STRATEGY_ISOLATE; }
- else if (value == "numactl") { params.numa = GGML_NUMA_STRATEGY_NUMACTL; }
- else { invalid_param = true; break; }
- }
- if (arg == "--verbose-prompt") {
- arg_found = true;
- params.verbose_prompt = true;
- }
- if (arg == "--no-display-prompt") {
- arg_found = true;
- params.display_prompt = false;
- }
- if (arg == "-r" || arg == "--reverse-prompt") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.antiprompt.emplace_back(argv[i]);
- }
- if (arg == "-ld" || arg == "--logdir") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.logdir = argv[i];
-
- if (params.logdir.back() != DIRECTORY_SEPARATOR) {
- params.logdir += DIRECTORY_SEPARATOR;
- }
- }
- if (arg == "--save-all-logits" || arg == "--kl-divergence-base") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.logits_file = argv[i];
- }
- if (arg == "--perplexity" || arg == "--all-logits") {
- arg_found = true;
- params.logits_all = true;
- }
- if (arg == "--ppl-stride") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.ppl_stride = std::stoi(argv[i]);
- }
- if (arg == "-ptc" || arg == "--print-token-count") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.n_print = std::stoi(argv[i]);
- }
- if (arg == "--ppl-output-type") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.ppl_output_type = std::stoi(argv[i]);
- }
- if (arg == "--hellaswag") {
- arg_found = true;
- params.hellaswag = true;
- }
- if (arg == "--hellaswag-tasks") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.hellaswag_tasks = std::stoi(argv[i]);
- }
- if (arg == "--winogrande") {
- arg_found = true;
- params.winogrande = true;
- }
- if (arg == "--winogrande-tasks") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.winogrande_tasks = std::stoi(argv[i]);
- }
- if (arg == "--multiple-choice") {
- arg_found = true;
- params.multiple_choice = true;
- }
- if (arg == "--multiple-choice-tasks") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.multiple_choice_tasks = std::stoi(argv[i]);
- }
- if (arg == "--kl-divergence") {
- arg_found = true;
- params.kl_divergence = true;
- }
- if (arg == "--ignore-eos") {
- arg_found = true;
- params.ignore_eos = true;
- }
- if (arg == "--no-penalize-nl") {
- arg_found = true;
- sparams.penalize_nl = false;
- }
- if (arg == "-l" || arg == "--logit-bias") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- std::stringstream ss(argv[i]);
- llama_token key;
- char sign;
- std::string value_str;
- try {
- if (ss >> key && ss >> sign && std::getline(ss, value_str) && (sign == '+' || sign == '-')) {
- sparams.logit_bias[key] = std::stof(value_str) * ((sign == '-') ? -1.0f : 1.0f);
- } else {
- throw std::exception();
- }
- } catch (const std::exception&) {
- invalid_param = true;
- break;
- }
- }
- if (arg == "-h" || arg == "--help") {
- arg_found = true;
- return false;
- }
- if (arg == "--version") {
- arg_found = true;
- fprintf(stderr, "version: %d (%s)\n", LLAMA_BUILD_NUMBER, LLAMA_COMMIT);
- fprintf(stderr, "built with %s for %s\n", LLAMA_COMPILER, LLAMA_BUILD_TARGET);
- exit(0);
- }
- if (arg == "--random-prompt") {
- arg_found = true;
- params.random_prompt = true;
- }
- if (arg == "--in-prefix-bos") {
- arg_found = true;
- params.input_prefix_bos = true;
- }
- if (arg == "--in-prefix") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.input_prefix = argv[i];
- }
- if (arg == "--in-suffix") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- params.input_suffix = argv[i];
- }
- if (arg == "--grammar") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- sparams.grammar = argv[i];
- }
- if (arg == "--grammar-file") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- std::ifstream file(argv[i]);
- if (!file) {
- fprintf(stderr, "error: failed to open file '%s'\n", argv[i]);
- invalid_param = true;
- break;
- }
- std::copy(
- std::istreambuf_iterator(file),
- std::istreambuf_iterator(),
- std::back_inserter(sparams.grammar)
- );
- }
- if (arg == "--override-kv") {
- arg_found = true;
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- char * sep = strchr(argv[i], '=');
- if (sep == nullptr || sep - argv[i] >= 128) {
- fprintf(stderr, "error: Malformed KV override: %s\n", argv[i]);
- invalid_param = true;
- break;
- }
- struct llama_model_kv_override kvo;
- std::strncpy(kvo.key, argv[i], sep - argv[i]);
- kvo.key[sep - argv[i]] = 0;
- sep++;
- if (strncmp(sep, "int:", 4) == 0) {
- sep += 4;
- kvo.tag = LLAMA_KV_OVERRIDE_TYPE_INT;
- kvo.int_value = std::atol(sep);
- } else if (strncmp(sep, "float:", 6) == 0) {
- sep += 6;
- kvo.tag = LLAMA_KV_OVERRIDE_TYPE_FLOAT;
- kvo.float_value = std::atof(sep);
- } else if (strncmp(sep, "bool:", 5) == 0) {
- sep += 5;
- kvo.tag = LLAMA_KV_OVERRIDE_TYPE_BOOL;
- if (std::strcmp(sep, "true") == 0) {
- kvo.bool_value = true;
- } else if (std::strcmp(sep, "false") == 0) {
- kvo.bool_value = false;
- } else {
- fprintf(stderr, "error: Invalid boolean value for KV override: %s\n", argv[i]);
- invalid_param = true;
- break;
- }
- } else {
- fprintf(stderr, "error: Invalid type for KV override: %s\n", argv[i]);
- invalid_param = true;
- break;
- }
- params.kv_overrides.push_back(kvo);
-#ifndef LOG_DISABLE_LOGS
- // Parse args for logging parameters
- }
- if ( log_param_single_parse( argv[i] ) ) {
- arg_found = true;
- // Do nothing, log_param_single_parse automatically does it's thing
- // and returns if a match was found and parsed.
- }
- if ( log_param_pair_parse( /*check_but_dont_parse*/ true, argv[i] ) ) {
- arg_found = true;
- // We have a matching known parameter requiring an argument,
- // now we need to check if there is anything after this argv
- // and flag invalid_param or parse it.
- if (++i >= argc) {
- invalid_param = true;
- break;
- }
- if( !log_param_pair_parse( /*check_but_dont_parse*/ false, argv[i-1], argv[i]) ) {
- invalid_param = true;
- break;
- }
- // End of Parse args for logging parameters
-#endif // LOG_DISABLE_LOGS
- }
-
- if (!arg_found) {
+ if (!gpt_params_find_arg(argc, argv, params, i, invalid_param)) {
throw std::invalid_argument("error: unknown argument: " + arg);
}
}
diff --git a/common/json.hpp b/common/json.hpp
index ea945f346..a858728c4 100644
--- a/common/json.hpp
+++ b/common/json.hpp
@@ -1,9 +1,9 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
/****************************************************************************\
@@ -27,7 +27,6 @@
#endif // JSON_NO_IO
#include // random_access_iterator_tag
#include // unique_ptr
-#include // accumulate
#include // string, stoi, to_string
#include // declval, forward, move, pair, swap
#include // vector
@@ -35,10 +34,10 @@
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -48,10 +47,10 @@
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -60,7 +59,7 @@
#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
#if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
- #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 2
+ #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 3
#warning "Already included a different version of the library!"
#endif
#endif
@@ -68,7 +67,7 @@
#define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum)
#define NLOHMANN_JSON_VERSION_MINOR 11 // NOLINT(modernize-macro-to-enum)
-#define NLOHMANN_JSON_VERSION_PATCH 2 // NOLINT(modernize-macro-to-enum)
+#define NLOHMANN_JSON_VERSION_PATCH 3 // NOLINT(modernize-macro-to-enum)
#ifndef JSON_DIAGNOSTICS
#define JSON_DIAGNOSTICS 0
@@ -150,10 +149,10 @@
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -173,16 +172,19 @@
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
#include // nullptr_t
#include // exception
+#if JSON_DIAGNOSTICS
+ #include // accumulate
+#endif
#include // runtime_error
#include // to_string
#include // vector
@@ -190,10 +192,10 @@
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -206,10 +208,10 @@
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -218,10 +220,10 @@
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -231,10 +233,10 @@
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -318,10 +320,10 @@ NLOHMANN_JSON_NAMESPACE_END
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-FileCopyrightText: 2016-2021 Evan Nemerson
// SPDX-License-Identifier: MIT
@@ -2483,6 +2485,14 @@ JSON_HEDLEY_DIAGNOSTIC_POP
#endif
#endif
+#ifndef JSON_HAS_STATIC_RTTI
+ #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0
+ #define JSON_HAS_STATIC_RTTI 1
+ #else
+ #define JSON_HAS_STATIC_RTTI 0
+ #endif
+#endif
+
#ifdef JSON_HAS_CPP_17
#define JSON_INLINE_VARIABLE inline
#else
@@ -2590,12 +2600,13 @@ JSON_HEDLEY_DIAGNOSTIC_POP
class NumberUnsignedType, class NumberFloatType, \
template class AllocatorType, \
template class JSONSerializer, \
- class BinaryType>
+ class BinaryType, \
+ class CustomBaseClass>
#define NLOHMANN_BASIC_JSON_TPL \
basic_json
+ AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>
// Macros to simplify conversion from/to types
@@ -2745,7 +2756,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
- friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
+ friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
+
+#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
+ friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
/*!
@brief macro
@@ -2756,10 +2770,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP
inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
+#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
+ inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
+
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
- inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
-
+ inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
// inspired from https://stackoverflow.com/a/26745591
// allows to call any std function as if (e.g. with begin):
@@ -2923,10 +2939,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -2998,10 +3014,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -3040,10 +3056,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-FileCopyrightText: 2018 The Abseil Authors
// SPDX-License-Identifier: MIT
@@ -3214,10 +3230,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -3226,14 +3242,15 @@ NLOHMANN_JSON_NAMESPACE_END
#include // false_type, is_constructible, is_integral, is_same, true_type
#include // declval
#include // tuple
+#include // char_traits
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -3298,10 +3315,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -3318,10 +3335,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -3342,10 +3359,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
@@ -3389,7 +3406,8 @@ NLOHMANN_JSON_NAMESPACE_END
template class AllocatorType = std::allocator,
template class JSONSerializer =
adl_serializer,
- class BinaryType = std::vector>
+ class BinaryType = std::vector, // cppcheck-suppress syntaxError
+ class CustomBaseClass = void>
class basic_json;
/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
@@ -3577,6 +3595,63 @@ struct actual_object_comparator
template
using actual_object_comparator_t = typename actual_object_comparator::type;
+/////////////////
+// char_traits //
+/////////////////
+
+// Primary template of char_traits calls std char_traits
+template
+struct char_traits : std::char_traits
+{};
+
+// Explicitly define char traits for unsigned char since it is not standard
+template<>
+struct char_traits : std::char_traits
+{
+ using char_type = unsigned char;
+ using int_type = uint64_t;
+
+ // Redefine to_int_type function
+ static int_type to_int_type(char_type c) noexcept
+ {
+ return static_cast(c);
+ }
+
+ static char_type to_char_type(int_type i) noexcept
+ {
+ return static_cast(i);
+ }
+
+ static constexpr int_type eof() noexcept
+ {
+ return static_cast(EOF);
+ }
+};
+
+// Explicitly define char traits for signed char since it is not standard
+template<>
+struct char_traits : std::char_traits
+{
+ using char_type = signed char;
+ using int_type = uint64_t;
+
+ // Redefine to_int_type function
+ static int_type to_int_type(char_type c) noexcept
+ {
+ return static_cast(c);
+ }
+
+ static char_type to_char_type(int_type i) noexcept
+ {
+ return static_cast(i);
+ }
+
+ static constexpr int_type eof() noexcept
+ {
+ return static_cast(EOF);
+ }
+};
+
///////////////////
// is_ functions //
///////////////////
@@ -3613,7 +3688,6 @@ template
struct is_default_constructible>
: conjunction...> {};
-
template
struct is_constructible : std::is_constructible {};
@@ -3629,7 +3703,6 @@ struct is_constructible> : is_default_constructible
struct is_constructible> : is_default_constructible> {};
-
template
struct is_iterator_traits : std::false_type {};
@@ -4039,7 +4112,6 @@ struct value_in_range_of_impl2
}
};
-
template
struct value_in_range_of_impl2
{
@@ -4138,10 +4210,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -4165,28 +4237,28 @@ inline std::size_t concat_length()
}
template
-inline std::size_t concat_length(const char* cstr, Args&& ... rest);
+inline std::size_t concat_length(const char* cstr, const Args& ... rest);
template
-inline std::size_t concat_length(const StringType& str, Args&& ... rest);
+inline std::size_t concat_length(const StringType& str, const Args& ... rest);
template
-inline std::size_t concat_length(const char /*c*/, Args&& ... rest)
+inline std::size_t concat_length(const char /*c*/, const Args& ... rest)
{
- return 1 + concat_length(std::forward(rest)...);
+ return 1 + concat_length(rest...);
}
template
-inline std::size_t concat_length(const char* cstr, Args&& ... rest)
+inline std::size_t concat_length(const char* cstr, const Args& ... rest)
{
// cppcheck-suppress ignoredReturnValue
- return ::strlen(cstr) + concat_length(std::forward(rest)...);
+ return ::strlen(cstr) + concat_length(rest...);
}
template
-inline std::size_t concat_length(const StringType& str, Args&& ... rest)
+inline std::size_t concat_length(const StringType& str, const Args& ... rest)
{
- return str.size() + concat_length(std::forward(rest)...);
+ return str.size() + concat_length(rest...);
}
template
@@ -4277,7 +4349,7 @@ template
inline OutStringType concat(Args && ... args)
{
OutStringType str;
- str.reserve(concat_length(std::forward(args)...));
+ str.reserve(concat_length(args...));
concat_into(str, std::forward(args)...);
return str;
}
@@ -4286,7 +4358,6 @@ inline OutStringType concat(Args && ... args)
NLOHMANN_JSON_NAMESPACE_END
-
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
@@ -4334,9 +4405,9 @@ class exception : public std::exception
{
case value_t::array:
{
- for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
+ for (std::size_t i = 0; i < current->m_parent->m_data.m_value.array->size(); ++i)
{
- if (¤t->m_parent->m_value.array->operator[](i) == current)
+ if (¤t->m_parent->m_data.m_value.array->operator[](i) == current)
{
tokens.emplace_back(std::to_string(i));
break;
@@ -4347,7 +4418,7 @@ class exception : public std::exception
case value_t::object:
{
- for (const auto& element : *current->m_parent->m_value.object)
+ for (const auto& element : *current->m_parent->m_data.m_value.object)
{
if (&element.second == current)
{
@@ -4410,17 +4481,17 @@ class parse_error : public exception
template::value, int> = 0>
static parse_error create(int id_, const position_t& pos, const std::string& what_arg, BasicJsonContext context)
{
- std::string w = concat(exception::name("parse_error", id_), "parse error",
- position_string(pos), ": ", exception::diagnostics(context), what_arg);
+ const std::string w = concat(exception::name("parse_error", id_), "parse error",
+ position_string(pos), ": ", exception::diagnostics(context), what_arg);
return {id_, pos.chars_read_total, w.c_str()};
}
template::value, int> = 0>
static parse_error create(int id_, std::size_t byte_, const std::string& what_arg, BasicJsonContext context)
{
- std::string w = concat(exception::name("parse_error", id_), "parse error",
- (byte_ != 0 ? (concat(" at byte ", std::to_string(byte_))) : ""),
- ": ", exception::diagnostics(context), what_arg);
+ const std::string w = concat(exception::name("parse_error", id_), "parse error",
+ (byte_ != 0 ? (concat(" at byte ", std::to_string(byte_))) : ""),
+ ": ", exception::diagnostics(context), what_arg);
return {id_, byte_, w.c_str()};
}
@@ -4454,7 +4525,7 @@ class invalid_iterator : public exception
template::value, int> = 0>
static invalid_iterator create(int id_, const std::string& what_arg, BasicJsonContext context)
{
- std::string w = concat(exception::name("invalid_iterator", id_), exception::diagnostics(context), what_arg);
+ const std::string w = concat(exception::name("invalid_iterator", id_), exception::diagnostics(context), what_arg);
return {id_, w.c_str()};
}
@@ -4472,7 +4543,7 @@ class type_error : public exception
template::value, int> = 0>
static type_error create(int id_, const std::string& what_arg, BasicJsonContext context)
{
- std::string w = concat(exception::name("type_error", id_), exception::diagnostics(context), what_arg);
+ const std::string w = concat(exception::name("type_error", id_), exception::diagnostics(context), what_arg);
return {id_, w.c_str()};
}
@@ -4489,7 +4560,7 @@ class out_of_range : public exception
template::value, int> = 0>
static out_of_range create(int id_, const std::string& what_arg, BasicJsonContext context)
{
- std::string w = concat(exception::name("out_of_range", id_), exception::diagnostics(context), what_arg);
+ const std::string w = concat(exception::name("out_of_range", id_), exception::diagnostics(context), what_arg);
return {id_, w.c_str()};
}
@@ -4506,7 +4577,7 @@ class other_error : public exception
template::value, int> = 0>
static other_error create(int id_, const std::string& what_arg, BasicJsonContext context)
{
- std::string w = concat(exception::name("other_error", id_), exception::diagnostics(context), what_arg);
+ const std::string w = concat(exception::name("other_error", id_), exception::diagnostics(context), what_arg);
return {id_, w.c_str()};
}
@@ -4525,10 +4596,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -4549,10 +4620,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -5055,10 +5126,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -5075,10 +5146,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -5147,10 +5218,10 @@ template class iteration_proxy_value
// older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions
iteration_proxy_value(iteration_proxy_value&&)
noexcept(std::is_nothrow_move_constructible::value
- && std::is_nothrow_move_constructible::value) = default;
+ && std::is_nothrow_move_constructible::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations)
iteration_proxy_value& operator=(iteration_proxy_value&&)
noexcept(std::is_nothrow_move_assignable::value
- && std::is_nothrow_move_assignable::value) = default;
+ && std::is_nothrow_move_assignable::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations)
~iteration_proxy_value() = default;
/// dereference operator (needed for range-based for)
@@ -5297,11 +5368,11 @@ namespace std
#pragma clang diagnostic ignored "-Wmismatched-tags"
#endif
template
-class tuple_size<::nlohmann::detail::iteration_proxy_value>
+class tuple_size<::nlohmann::detail::iteration_proxy_value> // NOLINT(cert-dcl58-cpp)
: public std::integral_constant {};
template
-class tuple_element>
+class tuple_element> // NOLINT(cert-dcl58-cpp)
{
public:
using type = decltype(
@@ -5340,7 +5411,7 @@ namespace detail
/*
* Note all external_constructor<>::construct functions need to call
- * j.m_value.destroy(j.m_type) to avoid a memory leak in case j contains an
+ * j.m_data.m_value.destroy(j.m_data.m_type) to avoid a memory leak in case j contains an
* allocated value (e.g., a string). See bug issue
* https://github.com/nlohmann/json/issues/2865 for more information.
*/
@@ -5353,9 +5424,9 @@ struct external_constructor
template
static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept
{
- j.m_value.destroy(j.m_type);
- j.m_type = value_t::boolean;
- j.m_value = b;
+ j.m_data.m_value.destroy(j.m_data.m_type);
+ j.m_data.m_type = value_t::boolean;
+ j.m_data.m_value = b;
j.assert_invariant();
}
};
@@ -5366,18 +5437,18 @@ struct external_constructor
template
static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s)
{
- j.m_value.destroy(j.m_type);
- j.m_type = value_t::string;
- j.m_value = s;
+ j.m_data.m_value.destroy(j.m_data.m_type);
+ j.m_data.m_type = value_t::string;
+ j.m_data.m_value = s;
j.assert_invariant();
}
template
static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s)
{
- j.m_value.destroy(j.m_type);
- j.m_type = value_t::string;
- j.m_value = std::move(s);
+ j.m_data.m_value.destroy(j.m_data.m_type);
+ j.m_data.m_type = value_t::string;
+ j.m_data.m_value = std::move(s);
j.assert_invariant();
}
@@ -5386,9 +5457,9 @@ struct external_constructor
int > = 0 >
static void construct(BasicJsonType& j, const CompatibleStringType& str)
{
- j.m_value.destroy(j.m_type);
- j.m_type = value_t::string;
- j.m_value.string = j.template create(str);
+ j.m_data.m_value.destroy(j.m_data.m_type);
+ j.m_data.m_type = value_t::string;
+ j.m_data.m_value.string = j.template create(str);
j.assert_invariant();
}
};
@@ -5399,18 +5470,18 @@ struct external_constructor
template
static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b)
{
- j.m_value.destroy(j.m_type);
- j.m_type = value_t::binary;
- j.m_value = typename BasicJsonType::binary_t(b);
+ j.m_data.m_value.destroy(j.m_data.m_type);
+ j.m_data.m_type = value_t::binary;
+ j.m_data.m_value = typename BasicJsonType::binary_t(b);
j.assert_invariant();
}
template
static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b)
{
- j.m_value.destroy(j.m_type);
- j.m_type = value_t::binary;
- j.m_value = typename BasicJsonType::binary_t(std::move(b));
+ j.m_data.m_value.destroy(j.m_data.m_type);
+ j.m_data.m_type = value_t::binary;
+ j.m_data.m_value = typename BasicJsonType::binary_t(std::move(b));
j.assert_invariant();
}
};
@@ -5421,9 +5492,9 @@ struct external_constructor
template
static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept
{
- j.m_value.destroy(j.m_type);
- j.m_type = value_t::number_float;
- j.m_value = val;
+ j.m_data.m_value.destroy(j.m_data.m_type);
+ j.m_data.m_type = value_t::number_float;
+ j.m_data.m_value = val;
j.assert_invariant();
}
};
@@ -5434,9 +5505,9 @@ struct external_constructor
template
static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept
{
- j.m_value.destroy(j.m_type);
- j.m_type = value_t::number_unsigned;
- j.m_value = val;
+ j.m_data.m_value.destroy(j.m_data.m_type);
+ j.m_data.m_type = value_t::number_unsigned;
+ j.m_data.m_value = val;
j.assert_invariant();
}
};
@@ -5447,9 +5518,9 @@ struct external_constructor
template
static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept
{
- j.m_value.destroy(j.m_type);
- j.m_type = value_t::number_integer;
- j.m_value = val;
+ j.m_data.m_value.destroy(j.m_data.m_type);
+ j.m_data.m_type = value_t::number_integer;
+ j.m_data.m_value = val;
j.assert_invariant();
}
};
@@ -5460,9 +5531,9 @@ struct external_constructor
template
static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr)
{
- j.m_value.destroy(j.m_type);
- j.m_type = value_t::array;
- j.m_value = arr;
+ j.m_data.m_value.destroy(j.m_data.m_type);
+ j.m_data.m_type = value_t::array;
+ j.m_data.m_value = arr;
j.set_parents();
j.assert_invariant();
}
@@ -5470,9 +5541,9 @@ struct external_constructor
template
static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
{
- j.m_value.destroy(j.m_type);
- j.m_type = value_t::array;
- j.m_value = std::move(arr);
+ j.m_data.m_value.destroy(j.m_data.m_type);
+ j.m_data.m_type = value_t::array;
+ j.m_data.m_value = std::move(arr);
j.set_parents();
j.assert_invariant();
}
@@ -5485,9 +5556,9 @@ struct external_constructor
using std::begin;
using std::end;
- j.m_value.destroy(j.m_type);
- j.m_type = value_t::array;
- j.m_value.array = j.template create(begin(arr), end(arr));
+ j.m_data.m_value.destroy(j.m_data.m_type);
+ j.m_data.m_type = value_t::array;
+ j.m_data.m_value.array = j.template create(begin(arr), end(arr));
j.set_parents();
j.assert_invariant();
}
@@ -5495,14 +5566,14 @@ struct external_constructor
template
static void construct(BasicJsonType& j, const std::vector& arr)
{
- j.m_value.destroy(j.m_type);
- j.m_type = value_t::array;
- j.m_value = value_t::array;
- j.m_value.array->reserve(arr.size());
+ j.m_data.m_value.destroy(j.m_data.m_type);
+ j.m_data.m_type = value_t::array;
+ j.m_data.m_value = value_t::array;
+ j.m_data.m_value.array->reserve(arr.size());
for (const bool x : arr)
{
- j.m_value.array->push_back(x);
- j.set_parent(j.m_value.array->back());
+ j.m_data.m_value.array->push_back(x);
+ j.set_parent(j.m_data.m_value.array->back());
}
j.assert_invariant();
}
@@ -5511,13 +5582,13 @@ struct external_constructor
enable_if_t::value, int> = 0>
static void construct(BasicJsonType& j, const std::valarray& arr)
{
- j.m_value.destroy(j.m_type);
- j.m_type = value_t::array;
- j.m_value = value_t::array;
- j.m_value.array->resize(arr.size());
+ j.m_data.m_value.destroy(j.m_data.m_type);
+ j.m_data.m_type = value_t::array;
+ j.m_data.m_value = value_t::array;
+ j.m_data.m_value.array->resize(arr.size());
if (arr.size() > 0)
{
- std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
+ std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin());
}
j.set_parents();
j.assert_invariant();
@@ -5530,9 +5601,9 @@ struct external_constructor
template
static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj)
{
- j.m_value.destroy(j.m_type);
- j.m_type = value_t::object;
- j.m_value = obj;
+ j.m_data.m_value.destroy(j.m_data.m_type);
+ j.m_data.m_type = value_t::object;
+ j.m_data.m_value = obj;
j.set_parents();
j.assert_invariant();
}
@@ -5540,9 +5611,9 @@ struct external_constructor
template
static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
{
- j.m_value.destroy(j.m_type);
- j.m_type = value_t::object;
- j.m_value = std::move(obj);
+ j.m_data.m_value.destroy(j.m_data.m_type);
+ j.m_data.m_type = value_t::object;
+ j.m_data.m_value = std::move(obj);
j.set_parents();
j.assert_invariant();
}
@@ -5554,9 +5625,9 @@ struct external_constructor
using std::begin;
using std::end;
- j.m_value.destroy(j.m_type);
- j.m_type = value_t::object;
- j.m_value.object = j.template create(begin(obj), end(obj));
+ j.m_data.m_value.destroy(j.m_data.m_type);
+ j.m_data.m_type = value_t::object;
+ j.m_data.m_value.object = j.template create(begin(obj), end(obj));
j.set_parents();
j.assert_invariant();
}
@@ -5626,7 +5697,8 @@ template::type;
- external_constructor::construct(j, static_cast(e));
+ static constexpr value_t integral_value_t = std::is_unsigned::value ? value_t::number_unsigned : value_t::number_integer;
+ external_constructor::construct(j, static_cast(e));
}
#endif // JSON_DISABLE_ENUM_SERIALIZATION
@@ -5796,10 +5868,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -5908,10 +5980,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -6041,10 +6113,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -6067,10 +6139,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -6094,6 +6166,8 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
+// #include
+
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
@@ -6140,7 +6214,6 @@ class file_input_adapter
std::FILE* m_file;
};
-
/*!
Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at
beginning of input. Does not support changing the underlying std::streambuf
@@ -6214,16 +6287,16 @@ class iterator_input_adapter
: current(std::move(first)), end(std::move(last))
{}
- typename std::char_traits::int_type get_character()
+ typename char_traits::int_type get_character()
{
if (JSON_HEDLEY_LIKELY(current != end))
{
- auto result = std::char_traits::to_int_type(*current);
+ auto result = char_traits::to_int_type(*current);
std::advance(current, 1);
return result;
}
- return std::char_traits::eof();
+ return char_traits::eof();
}
private:
@@ -6239,7 +6312,6 @@ class iterator_input_adapter
}
};
-
template
struct wide_string_input_helper;
@@ -6363,7 +6435,7 @@ struct wide_string_input_helper
}
};
-// Wraps another input apdater to convert wide character types into individual bytes.
+// Wraps another input adapter to convert wide character types into individual bytes.
template
class wide_string_input_adapter
{
@@ -6408,7 +6480,6 @@ class wide_string_input_adapter
std::size_t utf8_bytes_filled = 0;
};
-
template
struct iterator_input_adapter_factory
{
@@ -6565,10 +6636,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -6710,7 +6781,6 @@ struct json_sax
virtual ~json_sax() = default;
};
-
namespace detail
{
/*!
@@ -6812,7 +6882,7 @@ class json_sax_dom_parser
JSON_ASSERT(ref_stack.back()->is_object());
// add null at given key and store the reference for later
- object_element = &(ref_stack.back()->m_value.object->operator[](val));
+ object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
return true;
}
@@ -6887,8 +6957,8 @@ class json_sax_dom_parser
if (ref_stack.back()->is_array())
{
- ref_stack.back()->m_value.array->emplace_back(std::forward(v));
- return &(ref_stack.back()->m_value.array->back());
+ ref_stack.back()->m_data.m_value.array->emplace_back(std::forward(v));
+ return &(ref_stack.back()->m_data.m_value.array->back());
}
JSON_ASSERT(ref_stack.back()->is_object());
@@ -7007,7 +7077,7 @@ class json_sax_dom_callback_parser
// add discarded value at given key and store the reference for later
if (keep && ref_stack.back())
{
- object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded);
+ object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) = discarded);
}
return true;
@@ -7092,7 +7162,7 @@ class json_sax_dom_callback_parser
// remove discarded value
if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
{
- ref_stack.back()->m_value.array->pop_back();
+ ref_stack.back()->m_data.m_value.array->pop_back();
}
return true;
@@ -7159,7 +7229,7 @@ class json_sax_dom_callback_parser
if (ref_stack.empty())
{
root = std::move(value);
- return {true, &root};
+ return {true, & root};
}
// skip this value if we already decided to skip the parent
@@ -7175,8 +7245,8 @@ class json_sax_dom_callback_parser
// array
if (ref_stack.back()->is_array())
{
- ref_stack.back()->m_value.array->emplace_back(std::move(value));
- return {true, &(ref_stack.back()->m_value.array->back())};
+ ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value));
+ return {true, & (ref_stack.back()->m_data.m_value.array->back())};
}
// object
@@ -7201,9 +7271,9 @@ class json_sax_dom_callback_parser
/// stack to model hierarchy of values
std::vector ref_stack {};
/// stack to manage which values to keep
- std::vector keep_stack {};
+ std::vector keep_stack {}; // NOLINT(readability-redundant-member-init)
/// stack to manage which object keys to keep
- std::vector key_keep_stack {};
+ std::vector key_keep_stack {}; // NOLINT(readability-redundant-member-init)
/// helper to hold the reference for the next object element
BasicJsonType* object_element = nullptr;
/// whether a syntax error occurred
@@ -7298,10 +7368,10 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann
// SPDX-License-Identifier: MIT
@@ -7322,6 +7392,8 @@ NLOHMANN_JSON_NAMESPACE_END
// #include
+// #include
+
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
@@ -7416,7 +7488,7 @@ class lexer : public lexer_base
using number_float_t = typename BasicJsonType::number_float_t;
using string_t = typename BasicJsonType::string_t;
using char_type = typename InputAdapterType::char_type;
- using char_int_type = typename std::char_traits::int_type;
+ using char_int_type = typename char_traits::int_type;
public:
using token_type = typename lexer_base::token_type;
@@ -7523,7 +7595,7 @@ class lexer : public lexer_base
for (auto range = ranges.begin(); range != ranges.end(); ++range)
{
get();
- if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range)))
+ if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) // NOLINT(bugprone-inc-dec-in-conditions)
{
add(current);
}
@@ -7566,7 +7638,7 @@ class lexer : public lexer_base
switch (get())
{
// end of file while parsing string
- case std::char_traits::eof():
+ case char_traits::eof():
{
error_message = "invalid string: missing closing quote";
return token_type::parse_error;
@@ -8155,7 +8227,7 @@ class lexer : public lexer_base