usearch 2.19.4 → 2.19.6
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.
- package/README.md +1 -1
- package/c/lib.cpp +8 -2
- package/c/usearch.h +1 -0
- package/cpp/bench.cpp +1 -1
- package/include/usearch/index.hpp +44 -1
- package/javascript/lib.cpp +1 -1
- package/package.json +1 -1
- package/prebuilds/darwin-arm64+x64/usearch.node +0 -0
- package/prebuilds/linux-arm64/usearch.node +0 -0
- package/prebuilds/linux-x64/usearch.node +0 -0
package/README.md
CHANGED
package/c/lib.cpp
CHANGED
|
@@ -59,6 +59,7 @@ scalar_kind_t scalar_kind_to_cpp(usearch_scalar_kind_t kind) {
|
|
|
59
59
|
case usearch_scalar_f32_k: return scalar_kind_t::f32_k;
|
|
60
60
|
case usearch_scalar_f64_k: return scalar_kind_t::f64_k;
|
|
61
61
|
case usearch_scalar_f16_k: return scalar_kind_t::f16_k;
|
|
62
|
+
case usearch_scalar_bf16_k: return scalar_kind_t::bf16_k;
|
|
62
63
|
case usearch_scalar_i8_k: return scalar_kind_t::i8_k;
|
|
63
64
|
case usearch_scalar_b1_k: return scalar_kind_t::b1x8_k;
|
|
64
65
|
default: return scalar_kind_t::unknown_k;
|
|
@@ -70,6 +71,7 @@ usearch_scalar_kind_t scalar_kind_to_c(scalar_kind_t kind) {
|
|
|
70
71
|
case scalar_kind_t::f32_k: return usearch_scalar_f32_k;
|
|
71
72
|
case scalar_kind_t::f64_k: return usearch_scalar_f64_k;
|
|
72
73
|
case scalar_kind_t::f16_k: return usearch_scalar_f16_k;
|
|
74
|
+
case scalar_kind_t::bf16_k: return usearch_scalar_bf16_k;
|
|
73
75
|
case scalar_kind_t::i8_k: return usearch_scalar_i8_k;
|
|
74
76
|
case scalar_kind_t::b1x8_k: return usearch_scalar_b1_k;
|
|
75
77
|
default: return usearch_scalar_unknown_k;
|
|
@@ -81,6 +83,7 @@ add_result_t add_(index_dense_t* index, usearch_key_t key, void const* vector, s
|
|
|
81
83
|
case scalar_kind_t::f32_k: return index->add(key, (f32_t const*)vector);
|
|
82
84
|
case scalar_kind_t::f64_k: return index->add(key, (f64_t const*)vector);
|
|
83
85
|
case scalar_kind_t::f16_k: return index->add(key, (f16_t const*)vector);
|
|
86
|
+
case scalar_kind_t::bf16_k: return index->add(key, (bf16_t const*)vector);
|
|
84
87
|
case scalar_kind_t::i8_k: return index->add(key, (i8_t const*)vector);
|
|
85
88
|
case scalar_kind_t::b1x8_k: return index->add(key, (b1x8_t const*)vector);
|
|
86
89
|
default: return add_result_t{}.failed("Unknown scalar kind!");
|
|
@@ -92,6 +95,7 @@ std::size_t get_(index_dense_t* index, usearch_key_t key, size_t count, void* ve
|
|
|
92
95
|
case scalar_kind_t::f32_k: return index->get(key, (f32_t*)vector, count);
|
|
93
96
|
case scalar_kind_t::f64_k: return index->get(key, (f64_t*)vector, count);
|
|
94
97
|
case scalar_kind_t::f16_k: return index->get(key, (f16_t*)vector, count);
|
|
98
|
+
case scalar_kind_t::bf16_k: return index->get(key, (bf16_t*)vector, count);
|
|
95
99
|
case scalar_kind_t::i8_k: return index->get(key, (i8_t*)vector, count);
|
|
96
100
|
case scalar_kind_t::b1x8_k: return index->get(key, (b1x8_t*)vector, count);
|
|
97
101
|
default: return search_result_t(*index).failed("Unknown scalar kind!");
|
|
@@ -108,6 +112,8 @@ search_result_t search_(index_dense_t* index, void const* vector, scalar_kind_t
|
|
|
108
112
|
return index->filtered_search((f64_t const*)vector, n, std::forward<predicate_at>(predicate));
|
|
109
113
|
case scalar_kind_t::f16_k:
|
|
110
114
|
return index->filtered_search((f16_t const*)vector, n, std::forward<predicate_at>(predicate));
|
|
115
|
+
case scalar_kind_t::bf16_k:
|
|
116
|
+
return index->filtered_search((bf16_t const*)vector, n, std::forward<predicate_at>(predicate));
|
|
111
117
|
case scalar_kind_t::i8_k:
|
|
112
118
|
return index->filtered_search((i8_t const*)vector, n, std::forward<predicate_at>(predicate));
|
|
113
119
|
case scalar_kind_t::b1x8_k:
|
|
@@ -401,7 +407,7 @@ USEARCH_EXPORT size_t usearch_search(
|
|
|
401
407
|
return 0;
|
|
402
408
|
}
|
|
403
409
|
|
|
404
|
-
return result.dump_to(found_keys, found_distances);
|
|
410
|
+
return result.dump_to(found_keys, found_distances, results_limit);
|
|
405
411
|
}
|
|
406
412
|
|
|
407
413
|
USEARCH_EXPORT size_t usearch_filtered_search( //
|
|
@@ -419,7 +425,7 @@ USEARCH_EXPORT size_t usearch_filtered_search( /
|
|
|
419
425
|
return 0;
|
|
420
426
|
}
|
|
421
427
|
|
|
422
|
-
return result.dump_to(found_keys, found_distances);
|
|
428
|
+
return result.dump_to(found_keys, found_distances, results_limit);
|
|
423
429
|
}
|
|
424
430
|
|
|
425
431
|
USEARCH_EXPORT size_t usearch_get( //
|
package/c/usearch.h
CHANGED
package/cpp/bench.cpp
CHANGED
|
@@ -327,7 +327,7 @@ void search_many( //
|
|
|
327
327
|
config.thread = omp_get_thread_num();
|
|
328
328
|
#endif
|
|
329
329
|
span_gt<scalar_at const> vector{vectors + dims * i, dims};
|
|
330
|
-
index.search(vector, wanted, config.thread).dump_to(ids + wanted * i, distances + wanted * i);
|
|
330
|
+
index.search(vector, wanted, config.thread).dump_to(ids + wanted * i, distances + wanted * i, wanted);
|
|
331
331
|
printer.progress++;
|
|
332
332
|
if (config.thread == 0)
|
|
333
333
|
printer.refresh();
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
#define USEARCH_VERSION_MAJOR 2
|
|
11
11
|
#define USEARCH_VERSION_MINOR 19
|
|
12
|
-
#define USEARCH_VERSION_PATCH
|
|
12
|
+
#define USEARCH_VERSION_PATCH 6
|
|
13
13
|
|
|
14
14
|
// Inferring C++ version
|
|
15
15
|
// https://stackoverflow.com/a/61552074
|
|
@@ -2695,6 +2695,49 @@ class index_gt {
|
|
|
2695
2695
|
}
|
|
2696
2696
|
return count;
|
|
2697
2697
|
}
|
|
2698
|
+
|
|
2699
|
+
/**
|
|
2700
|
+
* @brief Extracts the search results into a user-provided buffer.
|
|
2701
|
+
* @return The number of results stored in the buffer.
|
|
2702
|
+
* @param[in] keys The buffer to store the keys of the search results.
|
|
2703
|
+
* @param[in] distances The buffer to store the distances to the search results.
|
|
2704
|
+
* @param[in] capacity The maximum number of results that can be stored in the buffers.
|
|
2705
|
+
*/
|
|
2706
|
+
inline std::size_t dump_to(vector_key_t* keys, distance_t* distances, std::size_t capacity) const noexcept {
|
|
2707
|
+
std::size_t i = 0;
|
|
2708
|
+
std::size_t initialized_count = (std::min)(count, capacity);
|
|
2709
|
+
for (; i != initialized_count; ++i) {
|
|
2710
|
+
match_t result = operator[](i);
|
|
2711
|
+
keys[i] = result.member.key;
|
|
2712
|
+
distances[i] = result.distance;
|
|
2713
|
+
}
|
|
2714
|
+
for (; i != capacity; ++i) {
|
|
2715
|
+
keys[i] = vector_key_t{};
|
|
2716
|
+
distances[i] = std::numeric_limits<distance_t>::has_signaling_NaN
|
|
2717
|
+
? std::numeric_limits<distance_t>::signaling_NaN()
|
|
2718
|
+
: std::numeric_limits<distance_t>::max();
|
|
2719
|
+
}
|
|
2720
|
+
return initialized_count;
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
/**
|
|
2724
|
+
* @brief Extracts the search results into a user-provided buffer.
|
|
2725
|
+
* @return The number of results stored in the buffer.
|
|
2726
|
+
* @param[in] keys The buffer to store the keys of the search results.
|
|
2727
|
+
* @param[in] capacity The maximum number of results that can be stored in the buffers.
|
|
2728
|
+
*/
|
|
2729
|
+
inline std::size_t dump_to(vector_key_t* keys, std::size_t capacity) const noexcept {
|
|
2730
|
+
std::size_t i = 0;
|
|
2731
|
+
std::size_t initialized_count = (std::min)(this->count, capacity);
|
|
2732
|
+
for (; i != initialized_count; ++i) {
|
|
2733
|
+
match_t result = operator[](i);
|
|
2734
|
+
keys[i] = result.member.key;
|
|
2735
|
+
}
|
|
2736
|
+
for (; i != capacity; ++i)
|
|
2737
|
+
keys[i] = vector_key_t{};
|
|
2738
|
+
|
|
2739
|
+
return initialized_count;
|
|
2740
|
+
}
|
|
2698
2741
|
};
|
|
2699
2742
|
|
|
2700
2743
|
struct cluster_result_t {
|
package/javascript/lib.cpp
CHANGED
|
@@ -279,7 +279,7 @@ Napi::Value CompiledIndex::Search(Napi::CallbackInfo const& ctx) {
|
|
|
279
279
|
} else {
|
|
280
280
|
auto matches = matches_data + task_idx * wanted;
|
|
281
281
|
auto distances = distances_data + task_idx * wanted;
|
|
282
|
-
counts_data[task_idx] = result.dump_to(matches, distances);
|
|
282
|
+
counts_data[task_idx] = result.dump_to(matches, distances, wanted);
|
|
283
283
|
}
|
|
284
284
|
});
|
|
285
285
|
if (failed) {
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|