-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Narek/external index storage #335
base: main-dev
Are you sure you want to change the base?
Changes from all commits
d416092
61db8e5
211a103
c4394ce
c71e9c6
b10c582
1bd4842
daf7ca2
2df158c
d4fb277
aac0233
8209b52
a16e11f
76325fd
c36756b
9b30845
b78f4f9
ec9369a
7e966b5
41f6039
c28751a
e2d2670
d81d58d
f1b47f3
b48a657
ee9bb58
73cf2a6
731dfa2
a130ae8
204535c
5fdee31
6dab7ab
3c11340
d303be1
0dcf791
854a11c
28c9a04
098f875
84734d6
75a3cc4
b5d0a50
e36bd1c
754d9b7
02ecba4
f26cde9
846355c
c42c2f7
f969d4e
4af55fd
1448096
b13269e
7717c29
64996a7
36f7109
21f6b76
33220d5
f37bb7a
4291071
08db9ec
338e2fe
c6ad76d
25c7ca4
6ff2c8f
a7cc87c
d74263a
69cdbdb
96d9c53
e024fca
9b979bd
6e11258
ea5cdbb
a745439
de89cef
72d68a0
87ab073
b2a3d3a
c504e18
8dccd68
cae7210
ec3ed82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,12 @@ | |
#include <cassert> // `assert` | ||
#include <random> // `std::default_random_engine` | ||
#include <stdexcept> | ||
#include <unordered_map> | ||
#include <vector> // for std::vector | ||
|
||
#include <usearch/index.hpp> | ||
#include <usearch/index_dense.hpp> | ||
#include <usearch/index_plugins.hpp> | ||
#include <usearch/std_storage.hpp> | ||
|
||
using namespace unum::usearch; | ||
using namespace unum; | ||
|
@@ -77,7 +77,7 @@ void test_cosine(index_at& index, std::vector<std::vector<scalar_at>> const& vec | |
expect((index.stats(0).nodes == 3)); | ||
|
||
// Check if clustering endpoint compiles | ||
index.cluster(vector_first, 0, args...); | ||
// index.cluster(vector_first, 0, args...); | ||
|
||
// Try removals and replacements | ||
if constexpr (punned_ak) { | ||
|
@@ -141,8 +141,8 @@ void test_cosine(index_at& index, std::vector<std::vector<scalar_at>> const& vec | |
index.get(key_second, vec_recovered_from_view.data()); | ||
expect(std::equal(vector_second, vector_second + dimensions, vec_recovered_from_view.data())); | ||
|
||
auto compaction_result = index.compact(); | ||
expect(bool(compaction_result)); | ||
// auto compaction_result = index.compact(); | ||
// expect(bool(compaction_result)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
} | ||
|
||
expect(index.memory_usage() > 0); | ||
|
@@ -155,14 +155,15 @@ void test_cosine(index_at& index, std::vector<std::vector<scalar_at>> const& vec | |
} | ||
} | ||
|
||
template <typename scalar_at, typename key_at, typename slot_at> // | ||
template <typename storage_at, typename scalar_at, typename key_at, typename slot_at> // | ||
void test_cosine(std::size_t collection_size, std::size_t dimensions) { | ||
|
||
using storage_t = storage_at; | ||
using scalar_t = scalar_at; | ||
using vector_key_t = key_at; | ||
using slot_t = slot_at; | ||
|
||
using index_typed_t = index_gt<float, vector_key_t, slot_t>; | ||
using index_typed_t = index_gt<storage_t, float, vector_key_t, slot_t>; | ||
using member_cref_t = typename index_typed_t::member_cref_t; | ||
using member_citerator_t = typename index_typed_t::member_citerator_t; | ||
|
||
|
@@ -197,15 +198,17 @@ void test_cosine(std::size_t collection_size, std::size_t dimensions) { | |
std::printf("- templates with connectivity %zu \n", connectivity); | ||
metric_t metric{&matrix, dimensions}; | ||
index_config_t config(connectivity); | ||
index_typed_t index_typed(config); | ||
storage_t storage{config}; | ||
index_typed_t index_typed_tmp(&storage, config); | ||
index_typed_t index_typed = std::move(index_typed_tmp); | ||
test_cosine<false>(index_typed, matrix, metric); | ||
} | ||
|
||
// Type-punned: | ||
for (bool multi : {false, true}) { | ||
for (std::size_t connectivity : {3, 13, 50}) { | ||
std::printf("- punned with connectivity %zu \n", connectivity); | ||
using index_t = index_dense_gt<vector_key_t, slot_t>; | ||
using index_t = index_dense_gt<vector_key_t, slot_t, storage_t>; | ||
metric_punned_t metric(dimensions, metric_kind_t::cos_k, scalar_kind<scalar_at>()); | ||
index_dense_config_t config(connectivity); | ||
config.multi = multi; | ||
|
@@ -310,9 +313,24 @@ int main(int, char**) { | |
for (std::size_t collection_size : {10, 500}) | ||
for (std::size_t dimensions : {97, 256}) { | ||
std::printf("Indexing %zu vectors with cos: <float, std::int64_t, std::uint32_t> \n", collection_size); | ||
test_cosine<float, std::int64_t, std::uint32_t>(collection_size, dimensions); | ||
std::printf("Indexing %zu vectors with cos: <float, std::int64_t, uint40_t> \n", collection_size); | ||
test_cosine<float, std::int64_t, uint40_t>(collection_size, dimensions); | ||
using key_t = std::int64_t; | ||
{ | ||
using slot_t = std::uint32_t; | ||
using storage_v2_t = storage_v2_at<key_t, slot_t>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Runs tests for the two storage provider APIs
|
||
using std_storage_t = std_storage_at<key_t, slot_t>; | ||
|
||
test_cosine<storage_v2_t, float, std::int64_t, std::uint32_t>(collection_size, dimensions); | ||
test_cosine<std_storage_t, float, std::int64_t, std::uint32_t>(collection_size, dimensions); | ||
} | ||
{ | ||
using slot_t = uint40_t; | ||
using storage_v2_t = storage_v2_at<key_t, slot_t>; | ||
using std_storage_t = std_storage_at<key_t, slot_t>; | ||
|
||
std::printf("Indexing %zu vectors with cos: <float, std::int64_t, uint40_t> \n", collection_size); | ||
test_cosine<storage_v2_t, float, key_t, slot_t>(collection_size, dimensions); | ||
test_cosine<std_storage_t, float, key_t, slot_t>(collection_size, dimensions); | ||
} | ||
} | ||
|
||
for (std::size_t connectivity : {3, 13, 50}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
storage interface has not yet been added for this endpoint, so I removed the test.
Will add it back when implemented