@fugood/llama.node 0.3.17 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/CMakeLists.txt +3 -1
  2. package/bin/darwin/arm64/llama-node.node +0 -0
  3. package/bin/darwin/x64/llama-node.node +0 -0
  4. package/bin/linux/arm64/llama-node.node +0 -0
  5. package/bin/linux/x64/llama-node.node +0 -0
  6. package/bin/linux-cuda/arm64/llama-node.node +0 -0
  7. package/bin/linux-cuda/x64/llama-node.node +0 -0
  8. package/bin/linux-vulkan/arm64/llama-node.node +0 -0
  9. package/bin/linux-vulkan/x64/llama-node.node +0 -0
  10. package/bin/win32/arm64/llama-node.node +0 -0
  11. package/bin/win32/arm64/node.lib +0 -0
  12. package/bin/win32/x64/llama-node.node +0 -0
  13. package/bin/win32/x64/node.lib +0 -0
  14. package/bin/win32-vulkan/arm64/llama-node.node +0 -0
  15. package/bin/win32-vulkan/arm64/node.lib +0 -0
  16. package/bin/win32-vulkan/x64/llama-node.node +0 -0
  17. package/bin/win32-vulkan/x64/node.lib +0 -0
  18. package/lib/binding.ts +39 -2
  19. package/lib/index.js +132 -1
  20. package/lib/index.ts +203 -3
  21. package/package.json +2 -1
  22. package/src/EmbeddingWorker.cpp +1 -1
  23. package/src/LlamaCompletionWorker.cpp +366 -19
  24. package/src/LlamaCompletionWorker.h +30 -10
  25. package/src/LlamaContext.cpp +213 -5
  26. package/src/LlamaContext.h +12 -0
  27. package/src/common.hpp +15 -0
  28. package/src/llama.cpp/.github/workflows/build-linux-cross.yml +133 -24
  29. package/src/llama.cpp/.github/workflows/build.yml +41 -762
  30. package/src/llama.cpp/.github/workflows/docker.yml +5 -2
  31. package/src/llama.cpp/.github/workflows/release.yml +716 -0
  32. package/src/llama.cpp/.github/workflows/server.yml +12 -12
  33. package/src/llama.cpp/CMakeLists.txt +5 -17
  34. package/src/llama.cpp/cmake/build-info.cmake +8 -2
  35. package/src/llama.cpp/cmake/x64-windows-llvm.cmake +0 -6
  36. package/src/llama.cpp/common/CMakeLists.txt +31 -3
  37. package/src/llama.cpp/common/arg.cpp +48 -29
  38. package/src/llama.cpp/common/chat.cpp +128 -106
  39. package/src/llama.cpp/common/chat.h +2 -0
  40. package/src/llama.cpp/common/common.cpp +37 -1
  41. package/src/llama.cpp/common/common.h +18 -9
  42. package/src/llama.cpp/common/llguidance.cpp +1 -0
  43. package/src/llama.cpp/common/minja/chat-template.hpp +9 -5
  44. package/src/llama.cpp/common/minja/minja.hpp +69 -36
  45. package/src/llama.cpp/common/regex-partial.cpp +204 -0
  46. package/src/llama.cpp/common/regex-partial.h +56 -0
  47. package/src/llama.cpp/common/sampling.cpp +57 -50
  48. package/src/llama.cpp/examples/CMakeLists.txt +2 -23
  49. package/src/llama.cpp/examples/embedding/embedding.cpp +2 -11
  50. package/src/llama.cpp/examples/parallel/parallel.cpp +86 -14
  51. package/src/llama.cpp/examples/training/CMakeLists.txt +5 -0
  52. package/src/llama.cpp/examples/training/finetune.cpp +96 -0
  53. package/src/llama.cpp/ggml/CMakeLists.txt +27 -0
  54. package/src/llama.cpp/ggml/include/ggml-backend.h +4 -4
  55. package/src/llama.cpp/ggml/include/ggml-cpp.h +1 -1
  56. package/src/llama.cpp/ggml/include/ggml-opt.h +47 -28
  57. package/src/llama.cpp/ggml/include/ggml.h +10 -7
  58. package/src/llama.cpp/ggml/src/CMakeLists.txt +1 -1
  59. package/src/llama.cpp/ggml/src/ggml-alloc.c +4 -1
  60. package/src/llama.cpp/ggml/src/ggml-backend.cpp +9 -5
  61. package/src/llama.cpp/ggml/src/ggml-cpu/CMakeLists.txt +20 -13
  62. package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp +0 -2
  63. package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu-quants.c +306 -6
  64. package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu.c +4 -13
  65. package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu.cpp +29 -16
  66. package/src/llama.cpp/ggml/src/ggml-cpu/kleidiai/kernels.cpp +88 -5
  67. package/src/llama.cpp/ggml/src/ggml-cpu/kleidiai/kernels.h +47 -12
  68. package/src/llama.cpp/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp +264 -69
  69. package/src/llama.cpp/ggml/src/ggml-cpu/llamafile/sgemm.cpp +501 -0
  70. package/src/llama.cpp/ggml/src/ggml-cpu/ops.cpp +0 -13
  71. package/src/llama.cpp/ggml/src/ggml-cpu/vec.cpp +0 -6
  72. package/src/llama.cpp/ggml/src/ggml-cuda/CMakeLists.txt +23 -4
  73. package/src/llama.cpp/ggml/src/ggml-metal/ggml-metal-impl.h +36 -11
  74. package/src/llama.cpp/ggml/src/ggml-opencl/ggml-opencl.cpp +0 -2
  75. package/src/llama.cpp/ggml/src/ggml-opt.cpp +368 -190
  76. package/src/llama.cpp/ggml/src/ggml-quants.c +0 -6
  77. package/src/llama.cpp/ggml/src/ggml-rpc/ggml-rpc.cpp +41 -27
  78. package/src/llama.cpp/ggml/src/ggml-sycl/CMakeLists.txt +29 -23
  79. package/src/llama.cpp/ggml/src/ggml-sycl/backend.hpp +9 -8
  80. package/src/llama.cpp/ggml/src/ggml-sycl/binbcast.cpp +121 -232
  81. package/src/llama.cpp/ggml/src/ggml-sycl/common.hpp +7 -15
  82. package/src/llama.cpp/ggml/src/ggml-sycl/convert.cpp +72 -25
  83. package/src/llama.cpp/ggml/src/ggml-sycl/convert.hpp +14 -7
  84. package/src/llama.cpp/ggml/src/ggml-sycl/dequantize.hpp +59 -21
  85. package/src/llama.cpp/ggml/src/ggml-sycl/dmmv.cpp +7 -1
  86. package/src/llama.cpp/ggml/src/ggml-sycl/element_wise.cpp +0 -23
  87. package/src/llama.cpp/ggml/src/ggml-sycl/gemm.hpp +37 -8
  88. package/src/llama.cpp/ggml/src/ggml-sycl/ggml-sycl.cpp +338 -166
  89. package/src/llama.cpp/ggml/src/ggml-sycl/mmvq.cpp +185 -89
  90. package/src/llama.cpp/ggml/src/ggml-sycl/quants.hpp +83 -0
  91. package/src/llama.cpp/ggml/src/ggml-sycl/vecdotq.hpp +128 -53
  92. package/src/llama.cpp/ggml/src/ggml-vulkan/CMakeLists.txt +81 -70
  93. package/src/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp +657 -193
  94. package/src/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt +20 -0
  95. package/src/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +123 -29
  96. package/src/llama.cpp/ggml/src/ggml.c +29 -20
  97. package/src/llama.cpp/ggml/src/gguf.cpp +33 -33
  98. package/src/llama.cpp/include/llama.h +52 -11
  99. package/src/llama.cpp/requirements/requirements-all.txt +3 -3
  100. package/src/llama.cpp/scripts/xxd.cmake +1 -1
  101. package/src/llama.cpp/src/CMakeLists.txt +1 -0
  102. package/src/llama.cpp/src/llama-adapter.cpp +6 -0
  103. package/src/llama.cpp/src/llama-arch.cpp +3 -0
  104. package/src/llama.cpp/src/llama-batch.cpp +5 -1
  105. package/src/llama.cpp/src/llama-batch.h +2 -1
  106. package/src/llama.cpp/src/llama-chat.cpp +17 -7
  107. package/src/llama.cpp/src/llama-chat.h +1 -0
  108. package/src/llama.cpp/src/llama-context.cpp +389 -501
  109. package/src/llama.cpp/src/llama-context.h +44 -32
  110. package/src/llama.cpp/src/llama-cparams.h +1 -0
  111. package/src/llama.cpp/src/llama-graph.cpp +20 -38
  112. package/src/llama.cpp/src/llama-graph.h +12 -8
  113. package/src/llama.cpp/src/llama-kv-cache.cpp +1503 -389
  114. package/src/llama.cpp/src/llama-kv-cache.h +271 -85
  115. package/src/llama.cpp/src/llama-memory.h +11 -1
  116. package/src/llama.cpp/src/llama-model-loader.cpp +24 -15
  117. package/src/llama.cpp/src/llama-model-saver.cpp +281 -0
  118. package/src/llama.cpp/src/llama-model-saver.h +37 -0
  119. package/src/llama.cpp/src/llama-model.cpp +316 -69
  120. package/src/llama.cpp/src/llama-model.h +8 -1
  121. package/src/llama.cpp/src/llama-quant.cpp +15 -13
  122. package/src/llama.cpp/src/llama-sampling.cpp +18 -6
  123. package/src/llama.cpp/src/llama-vocab.cpp +42 -4
  124. package/src/llama.cpp/src/llama-vocab.h +6 -0
  125. package/src/llama.cpp/src/llama.cpp +14 -0
  126. package/src/llama.cpp/tests/CMakeLists.txt +10 -2
  127. package/src/llama.cpp/tests/test-backend-ops.cpp +107 -47
  128. package/src/llama.cpp/tests/test-chat-template.cpp +10 -11
  129. package/src/llama.cpp/tests/test-chat.cpp +3 -1
  130. package/src/llama.cpp/tests/test-mtmd-c-api.c +63 -0
  131. package/src/llama.cpp/tests/test-opt.cpp +33 -21
  132. package/src/llama.cpp/tests/test-regex-partial.cpp +288 -0
  133. package/src/llama.cpp/tests/test-sampling.cpp +1 -1
  134. package/src/llama.cpp/tools/CMakeLists.txt +39 -0
  135. package/src/llama.cpp/{examples → tools}/batched-bench/batched-bench.cpp +2 -2
  136. package/src/llama.cpp/{examples → tools}/imatrix/imatrix.cpp +11 -9
  137. package/src/llama.cpp/{examples → tools}/llama-bench/llama-bench.cpp +495 -348
  138. package/src/llama.cpp/{examples → tools}/main/main.cpp +6 -9
  139. package/src/llama.cpp/{examples/llava → tools/mtmd}/CMakeLists.txt +1 -35
  140. package/src/llama.cpp/{examples/llava → tools/mtmd}/clip-impl.h +25 -5
  141. package/src/llama.cpp/{examples/llava → tools/mtmd}/clip.cpp +1440 -1349
  142. package/src/llama.cpp/tools/mtmd/clip.h +99 -0
  143. package/src/llama.cpp/{examples/llava → tools/mtmd}/mtmd-cli.cpp +70 -44
  144. package/src/llama.cpp/tools/mtmd/mtmd-helper.cpp +310 -0
  145. package/src/llama.cpp/{examples/llava → tools/mtmd}/mtmd.cpp +251 -281
  146. package/src/llama.cpp/tools/mtmd/mtmd.h +331 -0
  147. package/src/llama.cpp/{examples → tools}/perplexity/perplexity.cpp +4 -2
  148. package/src/llama.cpp/{examples → tools}/quantize/quantize.cpp +13 -76
  149. package/src/llama.cpp/{examples → tools}/rpc/rpc-server.cpp +70 -74
  150. package/src/llama.cpp/{examples → tools}/run/run.cpp +18 -4
  151. package/src/llama.cpp/{examples → tools}/server/CMakeLists.txt +2 -1
  152. package/src/llama.cpp/{examples → tools}/server/server.cpp +291 -76
  153. package/src/llama.cpp/{examples → tools}/server/utils.hpp +377 -5
  154. package/src/llama.cpp/cmake/arm64-windows-msvc.cmake +0 -6
  155. package/src/llama.cpp/examples/infill/CMakeLists.txt +0 -5
  156. package/src/llama.cpp/examples/infill/infill.cpp +0 -590
  157. package/src/llama.cpp/examples/llava/android/build_64.sh +0 -8
  158. package/src/llama.cpp/examples/llava/clip-quantize-cli.cpp +0 -59
  159. package/src/llama.cpp/examples/llava/clip.h +0 -135
  160. package/src/llama.cpp/examples/llava/llava.cpp +0 -586
  161. package/src/llama.cpp/examples/llava/llava.h +0 -49
  162. package/src/llama.cpp/examples/llava/mtmd.h +0 -168
  163. package/src/llama.cpp/examples/llava/qwen2vl-test.cpp +0 -636
  164. /package/src/llama.cpp/{examples → tools}/batched-bench/CMakeLists.txt +0 -0
  165. /package/src/llama.cpp/{examples → tools}/cvector-generator/CMakeLists.txt +0 -0
  166. /package/src/llama.cpp/{examples → tools}/cvector-generator/completions.txt +0 -0
  167. /package/src/llama.cpp/{examples → tools}/cvector-generator/cvector-generator.cpp +0 -0
  168. /package/src/llama.cpp/{examples → tools}/cvector-generator/mean.hpp +0 -0
  169. /package/src/llama.cpp/{examples → tools}/cvector-generator/negative.txt +0 -0
  170. /package/src/llama.cpp/{examples → tools}/cvector-generator/pca.hpp +0 -0
  171. /package/src/llama.cpp/{examples → tools}/cvector-generator/positive.txt +0 -0
  172. /package/src/llama.cpp/{examples → tools}/export-lora/CMakeLists.txt +0 -0
  173. /package/src/llama.cpp/{examples → tools}/export-lora/export-lora.cpp +0 -0
  174. /package/src/llama.cpp/{examples → tools}/gguf-split/CMakeLists.txt +0 -0
  175. /package/src/llama.cpp/{examples → tools}/gguf-split/gguf-split.cpp +0 -0
  176. /package/src/llama.cpp/{examples → tools}/imatrix/CMakeLists.txt +0 -0
  177. /package/src/llama.cpp/{examples → tools}/llama-bench/CMakeLists.txt +0 -0
  178. /package/src/llama.cpp/{examples → tools}/main/CMakeLists.txt +0 -0
  179. /package/src/llama.cpp/{examples/llava → tools/mtmd}/deprecation-warning.cpp +0 -0
  180. /package/src/llama.cpp/{examples/llava → tools/mtmd}/requirements.txt +0 -0
  181. /package/src/llama.cpp/{examples → tools}/perplexity/CMakeLists.txt +0 -0
  182. /package/src/llama.cpp/{examples → tools}/quantize/CMakeLists.txt +0 -0
  183. /package/src/llama.cpp/{examples → tools}/rpc/CMakeLists.txt +0 -0
  184. /package/src/llama.cpp/{examples → tools}/run/CMakeLists.txt +0 -0
  185. /package/src/llama.cpp/{examples → tools}/run/linenoise.cpp/linenoise.cpp +0 -0
  186. /package/src/llama.cpp/{examples → tools}/run/linenoise.cpp/linenoise.h +0 -0
  187. /package/src/llama.cpp/{examples → tools}/server/bench/requirements.txt +0 -0
  188. /package/src/llama.cpp/{examples → tools}/server/httplib.h +0 -0
  189. /package/src/llama.cpp/{examples → tools}/server/tests/requirements.txt +0 -0
  190. /package/src/llama.cpp/{examples → tools}/tokenize/CMakeLists.txt +0 -0
  191. /package/src/llama.cpp/{examples → tools}/tokenize/tokenize.cpp +0 -0
  192. /package/src/llama.cpp/{examples → tools}/tts/CMakeLists.txt +0 -0
  193. /package/src/llama.cpp/{examples → tools}/tts/tts.cpp +0 -0
@@ -11,6 +11,7 @@
11
11
  #include <algorithm>
12
12
  #include <cctype>
13
13
  #include <cstddef>
14
+ #include <cstdint>
14
15
  #include <cmath>
15
16
  #include <exception>
16
17
  #include <functional>
@@ -233,7 +234,7 @@ public:
233
234
  }
234
235
  } else if (is_object()) {
235
236
  if (!index.is_hashable())
236
- throw std::runtime_error("Unashable type: " + index.dump());
237
+ throw std::runtime_error("Unhashable type: " + index.dump());
237
238
  auto it = object_->find(index.primitive_);
238
239
  if (it == object_->end())
239
240
  throw std::runtime_error("Key not found: " + index.dump());
@@ -252,7 +253,7 @@ public:
252
253
  auto index = key.get<int>();
253
254
  return array_->at(index < 0 ? array_->size() + index : index);
254
255
  } else if (object_) {
255
- if (!key.is_hashable()) throw std::runtime_error("Unashable type: " + dump());
256
+ if (!key.is_hashable()) throw std::runtime_error("Unhashable type: " + dump());
256
257
  auto it = object_->find(key.primitive_);
257
258
  if (it == object_->end()) return Value();
258
259
  return it->second;
@@ -261,7 +262,7 @@ public:
261
262
  }
262
263
  void set(const Value& key, const Value& value) {
263
264
  if (!object_) throw std::runtime_error("Value is not an object: " + dump());
264
- if (!key.is_hashable()) throw std::runtime_error("Unashable type: " + dump());
265
+ if (!key.is_hashable()) throw std::runtime_error("Unhashable type: " + dump());
265
266
  (*object_)[key.primitive_] = value;
266
267
  }
267
268
  Value call(const std::shared_ptr<Context> & context, ArgumentsValue & args) const {
@@ -398,7 +399,7 @@ public:
398
399
  }
399
400
  return false;
400
401
  } else if (object_) {
401
- if (!value.is_hashable()) throw std::runtime_error("Unashable type: " + value.dump());
402
+ if (!value.is_hashable()) throw std::runtime_error("Unhashable type: " + value.dump());
402
403
  return object_->find(value.primitive_) != object_->end();
403
404
  } else {
404
405
  throw std::runtime_error("contains can only be called on arrays and objects: " + dump());
@@ -416,7 +417,7 @@ public:
416
417
  return const_cast<Value*>(this)->at(index);
417
418
  }
418
419
  Value& at(const Value & index) {
419
- if (!index.is_hashable()) throw std::runtime_error("Unashable type: " + dump());
420
+ if (!index.is_hashable()) throw std::runtime_error("Unhashable type: " + dump());
420
421
  if (is_array()) return array_->at(index.get<int>());
421
422
  if (is_object()) return object_->at(index.primitive_);
422
423
  throw std::runtime_error("Value is not an array or object: " + dump());
@@ -676,8 +677,8 @@ public:
676
677
  class VariableExpr : public Expression {
677
678
  std::string name;
678
679
  public:
679
- VariableExpr(const Location & location, const std::string& n)
680
- : Expression(location), name(n) {}
680
+ VariableExpr(const Location & loc, const std::string& n)
681
+ : Expression(loc), name(n) {}
681
682
  std::string get_name() const { return name; }
682
683
  Value do_evaluate(const std::shared_ptr<Context> & context) const override {
683
684
  if (!context->contains(name)) {
@@ -1200,9 +1201,9 @@ public:
1200
1201
 
1201
1202
  class SliceExpr : public Expression {
1202
1203
  public:
1203
- std::shared_ptr<Expression> start, end;
1204
- SliceExpr(const Location & loc, std::shared_ptr<Expression> && s, std::shared_ptr<Expression> && e)
1205
- : Expression(loc), start(std::move(s)), end(std::move(e)) {}
1204
+ std::shared_ptr<Expression> start, end, step;
1205
+ SliceExpr(const Location & loc, std::shared_ptr<Expression> && s, std::shared_ptr<Expression> && e, std::shared_ptr<Expression> && st = nullptr)
1206
+ : Expression(loc), start(std::move(s)), end(std::move(e)), step(std::move(st)) {}
1206
1207
  Value do_evaluate(const std::shared_ptr<Context> &) const override {
1207
1208
  throw std::runtime_error("SliceExpr not implemented");
1208
1209
  }
@@ -1219,18 +1220,35 @@ public:
1219
1220
  if (!index) throw std::runtime_error("SubscriptExpr.index is null");
1220
1221
  auto target_value = base->evaluate(context);
1221
1222
  if (auto slice = dynamic_cast<SliceExpr*>(index.get())) {
1222
- auto start = slice->start ? slice->start->evaluate(context).get<int64_t>() : 0;
1223
- auto end = slice->end ? slice->end->evaluate(context).get<int64_t>() : (int64_t) target_value.size();
1223
+ auto len = target_value.size();
1224
+ auto wrap = [len](int64_t i) -> int64_t {
1225
+ if (i < 0) {
1226
+ return i + len;
1227
+ }
1228
+ return i;
1229
+ };
1230
+ int64_t step = slice->step ? slice->step->evaluate(context).get<int64_t>() : 1;
1231
+ if (!step) {
1232
+ throw std::runtime_error("slice step cannot be zero");
1233
+ }
1234
+ int64_t start = slice->start ? wrap(slice->start->evaluate(context).get<int64_t>()) : (step < 0 ? len - 1 : 0);
1235
+ int64_t end = slice->end ? wrap(slice->end->evaluate(context).get<int64_t>()) : (step < 0 ? -1 : len);
1224
1236
  if (target_value.is_string()) {
1225
1237
  std::string s = target_value.get<std::string>();
1226
- if (start < 0) start = s.size() + start;
1227
- if (end < 0) end = s.size() + end;
1228
- return s.substr(start, end - start);
1238
+
1239
+ std::string result;
1240
+ if (start < end && step == 1) {
1241
+ result = s.substr(start, end - start);
1242
+ } else {
1243
+ for (int64_t i = start; step > 0 ? i < end : i > end; i += step) {
1244
+ result += s[i];
1245
+ }
1246
+ }
1247
+ return result;
1248
+
1229
1249
  } else if (target_value.is_array()) {
1230
- if (start < 0) start = target_value.size() + start;
1231
- if (end < 0) end = target_value.size() + end;
1232
1250
  auto result = Value::array();
1233
- for (auto i = start; i < end; ++i) {
1251
+ for (int64_t i = start; step > 0 ? i < end : i > end; i += step) {
1234
1252
  result.push_back(target_value.at(i));
1235
1253
  }
1236
1254
  return result;
@@ -1305,6 +1323,8 @@ public:
1305
1323
  if (name == "iterable") return l.is_iterable();
1306
1324
  if (name == "sequence") return l.is_array();
1307
1325
  if (name == "defined") return !l.is_null();
1326
+ if (name == "true") return l.to_bool();
1327
+ if (name == "false") return !l.to_bool();
1308
1328
  throw std::runtime_error("Unknown type for 'is' operator: " + name);
1309
1329
  };
1310
1330
  auto value = eval();
@@ -1520,6 +1540,10 @@ public:
1520
1540
  vargs.expectArgs("endswith method", {1, 1}, {0, 0});
1521
1541
  auto suffix = vargs.args[0].get<std::string>();
1522
1542
  return suffix.length() <= str.length() && std::equal(suffix.rbegin(), suffix.rend(), str.rbegin());
1543
+ } else if (method->get_name() == "startswith") {
1544
+ vargs.expectArgs("startswith method", {1, 1}, {0, 0});
1545
+ auto prefix = vargs.args[0].get<std::string>();
1546
+ return prefix.length() <= str.length() && std::equal(prefix.begin(), prefix.end(), str.begin());
1523
1547
  } else if (method->get_name() == "title") {
1524
1548
  vargs.expectArgs("title method", {0, 0}, {0, 0});
1525
1549
  auto res = str;
@@ -2082,28 +2106,37 @@ private:
2082
2106
 
2083
2107
  while (it != end && consumeSpaces() && peekSymbols({ "[", "." })) {
2084
2108
  if (!consumeToken("[").empty()) {
2085
- std::shared_ptr<Expression> index;
2109
+ std::shared_ptr<Expression> index;
2110
+ auto slice_loc = get_location();
2111
+ std::shared_ptr<Expression> start, end, step;
2112
+ bool has_first_colon = false, has_second_colon = false;
2113
+
2114
+ if (!peekSymbols({ ":" })) {
2115
+ start = parseExpression();
2116
+ }
2117
+
2118
+ if (!consumeToken(":").empty()) {
2119
+ has_first_colon = true;
2120
+ if (!peekSymbols({ ":", "]" })) {
2121
+ end = parseExpression();
2122
+ }
2086
2123
  if (!consumeToken(":").empty()) {
2087
- auto slice_end = parseExpression();
2088
- index = std::make_shared<SliceExpr>(slice_end->location, nullptr, std::move(slice_end));
2089
- } else {
2090
- auto slice_start = parseExpression();
2091
- if (!consumeToken(":").empty()) {
2092
- consumeSpaces();
2093
- if (peekSymbols({ "]" })) {
2094
- index = std::make_shared<SliceExpr>(slice_start->location, std::move(slice_start), nullptr);
2095
- } else {
2096
- auto slice_end = parseExpression();
2097
- index = std::make_shared<SliceExpr>(slice_start->location, std::move(slice_start), std::move(slice_end));
2098
- }
2099
- } else {
2100
- index = std::move(slice_start);
2124
+ has_second_colon = true;
2125
+ if (!peekSymbols({ "]" })) {
2126
+ step = parseExpression();
2101
2127
  }
2102
2128
  }
2103
- if (!index) throw std::runtime_error("Empty index in subscript");
2104
- if (consumeToken("]").empty()) throw std::runtime_error("Expected closing bracket in subscript");
2129
+ }
2130
+
2131
+ if ((has_first_colon || has_second_colon) && (start || end || step)) {
2132
+ index = std::make_shared<SliceExpr>(slice_loc, std::move(start), std::move(end), std::move(step));
2133
+ } else {
2134
+ index = std::move(start);
2135
+ }
2136
+ if (!index) throw std::runtime_error("Empty index in subscript");
2137
+ if (consumeToken("]").empty()) throw std::runtime_error("Expected closing bracket in subscript");
2105
2138
 
2106
- value = std::make_shared<SubscriptExpr>(value->location, std::move(value), std::move(index));
2139
+ value = std::make_shared<SubscriptExpr>(value->location, std::move(value), std::move(index));
2107
2140
  } else if (!consumeToken(".").empty()) {
2108
2141
  auto identifier = parseIdentifier();
2109
2142
  if (!identifier) throw std::runtime_error("Expected identifier in subscript");
@@ -0,0 +1,204 @@
1
+ #include "regex-partial.h"
2
+ #include "common.h"
3
+ #include <functional>
4
+ #include <optional>
5
+
6
+ common_regex::common_regex(const std::string & pattern) :
7
+ pattern(pattern),
8
+ rx(pattern),
9
+ rx_reversed_partial(regex_to_reversed_partial_regex(pattern)) {}
10
+
11
+ common_regex_match common_regex::search(const std::string & input, size_t pos, bool as_match) const {
12
+ std::smatch match;
13
+ if (pos > input.size()) {
14
+ throw std::runtime_error("Position out of bounds");
15
+ }
16
+ auto start = input.begin() + pos;
17
+ auto found = as_match
18
+ ? std::regex_match(start, input.end(), match, rx)
19
+ : std::regex_search(start, input.end(), match, rx);
20
+ if (found) {
21
+ common_regex_match res;
22
+ res.type = COMMON_REGEX_MATCH_TYPE_FULL;
23
+ for (size_t i = 0; i < match.size(); ++i) {
24
+ auto begin = pos + match.position(i);
25
+ res.groups.emplace_back(begin, begin + match.length(i));
26
+ }
27
+ return res;
28
+ }
29
+ std::match_results<std::string::const_reverse_iterator> srmatch;
30
+ if (std::regex_match(input.rbegin(), input.rend() - pos, srmatch, rx_reversed_partial)) {
31
+ auto group = srmatch[1].str();
32
+ if (group.length() != 0) {
33
+ auto it = srmatch[1].second.base();
34
+ // auto position = static_cast<size_t>(std::distance(input.begin(), it));
35
+ if ((!as_match) || it == input.begin()) {
36
+ common_regex_match res;
37
+ res.type = COMMON_REGEX_MATCH_TYPE_PARTIAL;
38
+ const size_t begin = std::distance(input.begin(), it);
39
+ const size_t end = input.size();
40
+ if (begin == std::string::npos || end == std::string::npos || begin > end) {
41
+ throw std::runtime_error("Invalid range");
42
+ }
43
+ res.groups.push_back({begin, end});
44
+ return res;
45
+ }
46
+ }
47
+ }
48
+ return {};
49
+ }
50
+
51
+ /*
52
+ Transforms a regex pattern to a partial match pattern that operates on a reversed input string to find partial final matches of the original pattern.
53
+
54
+ Ideally we'd like to use boost::match_partial (https://beta.boost.org/doc/libs/1_59_0/libs/regex/doc/html/boost_regex/partial_matches.html)
55
+ to see if a string ends with a partial regex match, but but it's not in std::regex yet.
56
+ Instead, we'll the regex into a partial match regex operating as a full match on the reverse iterators of the input.
57
+
58
+ - /abcd/ -> (dcba|cba|ba|a).* -> ((?:(?:(?:(?:d)?c)?b)?a).*
59
+ - /a|b/ -> (a|b).*
60
+ - /a*?/ -> error, could match ""
61
+ - /a*b/ -> ((?:b)?a*+).* (final repetitions become eager)
62
+ - /.*?ab/ -> ((?:b)?a).* (merge .*)
63
+ - /a.*?b/ -> ((?:b)?.*?a).* (keep reluctant matches)
64
+ - /a(bc)d/ -> ((?:(?:d)?(?:(?:c)?b))?a).*
65
+ - /a(bc|de)/ -> ((?:(?:(?:e)?d)?|(?:(?:c)?b)?)?a).*
66
+ - /ab{2,4}c/ -> abbb?b?c -> ((?:(?:(?:(?:(?:c)?b)?b)?b?)?b?)?a).*
67
+
68
+ The regex will match a reversed string fully, and the end of the first (And only) capturing group will indicate the reversed start of the original partial pattern
69
+ (i.e. just where the final .* starts in the inverted pattern; all other groups are turned into non-capturing groups, and reluctant quantifiers are ignored)
70
+ */
71
+ std::string regex_to_reversed_partial_regex(const std::string & pattern) {
72
+ auto it = pattern.begin();
73
+ const auto end = pattern.end();
74
+
75
+ std::function<std::string()> process = [&]() {
76
+ std::vector<std::vector<std::string>> alternatives(1);
77
+ std::vector<std::string> * sequence = &alternatives.back();
78
+
79
+ while (it != end) {
80
+ if (*it == '[') {
81
+ auto start = it;
82
+ ++it;
83
+ while (it != end) {
84
+ if ((*it == '\\') && (++it != end)) {
85
+ ++it;
86
+ } else if ((it != end) && (*it == ']')) {
87
+ break;
88
+ } else {
89
+ ++it;
90
+ }
91
+ }
92
+ if (it == end) {
93
+ throw std::runtime_error("Unmatched '[' in pattern");
94
+ }
95
+ ++it;
96
+ sequence->push_back(std::string(start, it));
97
+ } else if (*it == '*' || *it == '?' || *it == '+') {
98
+ if (sequence->empty()) {
99
+ throw std::runtime_error("Quantifier without preceding element");
100
+ }
101
+ sequence->back() += *it;
102
+ auto is_star = *it == '*';
103
+ ++it;
104
+ if (is_star) {
105
+ if (*it == '?') {
106
+ ++it;
107
+ }
108
+ }
109
+ } else if (*it == '{') {
110
+ if (sequence->empty()) {
111
+ throw std::runtime_error("Repetition without preceding element");
112
+ }
113
+ ++it;
114
+ auto start = it;
115
+ while (it != end && *it != '}') {
116
+ ++it;
117
+ }
118
+ if (it == end) {
119
+ throw std::runtime_error("Unmatched '{' in pattern");
120
+ }
121
+ auto parts = string_split(std::string(start, it), ",");
122
+ ++it;
123
+ if (parts.size() > 2) {
124
+ throw std::runtime_error("Invalid repetition range in pattern");
125
+ }
126
+
127
+ auto parseOptInt = [&](const std::string & s, const std::optional<int> & def = std::nullopt) -> std::optional<int> {
128
+ if (s.empty()) {
129
+ return def;
130
+ }
131
+ return std::stoi(s);
132
+ };
133
+ auto min = parseOptInt(parts[0], 0);
134
+ auto max = parts.size() == 1 ? min : parseOptInt(parts[1]);
135
+ if (min && max && *max < *min) {
136
+ throw std::runtime_error("Invalid repetition range in pattern");
137
+ }
138
+ // Brutal but... let's repeat at least min times, then ? for the delta between min & max (or * for unbounded)
139
+ auto part = sequence->back();
140
+ sequence->pop_back();
141
+ for (int i = 0; i < *min; i++) {
142
+ sequence->push_back(part);
143
+ }
144
+ if (max) {
145
+ for (int i = *min; i < *max; i++) {
146
+ sequence->push_back(part + "?");
147
+ }
148
+ } else {
149
+ sequence->push_back(part + "*");
150
+ }
151
+ } else if (*it == '(') {
152
+ ++it;
153
+ if (it != end && *it == '?' && (it + 1 != end) && *(it + 1) == ':') {
154
+ it += 2;
155
+ }
156
+ auto sub = process();
157
+ if (*it != ')') {
158
+ throw std::runtime_error("Unmatched '(' in pattern");
159
+ }
160
+ ++it;
161
+ auto & part = sequence->emplace_back("(?:");
162
+ part += sub;
163
+ part += ")";
164
+ } else if (*it == ')') {
165
+ break;
166
+ } else if (*it == '|') {
167
+ ++it;
168
+ alternatives.emplace_back();
169
+ sequence = &alternatives.back();
170
+ } else if (*it == '\\' && (++it != end)) {
171
+ auto str = std::string("\\") + *it;
172
+ sequence->push_back(str);
173
+ ++it;
174
+ } else if (it != end) {
175
+ sequence->push_back(std::string(1, *it));
176
+ ++it;
177
+ }
178
+ }
179
+
180
+ // /abcd/ -> (dcba|cba|ba|a).* -> ((?:(?:(?:d)?c)?b)?a).*
181
+ // if n(=4) parts, opening n-1(=3) non-capturing groups after the 1 capturing group
182
+ // We'll do the outermost capturing group and final .* in the enclosing function.
183
+ std::vector<std::string> res_alts;
184
+ for (const auto & parts : alternatives) {
185
+ auto & res = res_alts.emplace_back();
186
+ for (size_t i = 0; i < parts.size() - 1; i++) {
187
+ res += "(?:";
188
+ }
189
+ for (auto it = parts.rbegin(); it != parts.rend(); ++it) {
190
+ res += *it;
191
+ if (it != parts.rend() - 1) {
192
+ res += ")?";
193
+ }
194
+ }
195
+ }
196
+ return string_join(res_alts, "|");
197
+ };
198
+ auto res = process();
199
+ if (it != end) {
200
+ throw std::runtime_error("Unmatched '(' in pattern");
201
+ }
202
+
203
+ return "(" + res + ")[\\s\\S]*";
204
+ }
@@ -0,0 +1,56 @@
1
+ #pragma once
2
+
3
+ #include <regex>
4
+ #include <string>
5
+
6
+ enum common_regex_match_type {
7
+ COMMON_REGEX_MATCH_TYPE_NONE,
8
+ COMMON_REGEX_MATCH_TYPE_PARTIAL,
9
+ COMMON_REGEX_MATCH_TYPE_FULL,
10
+ };
11
+
12
+ struct common_string_range {
13
+ size_t begin;
14
+ size_t end;
15
+ common_string_range(size_t begin, size_t end) : begin(begin), end(end) {
16
+ if (begin > end) {
17
+ throw std::runtime_error("Invalid range");
18
+ }
19
+ }
20
+ // prevent default ctor
21
+ common_string_range() = delete;
22
+ bool empty() const {
23
+ return begin == end;
24
+ }
25
+ bool operator==(const common_string_range & other) const {
26
+ return begin == other.begin && end == other.end;
27
+ }
28
+ };
29
+
30
+ struct common_regex_match {
31
+ common_regex_match_type type = COMMON_REGEX_MATCH_TYPE_NONE;
32
+ std::vector<common_string_range> groups;
33
+
34
+ bool operator==(const common_regex_match & other) const {
35
+ return type == other.type && groups == other.groups;
36
+ }
37
+ bool operator!=(const common_regex_match & other) const {
38
+ return !(*this == other);
39
+ }
40
+ };
41
+
42
+ class common_regex {
43
+ std::string pattern;
44
+ std::regex rx;
45
+ std::regex rx_reversed_partial;
46
+
47
+ public:
48
+ explicit common_regex(const std::string & pattern);
49
+
50
+ common_regex_match search(const std::string & input, size_t pos, bool as_match = false) const;
51
+
52
+ const std::string & str() const { return pattern; }
53
+ };
54
+
55
+ // For testing only (pretty print of failures).
56
+ std::string regex_to_reversed_partial_regex(const std::string & pattern);
@@ -1,6 +1,7 @@
1
1
  #include "sampling.h"
2
2
 
3
3
  #include "common.h"
4
+ #include "log.h"
4
5
 
5
6
  #include <cmath>
6
7
  #include <unordered_map>
@@ -229,51 +230,48 @@ struct common_sampler * common_sampler_init(const struct llama_model * model, co
229
230
  params.logit_bias.data()));
230
231
 
231
232
  if (params.mirostat == 0) {
232
- if (params.top_n_sigma >= 0) {
233
- llama_sampler_chain_add(result->chain, llama_sampler_init_top_k (params.top_k));
234
- llama_sampler_chain_add(result->chain, llama_sampler_init_temp (params.temp));
235
- llama_sampler_chain_add(result->chain, llama_sampler_init_top_n_sigma (params.top_n_sigma));
236
- } else {
237
- for (const auto & cnstr : params.samplers) {
238
- switch (cnstr) {
239
- case COMMON_SAMPLER_TYPE_DRY:
240
- {
241
- std::vector<const char *> c_breakers;
242
- c_breakers.reserve(params.dry_sequence_breakers.size());
243
- for (const auto & str : params.dry_sequence_breakers) {
244
- c_breakers.push_back(str.c_str());
245
- }
246
-
247
- llama_sampler_chain_add(result->chain, llama_sampler_init_dry (vocab, llama_model_n_ctx_train(model), params.dry_multiplier, params.dry_base, params.dry_allowed_length, params.dry_penalty_last_n, c_breakers.data(), c_breakers.size()));
233
+ for (const auto & cnstr : params.samplers) {
234
+ switch (cnstr) {
235
+ case COMMON_SAMPLER_TYPE_DRY:
236
+ {
237
+ std::vector<const char *> c_breakers;
238
+ c_breakers.reserve(params.dry_sequence_breakers.size());
239
+ for (const auto & str : params.dry_sequence_breakers) {
240
+ c_breakers.push_back(str.c_str());
248
241
  }
249
- break;
250
- case COMMON_SAMPLER_TYPE_TOP_K:
251
- llama_sampler_chain_add(result->chain, llama_sampler_init_top_k (params.top_k));
252
- break;
253
- case COMMON_SAMPLER_TYPE_TOP_P:
254
- llama_sampler_chain_add(result->chain, llama_sampler_init_top_p (params.top_p, params.min_keep));
255
- break;
256
- case COMMON_SAMPLER_TYPE_MIN_P:
257
- llama_sampler_chain_add(result->chain, llama_sampler_init_min_p (params.min_p, params.min_keep));
258
- break;
259
- case COMMON_SAMPLER_TYPE_XTC:
260
- llama_sampler_chain_add(result->chain, llama_sampler_init_xtc (params.xtc_probability, params.xtc_threshold, params.min_keep, params.seed));
261
- break;
262
- case COMMON_SAMPLER_TYPE_TYPICAL_P:
263
- llama_sampler_chain_add(result->chain, llama_sampler_init_typical (params.typ_p, params.min_keep));
264
- break;
265
- case COMMON_SAMPLER_TYPE_TEMPERATURE:
266
- llama_sampler_chain_add(result->chain, llama_sampler_init_temp_ext (params.temp, params.dynatemp_range, params.dynatemp_exponent));
267
- break;
268
- case COMMON_SAMPLER_TYPE_INFILL:
269
- llama_sampler_chain_add(result->chain, llama_sampler_init_infill (vocab));
270
- break;
271
- case COMMON_SAMPLER_TYPE_PENALTIES:
272
- llama_sampler_chain_add(result->chain, llama_sampler_init_penalties(params.penalty_last_n, params.penalty_repeat, params.penalty_freq, params.penalty_present));
273
- break;
274
- default:
275
- GGML_ASSERT(false && "unknown sampler type");
276
- }
242
+
243
+ llama_sampler_chain_add(result->chain, llama_sampler_init_dry (vocab, llama_model_n_ctx_train(model), params.dry_multiplier, params.dry_base, params.dry_allowed_length, params.dry_penalty_last_n, c_breakers.data(), c_breakers.size()));
244
+ }
245
+ break;
246
+ case COMMON_SAMPLER_TYPE_TOP_K:
247
+ llama_sampler_chain_add(result->chain, llama_sampler_init_top_k (params.top_k));
248
+ break;
249
+ case COMMON_SAMPLER_TYPE_TOP_P:
250
+ llama_sampler_chain_add(result->chain, llama_sampler_init_top_p (params.top_p, params.min_keep));
251
+ break;
252
+ case COMMON_SAMPLER_TYPE_TOP_N_SIGMA:
253
+ llama_sampler_chain_add(result->chain, llama_sampler_init_top_n_sigma (params.top_n_sigma));
254
+ break;
255
+ case COMMON_SAMPLER_TYPE_MIN_P:
256
+ llama_sampler_chain_add(result->chain, llama_sampler_init_min_p (params.min_p, params.min_keep));
257
+ break;
258
+ case COMMON_SAMPLER_TYPE_XTC:
259
+ llama_sampler_chain_add(result->chain, llama_sampler_init_xtc (params.xtc_probability, params.xtc_threshold, params.min_keep, params.seed));
260
+ break;
261
+ case COMMON_SAMPLER_TYPE_TYPICAL_P:
262
+ llama_sampler_chain_add(result->chain, llama_sampler_init_typical (params.typ_p, params.min_keep));
263
+ break;
264
+ case COMMON_SAMPLER_TYPE_TEMPERATURE:
265
+ llama_sampler_chain_add(result->chain, llama_sampler_init_temp_ext (params.temp, params.dynatemp_range, params.dynatemp_exponent));
266
+ break;
267
+ case COMMON_SAMPLER_TYPE_INFILL:
268
+ llama_sampler_chain_add(result->chain, llama_sampler_init_infill (vocab));
269
+ break;
270
+ case COMMON_SAMPLER_TYPE_PENALTIES:
271
+ llama_sampler_chain_add(result->chain, llama_sampler_init_penalties (params.penalty_last_n, params.penalty_repeat, params.penalty_freq, params.penalty_present));
272
+ break;
273
+ default:
274
+ GGML_ASSERT(false && "unknown sampler type");
277
275
  }
278
276
  }
279
277
  llama_sampler_chain_add(result->chain, llama_sampler_init_dist(params.seed));
@@ -475,6 +473,7 @@ char common_sampler_type_to_chr(enum common_sampler_type cnstr) {
475
473
  case COMMON_SAMPLER_TYPE_TOP_K: return 'k';
476
474
  case COMMON_SAMPLER_TYPE_TYPICAL_P: return 'y';
477
475
  case COMMON_SAMPLER_TYPE_TOP_P: return 'p';
476
+ case COMMON_SAMPLER_TYPE_TOP_N_SIGMA: return 's';
478
477
  case COMMON_SAMPLER_TYPE_MIN_P: return 'm';
479
478
  case COMMON_SAMPLER_TYPE_TEMPERATURE: return 't';
480
479
  case COMMON_SAMPLER_TYPE_XTC: return 'x';
@@ -490,6 +489,7 @@ std::string common_sampler_type_to_str(enum common_sampler_type cnstr) {
490
489
  case COMMON_SAMPLER_TYPE_TOP_K: return "top_k";
491
490
  case COMMON_SAMPLER_TYPE_TYPICAL_P: return "typ_p";
492
491
  case COMMON_SAMPLER_TYPE_TOP_P: return "top_p";
492
+ case COMMON_SAMPLER_TYPE_TOP_N_SIGMA: return "top_n_sigma";
493
493
  case COMMON_SAMPLER_TYPE_MIN_P: return "min_p";
494
494
  case COMMON_SAMPLER_TYPE_TEMPERATURE: return "temperature";
495
495
  case COMMON_SAMPLER_TYPE_XTC: return "xtc";
@@ -504,6 +504,7 @@ std::vector<common_sampler_type> common_sampler_types_from_names(const std::vect
504
504
  { "dry", COMMON_SAMPLER_TYPE_DRY },
505
505
  { "top_k", COMMON_SAMPLER_TYPE_TOP_K },
506
506
  { "top_p", COMMON_SAMPLER_TYPE_TOP_P },
507
+ { "top_n_sigma", COMMON_SAMPLER_TYPE_TOP_N_SIGMA },
507
508
  { "typ_p", COMMON_SAMPLER_TYPE_TYPICAL_P },
508
509
  { "min_p", COMMON_SAMPLER_TYPE_MIN_P },
509
510
  { "temperature", COMMON_SAMPLER_TYPE_TEMPERATURE },
@@ -517,6 +518,7 @@ std::vector<common_sampler_type> common_sampler_types_from_names(const std::vect
517
518
  std::unordered_map<std::string, common_sampler_type> sampler_alt_name_map {
518
519
  { "top-k", COMMON_SAMPLER_TYPE_TOP_K },
519
520
  { "top-p", COMMON_SAMPLER_TYPE_TOP_P },
521
+ { "top-n-sigma", COMMON_SAMPLER_TYPE_TOP_N_SIGMA },
520
522
  { "nucleus", COMMON_SAMPLER_TYPE_TOP_P },
521
523
  { "typical-p", COMMON_SAMPLER_TYPE_TYPICAL_P },
522
524
  { "typical", COMMON_SAMPLER_TYPE_TYPICAL_P },
@@ -533,14 +535,16 @@ std::vector<common_sampler_type> common_sampler_types_from_names(const std::vect
533
535
  auto sampler = sampler_canonical_name_map.find(name);
534
536
  if (sampler != sampler_canonical_name_map.end()) {
535
537
  samplers.push_back(sampler->second);
536
- } else {
537
- if (allow_alt_names) {
538
- sampler = sampler_alt_name_map.find(name);
539
- if (sampler != sampler_alt_name_map.end()) {
540
- samplers.push_back(sampler->second);
541
- }
538
+ continue;
539
+ }
540
+ if (allow_alt_names) {
541
+ sampler = sampler_alt_name_map.find(name);
542
+ if (sampler != sampler_alt_name_map.end()) {
543
+ samplers.push_back(sampler->second);
544
+ continue;
542
545
  }
543
546
  }
547
+ LOG_WRN("%s: unable to match sampler by name '%s'\n", __func__, name.c_str());
544
548
  }
545
549
 
546
550
  return samplers;
@@ -552,6 +556,7 @@ std::vector<common_sampler_type> common_sampler_types_from_chars(const std::stri
552
556
  { common_sampler_type_to_chr(COMMON_SAMPLER_TYPE_TOP_K), COMMON_SAMPLER_TYPE_TOP_K },
553
557
  { common_sampler_type_to_chr(COMMON_SAMPLER_TYPE_TYPICAL_P), COMMON_SAMPLER_TYPE_TYPICAL_P },
554
558
  { common_sampler_type_to_chr(COMMON_SAMPLER_TYPE_TOP_P), COMMON_SAMPLER_TYPE_TOP_P },
559
+ { common_sampler_type_to_chr(COMMON_SAMPLER_TYPE_TOP_N_SIGMA), COMMON_SAMPLER_TYPE_TOP_N_SIGMA },
555
560
  { common_sampler_type_to_chr(COMMON_SAMPLER_TYPE_MIN_P), COMMON_SAMPLER_TYPE_MIN_P },
556
561
  { common_sampler_type_to_chr(COMMON_SAMPLER_TYPE_TEMPERATURE), COMMON_SAMPLER_TYPE_TEMPERATURE },
557
562
  { common_sampler_type_to_chr(COMMON_SAMPLER_TYPE_XTC), COMMON_SAMPLER_TYPE_XTC },
@@ -566,6 +571,8 @@ std::vector<common_sampler_type> common_sampler_types_from_chars(const std::stri
566
571
  const auto sampler = sampler_name_map.find(c);
567
572
  if (sampler != sampler_name_map.end()) {
568
573
  samplers.push_back(sampler->second);
574
+ } else {
575
+ LOG_WRN("%s: unable to match sampler by char '%c'\n", __func__, c);
569
576
  }
570
577
  }
571
578