usearch 2.10.3 → 2.10.5
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/binding.gyp +101 -0
- package/c/CMakeLists.txt +27 -0
- package/c/README.md +34 -0
- package/c/lib.cpp +362 -0
- package/c/test.c +382 -0
- package/c/usearch.h +356 -0
- package/cmake/clipp.cmake +7 -0
- package/cmake/config.cmake.in +15 -0
- package/cmake/emscripten.cmake +8 -0
- package/cmake/jemalloc.cmake +62 -0
- package/cmake/pkg-config.pc.in +4 -0
- package/cmake/usearchConfigVersion.cmake.in +20 -0
- package/cpp/CMakeLists.txt +14 -0
- package/cpp/README.md +161 -0
- package/cpp/bench.cpp +616 -0
- package/cpp/test.cpp +324 -0
- package/fp16/CMakeLists.txt +176 -0
- package/fp16/LICENSE +11 -0
- package/fp16/README.md +20 -0
- package/fp16/bench/alt-element.cc +89 -0
- package/fp16/bench/from-alt-array.cc +175 -0
- package/fp16/bench/from-ieee-array.cc +399 -0
- package/fp16/bench/ieee-element.cc +272 -0
- package/fp16/bench/to-alt-array.cc +91 -0
- package/fp16/bench/to-ieee-array.cc +303 -0
- package/fp16/cmake/DownloadGoogleBenchmark.cmake +15 -0
- package/fp16/cmake/DownloadGoogleTest.cmake +15 -0
- package/fp16/cmake/DownloadPSimd.cmake +15 -0
- package/fp16/configure.py +65 -0
- package/fp16/confu.yaml +8 -0
- package/fp16/include/fp16/__init__.py +0 -0
- package/fp16/include/fp16/avx.py +50 -0
- package/fp16/include/fp16/avx2.py +53 -0
- package/fp16/include/fp16/bitcasts.h +92 -0
- package/fp16/include/fp16/fp16.h +451 -0
- package/fp16/include/fp16/psimd.h +131 -0
- package/fp16/include/fp16.h +11 -0
- package/fp16/jni/Android.mk +6 -0
- package/fp16/jni/Application.mk +4 -0
- package/fp16/test/alt-from-fp32-value.cc +498 -0
- package/fp16/test/alt-to-fp32-bits.cc +263 -0
- package/fp16/test/alt-to-fp32-psimd.cc +145 -0
- package/fp16/test/alt-to-fp32-value.cc +348 -0
- package/fp16/test/alt-to-fp32x2-psimd.cc +245 -0
- package/fp16/test/bitcasts.cc +56 -0
- package/fp16/test/ieee-from-fp32-value.cc +523 -0
- package/fp16/test/ieee-to-fp32-bits.cc +333 -0
- package/fp16/test/ieee-to-fp32-psimd.cc +312 -0
- package/fp16/test/ieee-to-fp32-value.cc +420 -0
- package/fp16/test/ieee-to-fp32x2-psimd.cc +541 -0
- package/fp16/test/peachpy/alt-xmm-to-fp32-xmm-avx.cc +96 -0
- package/fp16/test/peachpy/alt-xmm-to-fp32-ymm-avx2.cc +96 -0
- package/fp16/test/peachpy/stubs.py +38 -0
- package/fp16/test/tables.cc +530 -0
- package/fp16/test/tables.h +13 -0
- package/fp16/third-party/THHalf.h +92 -0
- package/fp16/third-party/eigen-half.h +170 -0
- package/fp16/third-party/float16-compressor.h +80 -0
- package/fp16/third-party/half.hpp +2916 -0
- package/fp16/third-party/npy-halffloat.h +328 -0
- package/include/usearch/index.hpp +3838 -0
- package/include/usearch/index_dense.hpp +2004 -0
- package/include/usearch/index_plugins.hpp +2255 -0
- package/javascript/dist-package-cjs.json +3 -0
- package/javascript/dist-package-esm.json +3 -0
- package/javascript/lib.cpp +350 -0
- package/javascript/node-gyp-build.d.ts +1 -0
- package/javascript/tsconfig-base.json +25 -0
- package/javascript/tsconfig-cjs.json +8 -0
- package/javascript/tsconfig-esm.json +8 -0
- package/javascript/usearch.test.js +84 -0
- package/javascript/usearch.ts +640 -0
- package/package.json +10 -3
- 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/prebuilds/win32-ia32/usearch.node +0 -0
- package/prebuilds/win32-x64/usearch.node +0 -0
- package/simsimd/.releaserc +87 -0
- package/simsimd/CONTRIBUTING.md +114 -0
- package/simsimd/Cargo.lock +709 -0
- package/simsimd/Cargo.toml +44 -0
- package/simsimd/LICENSE +201 -0
- package/simsimd/README.md +708 -0
- package/simsimd/binding.gyp +36 -0
- package/simsimd/build.rs +51 -0
- package/simsimd/c/lib.c +110 -0
- package/simsimd/include/simsimd/binary.h +258 -0
- package/simsimd/include/simsimd/dot.h +1237 -0
- package/simsimd/include/simsimd/geospatial.h +37 -0
- package/simsimd/include/simsimd/probability.h +563 -0
- package/simsimd/include/simsimd/simsimd.h +1129 -0
- package/simsimd/include/simsimd/spatial.h +1019 -0
- package/simsimd/include/simsimd/types.h +309 -0
- package/simsimd/javascript/bench.js +127 -0
- package/simsimd/javascript/dist-package-cjs.json +3 -0
- package/simsimd/javascript/dist-package-esm.json +3 -0
- package/simsimd/javascript/fallback.ts +203 -0
- package/simsimd/javascript/lib.c +107 -0
- package/simsimd/javascript/node-gyp-build.d.ts +1 -0
- package/simsimd/javascript/simsimd.ts +135 -0
- package/simsimd/javascript/test.mjs +179 -0
- package/simsimd/javascript/tsconfig-base.json +37 -0
- package/simsimd/javascript/tsconfig-cjs.json +8 -0
- package/simsimd/javascript/tsconfig-esm.json +8 -0
- package/simsimd/package-lock.json +1709 -0
- package/simsimd/package.json +61 -0
- package/simsimd/rust/benches/cosine.rs +27 -0
- package/simsimd/rust/benches/native.rs +30 -0
- package/simsimd/rust/benches/sqeuclidean.rs +27 -0
- package/simsimd/rust/lib.rs +778 -0
package/cpp/test.cpp
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @brief A trivial test.
|
|
3
|
+
*/
|
|
4
|
+
#include <algorithm> // `std::shuffle`
|
|
5
|
+
#include <cassert> // `assert`
|
|
6
|
+
#include <random> // `std::default_random_engine`
|
|
7
|
+
#include <stdexcept>
|
|
8
|
+
#include <unordered_map>
|
|
9
|
+
#include <vector> // for std::vector
|
|
10
|
+
|
|
11
|
+
#include <usearch/index.hpp>
|
|
12
|
+
#include <usearch/index_dense.hpp>
|
|
13
|
+
#include <usearch/index_plugins.hpp>
|
|
14
|
+
|
|
15
|
+
using namespace unum::usearch;
|
|
16
|
+
using namespace unum;
|
|
17
|
+
|
|
18
|
+
void expect(bool must_be_true) {
|
|
19
|
+
if (!must_be_true)
|
|
20
|
+
throw std::runtime_error("Failed!");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
template <bool punned_ak, typename index_at, typename scalar_at, typename... extra_args_at>
|
|
24
|
+
void test_cosine(index_at& index, std::vector<std::vector<scalar_at>> const& vectors, extra_args_at&&... args) {
|
|
25
|
+
|
|
26
|
+
using scalar_t = scalar_at;
|
|
27
|
+
using index_t = index_at;
|
|
28
|
+
using vector_key_t = typename index_t::vector_key_t;
|
|
29
|
+
using distance_t = typename index_t::distance_t;
|
|
30
|
+
|
|
31
|
+
// Generate some keys starting from end,
|
|
32
|
+
// for three vectors from the dataset
|
|
33
|
+
vector_key_t const key_max = default_free_value<vector_key_t>() - 1;
|
|
34
|
+
vector_key_t const key_first = key_max - 0;
|
|
35
|
+
vector_key_t const key_second = key_max - 1;
|
|
36
|
+
vector_key_t const key_third = key_max - 2;
|
|
37
|
+
scalar_t const* vector_first = vectors[0].data();
|
|
38
|
+
scalar_t const* vector_second = vectors[1].data();
|
|
39
|
+
scalar_t const* vector_third = vectors[2].data();
|
|
40
|
+
std::size_t dimensions = vectors[0].size();
|
|
41
|
+
|
|
42
|
+
// Try checking the empty state
|
|
43
|
+
if constexpr (punned_ak) {
|
|
44
|
+
expect(!index.contains(key_first));
|
|
45
|
+
expect(!index.get(key_first, (f32_t*)nullptr, 1));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Add data
|
|
49
|
+
index.reserve(10);
|
|
50
|
+
index.add(key_first, vector_first, args...);
|
|
51
|
+
|
|
52
|
+
// Default approximate search
|
|
53
|
+
vector_key_t matched_keys[10] = {0};
|
|
54
|
+
distance_t matched_distances[10] = {0};
|
|
55
|
+
std::size_t matched_count = index.search(vector_first, 5, args...).dump_to(matched_keys, matched_distances);
|
|
56
|
+
|
|
57
|
+
expect(matched_count == 1);
|
|
58
|
+
expect(matched_keys[0] == key_first);
|
|
59
|
+
expect(std::abs(matched_distances[0]) < 0.01);
|
|
60
|
+
|
|
61
|
+
// Add more entries
|
|
62
|
+
index.add(key_second, vector_second, args...);
|
|
63
|
+
index.add(key_third, vector_third, args...);
|
|
64
|
+
expect(index.size() == 3);
|
|
65
|
+
|
|
66
|
+
// Perform exact search
|
|
67
|
+
matched_count = index.search(vector_first, 5, args...).dump_to(matched_keys, matched_distances);
|
|
68
|
+
|
|
69
|
+
// Validate scans
|
|
70
|
+
std::size_t count = 0;
|
|
71
|
+
for (auto member : index) {
|
|
72
|
+
vector_key_t id = member.key;
|
|
73
|
+
expect(id <= key_first && id >= key_third);
|
|
74
|
+
count++;
|
|
75
|
+
}
|
|
76
|
+
expect((count == 3));
|
|
77
|
+
expect((index.stats(0).nodes == 3));
|
|
78
|
+
|
|
79
|
+
// Check if clustering endpoint compiles
|
|
80
|
+
index.cluster(vector_first, 0, args...);
|
|
81
|
+
|
|
82
|
+
// Try removals and replacements
|
|
83
|
+
if constexpr (punned_ak) {
|
|
84
|
+
using labeling_result_t = typename index_t::labeling_result_t;
|
|
85
|
+
labeling_result_t result = index.remove(key_third);
|
|
86
|
+
expect(bool(result));
|
|
87
|
+
expect(index.size() == 2);
|
|
88
|
+
index.add(key_third, vector_third, args...);
|
|
89
|
+
expect(index.size() == 3);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Search again over reconstructed index
|
|
93
|
+
index.save("tmp.usearch");
|
|
94
|
+
index.load("tmp.usearch");
|
|
95
|
+
matched_count = index.search(vector_first, 5, args...).dump_to(matched_keys, matched_distances);
|
|
96
|
+
expect(matched_count == 3);
|
|
97
|
+
expect(matched_keys[0] == key_first);
|
|
98
|
+
expect(std::abs(matched_distances[0]) < 0.01);
|
|
99
|
+
|
|
100
|
+
if constexpr (punned_ak) {
|
|
101
|
+
std::vector<scalar_t> vec_recovered_from_load(dimensions);
|
|
102
|
+
index.get(key_second, vec_recovered_from_load.data());
|
|
103
|
+
expect(std::equal(vector_second, vector_second + dimensions, vec_recovered_from_load.data()));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Try batch requests
|
|
107
|
+
executor_default_t executor;
|
|
108
|
+
index.reserve({vectors.size(), executor.size()});
|
|
109
|
+
executor.fixed(vectors.size() - 3, [&](std::size_t thread, std::size_t task) {
|
|
110
|
+
if constexpr (punned_ak) {
|
|
111
|
+
index.add(key_max - task - 3, vectors[task + 3].data(), args...);
|
|
112
|
+
} else {
|
|
113
|
+
index_update_config_t config;
|
|
114
|
+
config.thread = thread;
|
|
115
|
+
index.add(key_max - task - 3, vectors[task + 3].data(), args..., config);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Check for duplicates
|
|
120
|
+
if constexpr (punned_ak) {
|
|
121
|
+
index.reserve({vectors.size() + 1u, executor.size()});
|
|
122
|
+
auto result = index.add(key_first, vector_first, args...);
|
|
123
|
+
expect(!!result == index.multi());
|
|
124
|
+
result.error.release();
|
|
125
|
+
|
|
126
|
+
std::size_t first_key_count = index.count(key_first);
|
|
127
|
+
expect(first_key_count == (1ul + index.multi()));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Search again over mapped index
|
|
131
|
+
// file_head_result_t head = index_dense_metadata_from_path("tmp.usearch");
|
|
132
|
+
// expect(head.size == 3);
|
|
133
|
+
index.view("tmp.usearch");
|
|
134
|
+
matched_count = index.search(vector_first, 5, args...).dump_to(matched_keys, matched_distances);
|
|
135
|
+
expect(matched_count == 3);
|
|
136
|
+
expect(matched_keys[0] == key_first);
|
|
137
|
+
expect(std::abs(matched_distances[0]) < 0.01);
|
|
138
|
+
|
|
139
|
+
if constexpr (punned_ak) {
|
|
140
|
+
std::vector<scalar_t> vec_recovered_from_view(dimensions);
|
|
141
|
+
index.get(key_second, vec_recovered_from_view.data());
|
|
142
|
+
expect(std::equal(vector_second, vector_second + dimensions, vec_recovered_from_view.data()));
|
|
143
|
+
|
|
144
|
+
auto compaction_result = index.compact();
|
|
145
|
+
expect(bool(compaction_result));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
expect(index.memory_usage() > 0);
|
|
149
|
+
expect(index.stats().max_edges > 0);
|
|
150
|
+
|
|
151
|
+
// Check metadata
|
|
152
|
+
if constexpr (punned_ak) {
|
|
153
|
+
index_dense_metadata_result_t meta = index_dense_metadata_from_path("tmp.usearch");
|
|
154
|
+
expect(bool(meta));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
template <typename scalar_at, typename key_at, typename slot_at> //
|
|
159
|
+
void test_cosine(std::size_t collection_size, std::size_t dimensions) {
|
|
160
|
+
|
|
161
|
+
using scalar_t = scalar_at;
|
|
162
|
+
using vector_key_t = key_at;
|
|
163
|
+
using slot_t = slot_at;
|
|
164
|
+
|
|
165
|
+
using index_typed_t = index_gt<float, vector_key_t, slot_t>;
|
|
166
|
+
using member_cref_t = typename index_typed_t::member_cref_t;
|
|
167
|
+
using member_citerator_t = typename index_typed_t::member_citerator_t;
|
|
168
|
+
|
|
169
|
+
using vector_of_vectors_t = std::vector<std::vector<scalar_at>>;
|
|
170
|
+
vector_of_vectors_t vector_of_vectors(collection_size);
|
|
171
|
+
for (auto& vector : vector_of_vectors) {
|
|
172
|
+
vector.resize(dimensions);
|
|
173
|
+
std::generate(vector.begin(), vector.end(), [=] { return float(std::rand()) / float(INT_MAX); });
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
struct metric_t {
|
|
177
|
+
vector_of_vectors_t const* vector_of_vectors_ptr = nullptr;
|
|
178
|
+
std::size_t dimensions = 0;
|
|
179
|
+
|
|
180
|
+
scalar_t const* row(std::size_t i) const noexcept { return (*vector_of_vectors_ptr)[i].data(); }
|
|
181
|
+
|
|
182
|
+
float operator()(member_cref_t const& a, member_cref_t const& b) const {
|
|
183
|
+
return metric_cos_gt<scalar_t>{}(row(get_slot(b)), row(get_slot(a)), dimensions);
|
|
184
|
+
}
|
|
185
|
+
float operator()(scalar_t const* some_vector, member_cref_t const& member) const {
|
|
186
|
+
return metric_cos_gt<scalar_t>{}(some_vector, row(get_slot(member)), dimensions);
|
|
187
|
+
}
|
|
188
|
+
float operator()(member_citerator_t const& a, member_citerator_t const& b) const {
|
|
189
|
+
return metric_cos_gt<scalar_t>{}(row(get_slot(b)), row(get_slot(a)), dimensions);
|
|
190
|
+
}
|
|
191
|
+
float operator()(scalar_t const* some_vector, member_citerator_t const& member) const {
|
|
192
|
+
return metric_cos_gt<scalar_t>{}(some_vector, row(get_slot(member)), dimensions);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
// Template:
|
|
197
|
+
for (std::size_t connectivity : {3, 13, 50}) {
|
|
198
|
+
std::printf("- templates with connectivity %zu \n", connectivity);
|
|
199
|
+
metric_t metric{&vector_of_vectors, dimensions};
|
|
200
|
+
index_config_t config(connectivity);
|
|
201
|
+
index_typed_t index_typed(config);
|
|
202
|
+
test_cosine<false>(index_typed, vector_of_vectors, metric);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Type-punned:
|
|
206
|
+
for (bool multi : {false, true}) {
|
|
207
|
+
for (std::size_t connectivity : {3, 13, 50}) {
|
|
208
|
+
std::printf("- punned with connectivity %zu \n", connectivity);
|
|
209
|
+
using index_t = index_dense_gt<vector_key_t, slot_t>;
|
|
210
|
+
metric_punned_t metric(dimensions, metric_kind_t::cos_k, scalar_kind<scalar_at>());
|
|
211
|
+
index_dense_config_t config(connectivity);
|
|
212
|
+
config.multi = multi;
|
|
213
|
+
index_t index;
|
|
214
|
+
{
|
|
215
|
+
index_t index_tmp1 = index_t::make(metric, config);
|
|
216
|
+
// move construction
|
|
217
|
+
index_t index_tmp2 = std::move(index_tmp1);
|
|
218
|
+
// move assignment
|
|
219
|
+
index = std::move(index_tmp2);
|
|
220
|
+
}
|
|
221
|
+
test_cosine<true>(index, vector_of_vectors);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
template <typename key_at, typename slot_at> void test_tanimoto(std::size_t dimensions, std::size_t connectivity) {
|
|
227
|
+
|
|
228
|
+
using vector_key_t = key_at;
|
|
229
|
+
using slot_t = slot_at;
|
|
230
|
+
|
|
231
|
+
using index_punned_t = index_dense_gt<vector_key_t, slot_t>;
|
|
232
|
+
std::size_t words = divide_round_up<CHAR_BIT>(dimensions);
|
|
233
|
+
metric_punned_t metric(words, metric_kind_t::tanimoto_k, scalar_kind_t::b1x8_k);
|
|
234
|
+
index_config_t config(connectivity);
|
|
235
|
+
index_punned_t index = index_punned_t::make(metric, config);
|
|
236
|
+
|
|
237
|
+
executor_default_t executor;
|
|
238
|
+
std::size_t batch_size = 1000;
|
|
239
|
+
std::vector<b1x8_t> scalars(batch_size * index.scalar_words());
|
|
240
|
+
std::generate(scalars.begin(), scalars.end(), [] { return static_cast<b1x8_t>(std::rand()); });
|
|
241
|
+
|
|
242
|
+
index.reserve({batch_size + index.size(), executor.size()});
|
|
243
|
+
executor.fixed(batch_size, [&](std::size_t thread, std::size_t task) {
|
|
244
|
+
index.add(task + 25000, scalars.data() + index.scalar_words() * task, thread);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
void test_exact_search(std::size_t dataset_count, std::size_t queries_count, std::size_t wanted_count) {
|
|
249
|
+
std::size_t dimensions = 10;
|
|
250
|
+
metric_punned_t metric(dimensions, metric_kind_t::cos_k);
|
|
251
|
+
|
|
252
|
+
std::random_device rd;
|
|
253
|
+
std::mt19937 gen(rd());
|
|
254
|
+
std::uniform_real_distribution<> dis(0.0, 1.0);
|
|
255
|
+
std::vector<float> dataset(dataset_count * dimensions);
|
|
256
|
+
std::generate(dataset.begin(), dataset.end(), [&] { return dis(gen); });
|
|
257
|
+
|
|
258
|
+
exact_search_t search;
|
|
259
|
+
auto results = search( //
|
|
260
|
+
(byte_t const*)dataset.data(), dataset_count, dimensions * sizeof(float), //
|
|
261
|
+
(byte_t const*)dataset.data(), queries_count, dimensions * sizeof(float), //
|
|
262
|
+
wanted_count, metric);
|
|
263
|
+
|
|
264
|
+
for (std::size_t i = 0; i < results.size(); ++i)
|
|
265
|
+
assert(results.at(i)[0].offset == i); // Validate the top match
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
template <typename index_at> void test_sets(index_at&& index) {
|
|
269
|
+
|
|
270
|
+
using index_t = typename std::remove_reference<index_at>::type;
|
|
271
|
+
using scalar_t = typename index_t::scalar_t;
|
|
272
|
+
using view_t = span_gt<scalar_t const>;
|
|
273
|
+
|
|
274
|
+
scalar_t vec0[] = {10, 20};
|
|
275
|
+
scalar_t vec1[] = {10, 15, 20};
|
|
276
|
+
scalar_t vec2[] = {10, 20, 30, 35};
|
|
277
|
+
|
|
278
|
+
index.reserve(10);
|
|
279
|
+
index.add(42, view_t{&vec0[0], 2ul});
|
|
280
|
+
index.add(43, view_t{&vec1[0], 3ul});
|
|
281
|
+
index.add(44, view_t{&vec2[0], 4ul});
|
|
282
|
+
|
|
283
|
+
expect(index.size() == 3);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
template <typename index_at> void test_sets_moved(index_config_t const& config) {
|
|
287
|
+
{
|
|
288
|
+
index_at index{config};
|
|
289
|
+
test_sets(index);
|
|
290
|
+
}
|
|
291
|
+
{
|
|
292
|
+
index_at index{config};
|
|
293
|
+
index.reserve(1);
|
|
294
|
+
test_sets(index_at(std::move(index)));
|
|
295
|
+
}
|
|
296
|
+
{
|
|
297
|
+
index_at index{config};
|
|
298
|
+
index.reserve(1);
|
|
299
|
+
index_at index_moved = std::move(index);
|
|
300
|
+
test_sets(index_moved);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
int main(int, char**) {
|
|
305
|
+
|
|
306
|
+
for (std::size_t dataset_count : {10, 100})
|
|
307
|
+
for (std::size_t queries_count : {1, 10})
|
|
308
|
+
for (std::size_t wanted_count : {1, 5})
|
|
309
|
+
test_exact_search(dataset_count, queries_count, wanted_count);
|
|
310
|
+
|
|
311
|
+
for (std::size_t collection_size : {10, 500})
|
|
312
|
+
for (std::size_t dimensions : {97, 256}) {
|
|
313
|
+
std::printf("Indexing %zu vectors with cos: <float, std::int64_t, std::uint32_t> \n", collection_size);
|
|
314
|
+
test_cosine<float, std::int64_t, std::uint32_t>(collection_size, dimensions);
|
|
315
|
+
std::printf("Indexing %zu vectors with cos: <float, std::int64_t, uint40_t> \n", collection_size);
|
|
316
|
+
test_cosine<float, std::int64_t, uint40_t>(collection_size, dimensions);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
for (std::size_t connectivity : {3, 13, 50})
|
|
320
|
+
for (std::size_t dimensions : {97, 256})
|
|
321
|
+
test_tanimoto<std::int64_t, std::uint32_t>(dimensions, connectivity);
|
|
322
|
+
|
|
323
|
+
return 0;
|
|
324
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR)
|
|
2
|
+
|
|
3
|
+
INCLUDE(GNUInstallDirs)
|
|
4
|
+
|
|
5
|
+
# ---[ Project
|
|
6
|
+
PROJECT(FP16 C CXX)
|
|
7
|
+
|
|
8
|
+
# ---[ Options.
|
|
9
|
+
OPTION(FP16_BUILD_TESTS "Build FP16 unit tests" ON)
|
|
10
|
+
OPTION(FP16_BUILD_BENCHMARKS "Build FP16 micro-benchmarks" ON)
|
|
11
|
+
|
|
12
|
+
# ---[ CMake options
|
|
13
|
+
IF(FP16_BUILD_TESTS)
|
|
14
|
+
ENABLE_TESTING()
|
|
15
|
+
ENDIF()
|
|
16
|
+
|
|
17
|
+
MACRO(FP16_TARGET_ENABLE_CXX11 target)
|
|
18
|
+
IF(${CMAKE_VERSION} VERSION_LESS "3.1")
|
|
19
|
+
IF(NOT MSVC)
|
|
20
|
+
TARGET_COMPILE_OPTIONS(${target} PRIVATE -std=c++11)
|
|
21
|
+
ENDIF()
|
|
22
|
+
ELSE()
|
|
23
|
+
SET_TARGET_PROPERTIES(${target} PROPERTIES
|
|
24
|
+
CXX_STANDARD 11
|
|
25
|
+
CXX_STANDARD_REQUIRED YES
|
|
26
|
+
CXX_EXTENSIONS YES)
|
|
27
|
+
ENDIF()
|
|
28
|
+
ENDMACRO()
|
|
29
|
+
|
|
30
|
+
# ---[ Download deps
|
|
31
|
+
IF(NOT DEFINED PSIMD_SOURCE_DIR)
|
|
32
|
+
MESSAGE(STATUS "Downloading PSimd to ${CMAKE_BINARY_DIR}/psimd-source (define PSIMD_SOURCE_DIR to avoid it)")
|
|
33
|
+
CONFIGURE_FILE(cmake/DownloadPSimd.cmake "${CMAKE_BINARY_DIR}/psimd-download/CMakeLists.txt")
|
|
34
|
+
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
|
|
35
|
+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/psimd-download")
|
|
36
|
+
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" --build .
|
|
37
|
+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/psimd-download")
|
|
38
|
+
SET(PSIMD_SOURCE_DIR "${CMAKE_BINARY_DIR}/psimd-source" CACHE STRING "PSimd source directory")
|
|
39
|
+
ENDIF()
|
|
40
|
+
|
|
41
|
+
IF(FP16_BUILD_TESTS AND NOT DEFINED GOOGLETEST_SOURCE_DIR)
|
|
42
|
+
MESSAGE(STATUS "Downloading Google Test to ${CMAKE_BINARY_DIR}/googletest-source (define GOOGLETEST_SOURCE_DIR to avoid it)")
|
|
43
|
+
CONFIGURE_FILE(cmake/DownloadGoogleTest.cmake "${CMAKE_BINARY_DIR}/googletest-download/CMakeLists.txt")
|
|
44
|
+
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
|
|
45
|
+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download")
|
|
46
|
+
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" --build .
|
|
47
|
+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download")
|
|
48
|
+
SET(GOOGLETEST_SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-source" CACHE STRING "Google Test source directory")
|
|
49
|
+
ENDIF()
|
|
50
|
+
|
|
51
|
+
IF(FP16_BUILD_BENCHMARKS AND NOT DEFINED GOOGLEBENCHMARK_SOURCE_DIR)
|
|
52
|
+
MESSAGE(STATUS "Downloading Google Benchmark to ${CMAKE_BINARY_DIR}/googlebenchmark-source (define GOOGLEBENCHMARK_SOURCE_DIR to avoid it)")
|
|
53
|
+
CONFIGURE_FILE(cmake/DownloadGoogleBenchmark.cmake "${CMAKE_BINARY_DIR}/googlebenchmark-download/CMakeLists.txt")
|
|
54
|
+
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
|
|
55
|
+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googlebenchmark-download")
|
|
56
|
+
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" --build .
|
|
57
|
+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googlebenchmark-download")
|
|
58
|
+
SET(GOOGLEBENCHMARK_SOURCE_DIR "${CMAKE_BINARY_DIR}/googlebenchmark-source" CACHE STRING "Google Benchmark source directory")
|
|
59
|
+
ENDIF()
|
|
60
|
+
|
|
61
|
+
# ---[ FP16 library
|
|
62
|
+
IF(${CMAKE_VERSION} VERSION_LESS "3.0")
|
|
63
|
+
ADD_LIBRARY(fp16 STATIC
|
|
64
|
+
include/fp16.h
|
|
65
|
+
include/fp16/fp16.h
|
|
66
|
+
include/fp16/bitcasts.h
|
|
67
|
+
include/fp16/psimd.h)
|
|
68
|
+
SET_TARGET_PROPERTIES(fp16 PROPERTIES LINKER_LANGUAGE C)
|
|
69
|
+
ELSE()
|
|
70
|
+
ADD_LIBRARY(fp16 INTERFACE)
|
|
71
|
+
ENDIF()
|
|
72
|
+
TARGET_INCLUDE_DIRECTORIES(fp16 INTERFACE
|
|
73
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
74
|
+
$<INSTALL_INTERFACE:include>)
|
|
75
|
+
|
|
76
|
+
INSTALL(FILES include/fp16.h
|
|
77
|
+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
78
|
+
INSTALL(FILES
|
|
79
|
+
include/fp16/bitcasts.h
|
|
80
|
+
include/fp16/fp16.h
|
|
81
|
+
include/fp16/psimd.h
|
|
82
|
+
include/fp16/__init__.py
|
|
83
|
+
include/fp16/avx.py
|
|
84
|
+
include/fp16/avx2.py
|
|
85
|
+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/fp16)
|
|
86
|
+
|
|
87
|
+
# ---[ Configure psimd
|
|
88
|
+
IF(NOT TARGET psimd)
|
|
89
|
+
ADD_SUBDIRECTORY(
|
|
90
|
+
"${PSIMD_SOURCE_DIR}"
|
|
91
|
+
"${CMAKE_BINARY_DIR}/psimd")
|
|
92
|
+
ENDIF()
|
|
93
|
+
|
|
94
|
+
IF(FP16_BUILD_TESTS)
|
|
95
|
+
# ---[ Build google test
|
|
96
|
+
IF(NOT TARGET gtest)
|
|
97
|
+
SET(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
98
|
+
ADD_SUBDIRECTORY(
|
|
99
|
+
"${GOOGLETEST_SOURCE_DIR}"
|
|
100
|
+
"${CMAKE_BINARY_DIR}/googletest")
|
|
101
|
+
ENDIF()
|
|
102
|
+
|
|
103
|
+
# ---[ Build FP16 unit tests
|
|
104
|
+
ADD_EXECUTABLE(ieee-to-fp32-bits-test test/ieee-to-fp32-bits.cc test/tables.cc)
|
|
105
|
+
TARGET_INCLUDE_DIRECTORIES(ieee-to-fp32-bits-test PRIVATE test)
|
|
106
|
+
TARGET_LINK_LIBRARIES(ieee-to-fp32-bits-test fp16 gtest gtest_main)
|
|
107
|
+
ADD_TEST(ieee-to-fp32-bits ieee-to-fp32-bits-test)
|
|
108
|
+
|
|
109
|
+
ADD_EXECUTABLE(ieee-to-fp32-value-test test/ieee-to-fp32-value.cc test/tables.cc)
|
|
110
|
+
TARGET_INCLUDE_DIRECTORIES(ieee-to-fp32-value-test PRIVATE test)
|
|
111
|
+
TARGET_LINK_LIBRARIES(ieee-to-fp32-value-test fp16 gtest gtest_main)
|
|
112
|
+
ADD_TEST(ieee-to-fp32-value ieee-to-fp32-value-test)
|
|
113
|
+
|
|
114
|
+
ADD_EXECUTABLE(ieee-from-fp32-value-test test/ieee-from-fp32-value.cc test/tables.cc)
|
|
115
|
+
TARGET_INCLUDE_DIRECTORIES(ieee-from-fp32-value-test PRIVATE test)
|
|
116
|
+
TARGET_LINK_LIBRARIES(ieee-from-fp32-value-test fp16 gtest gtest_main)
|
|
117
|
+
ADD_TEST(ieee-from-fp32-value ieee-from-fp32-value-test)
|
|
118
|
+
|
|
119
|
+
ADD_EXECUTABLE(alt-to-fp32-bits-test test/alt-to-fp32-bits.cc test/tables.cc)
|
|
120
|
+
TARGET_INCLUDE_DIRECTORIES(alt-to-fp32-bits-test PRIVATE test)
|
|
121
|
+
TARGET_LINK_LIBRARIES(alt-to-fp32-bits-test fp16 gtest gtest_main)
|
|
122
|
+
ADD_TEST(alt-to-fp32-bits alt-to-fp32-bits-test)
|
|
123
|
+
|
|
124
|
+
ADD_EXECUTABLE(alt-to-fp32-value-test test/alt-to-fp32-value.cc test/tables.cc)
|
|
125
|
+
TARGET_INCLUDE_DIRECTORIES(alt-to-fp32-value-test PRIVATE test)
|
|
126
|
+
TARGET_LINK_LIBRARIES(alt-to-fp32-value-test fp16 gtest gtest_main)
|
|
127
|
+
ADD_TEST(alt-to-fp32-value alt-to-fp32-value-test)
|
|
128
|
+
|
|
129
|
+
ADD_EXECUTABLE(alt-from-fp32-value-test test/alt-from-fp32-value.cc test/tables.cc)
|
|
130
|
+
TARGET_INCLUDE_DIRECTORIES(alt-from-fp32-value-test PRIVATE test)
|
|
131
|
+
TARGET_LINK_LIBRARIES(alt-from-fp32-value-test fp16 gtest gtest_main)
|
|
132
|
+
ADD_TEST(alt-from-fp32-value alt-from-fp32-value-test)
|
|
133
|
+
|
|
134
|
+
ADD_EXECUTABLE(bitcasts-test test/bitcasts.cc)
|
|
135
|
+
TARGET_LINK_LIBRARIES(bitcasts-test fp16 gtest gtest_main)
|
|
136
|
+
ADD_TEST(bitcasts bitcasts-test)
|
|
137
|
+
ENDIF()
|
|
138
|
+
|
|
139
|
+
IF(FP16_BUILD_BENCHMARKS)
|
|
140
|
+
# ---[ Build google benchmark
|
|
141
|
+
IF(NOT TARGET benchmark)
|
|
142
|
+
SET(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "")
|
|
143
|
+
ADD_SUBDIRECTORY(
|
|
144
|
+
"${GOOGLEBENCHMARK_SOURCE_DIR}"
|
|
145
|
+
"${CMAKE_BINARY_DIR}/googlebenchmark")
|
|
146
|
+
ENDIF()
|
|
147
|
+
|
|
148
|
+
# ---[ Build FP16 benchmarks
|
|
149
|
+
ADD_EXECUTABLE(ieee-element-bench bench/ieee-element.cc)
|
|
150
|
+
TARGET_COMPILE_DEFINITIONS(ieee-element-bench PRIVATE FP16_COMPARATIVE_BENCHMARKS=1)
|
|
151
|
+
TARGET_INCLUDE_DIRECTORIES(ieee-element-bench PRIVATE ${PROJECT_SOURCE_DIR})
|
|
152
|
+
TARGET_LINK_LIBRARIES(ieee-element-bench fp16 psimd benchmark)
|
|
153
|
+
|
|
154
|
+
ADD_EXECUTABLE(alt-element-bench bench/alt-element.cc)
|
|
155
|
+
TARGET_LINK_LIBRARIES(alt-element-bench fp16 psimd benchmark)
|
|
156
|
+
|
|
157
|
+
ADD_EXECUTABLE(from-ieee-array-bench bench/from-ieee-array.cc)
|
|
158
|
+
FP16_TARGET_ENABLE_CXX11(from-ieee-array-bench)
|
|
159
|
+
TARGET_COMPILE_DEFINITIONS(from-ieee-array-bench PRIVATE FP16_COMPARATIVE_BENCHMARKS=1)
|
|
160
|
+
TARGET_INCLUDE_DIRECTORIES(from-ieee-array-bench PRIVATE ${PROJECT_SOURCE_DIR})
|
|
161
|
+
TARGET_LINK_LIBRARIES(from-ieee-array-bench fp16 psimd benchmark)
|
|
162
|
+
|
|
163
|
+
ADD_EXECUTABLE(from-alt-array-bench bench/from-alt-array.cc)
|
|
164
|
+
FP16_TARGET_ENABLE_CXX11(from-alt-array-bench)
|
|
165
|
+
TARGET_LINK_LIBRARIES(from-alt-array-bench fp16 psimd benchmark)
|
|
166
|
+
|
|
167
|
+
ADD_EXECUTABLE(to-ieee-array-bench bench/to-ieee-array.cc)
|
|
168
|
+
FP16_TARGET_ENABLE_CXX11(to-ieee-array-bench)
|
|
169
|
+
TARGET_COMPILE_DEFINITIONS(to-ieee-array-bench PRIVATE FP16_COMPARATIVE_BENCHMARKS=1)
|
|
170
|
+
TARGET_INCLUDE_DIRECTORIES(to-ieee-array-bench PRIVATE ${PROJECT_SOURCE_DIR})
|
|
171
|
+
TARGET_LINK_LIBRARIES(to-ieee-array-bench fp16 psimd benchmark)
|
|
172
|
+
|
|
173
|
+
ADD_EXECUTABLE(to-alt-array-bench bench/to-alt-array.cc)
|
|
174
|
+
FP16_TARGET_ENABLE_CXX11(to-alt-array-bench)
|
|
175
|
+
TARGET_LINK_LIBRARIES(to-alt-array-bench fp16 psimd benchmark)
|
|
176
|
+
ENDIF()
|
package/fp16/LICENSE
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Facebook Inc.
|
|
4
|
+
Copyright (c) 2017 Georgia Institute of Technology
|
|
5
|
+
Copyright 2019 Google LLC
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
8
|
+
|
|
9
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/fp16/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# FP16
|
|
2
|
+
Header-only library for conversion to/from half-precision floating point formats
|
|
3
|
+
|
|
4
|
+
## Features
|
|
5
|
+
|
|
6
|
+
- Supports IEEE and ARM alternative half-precision floating-point format
|
|
7
|
+
- Property converts infinities and NaNs
|
|
8
|
+
- Properly converts denormal numbers, even on systems without denormal support
|
|
9
|
+
- Header-only library, no installation or build required
|
|
10
|
+
- Compatible with C99 and C++11
|
|
11
|
+
- Fully covered with unit tests and microbenchmarks
|
|
12
|
+
|
|
13
|
+
## Acknowledgements
|
|
14
|
+
|
|
15
|
+
[](http://hpcgarage.org)
|
|
16
|
+
[](http://www.cse.gatech.edu/)
|
|
17
|
+
|
|
18
|
+
The library is developed by [Marat Dukhan](http://www.maratdukhan.com) of Georgia Tech. FP16 is a research project at [Richard Vuduc](http://vuduc.org)'s HPC Garage lab in the Georgia Institute of Technology, College of Computing, School of Computational Science and Engineering.
|
|
19
|
+
|
|
20
|
+
This material is based upon work supported by the U.S. National Science Foundation (NSF) Award Number 1339745. Any opinions, findings and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect those of NSF.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#include <benchmark/benchmark.h>
|
|
2
|
+
|
|
3
|
+
#include <fp16.h>
|
|
4
|
+
#ifndef EMSCRIPTEN
|
|
5
|
+
#include <fp16/psimd.h>
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
static inline uint16_t next_xorshift16(uint16_t x) {
|
|
9
|
+
x ^= x >> 8;
|
|
10
|
+
x ^= x << 9;
|
|
11
|
+
x ^= x >> 5;
|
|
12
|
+
return x;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static inline uint32_t next_xorshift32(uint32_t x) {
|
|
16
|
+
x ^= x >> 13;
|
|
17
|
+
x ^= x << 17;
|
|
18
|
+
x ^= x >> 5;
|
|
19
|
+
return x;
|
|
20
|
+
}
|
|
21
|
+
#ifndef EMSCRIPTEN
|
|
22
|
+
PSIMD_INTRINSIC psimd_u16 next_xorshift16_psimd(psimd_u16 x) {
|
|
23
|
+
x ^= x >> psimd_splat_u16(8);
|
|
24
|
+
x ^= x << psimd_splat_u16(9);
|
|
25
|
+
x ^= x >> psimd_splat_u16(5);
|
|
26
|
+
return x;
|
|
27
|
+
}
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
static void fp16_alt_to_fp32_bits(benchmark::State& state) {
|
|
32
|
+
uint16_t fp16 = UINT16_C(0x7C00);
|
|
33
|
+
while (state.KeepRunning()) {
|
|
34
|
+
const uint32_t fp32 = fp16_alt_to_fp32_bits(fp16);
|
|
35
|
+
|
|
36
|
+
fp16 = next_xorshift16(fp16);
|
|
37
|
+
benchmark::DoNotOptimize(fp32);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
BENCHMARK(fp16_alt_to_fp32_bits);
|
|
41
|
+
|
|
42
|
+
static void fp16_alt_to_fp32_value(benchmark::State& state) {
|
|
43
|
+
uint16_t fp16 = UINT16_C(0x7C00);
|
|
44
|
+
while (state.KeepRunning()) {
|
|
45
|
+
const float fp32 = fp16_alt_to_fp32_value(fp16);
|
|
46
|
+
|
|
47
|
+
fp16 = next_xorshift16(fp16);
|
|
48
|
+
benchmark::DoNotOptimize(fp32);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
BENCHMARK(fp16_alt_to_fp32_value);
|
|
52
|
+
|
|
53
|
+
#ifndef EMSCRIPTEN
|
|
54
|
+
static void fp16_alt_to_fp32_psimd(benchmark::State& state) {
|
|
55
|
+
psimd_u16 fp16 = (psimd_u16) { 0x7C00, 0x7C01, 0x7C02, 0x7C03 };
|
|
56
|
+
while (state.KeepRunning()) {
|
|
57
|
+
const psimd_f32 fp32 = fp16_alt_to_fp32_psimd(fp16);
|
|
58
|
+
|
|
59
|
+
fp16 = next_xorshift16_psimd(fp16);
|
|
60
|
+
benchmark::DoNotOptimize(fp32);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
BENCHMARK(fp16_alt_to_fp32_psimd);
|
|
64
|
+
|
|
65
|
+
static void fp16_alt_to_fp32x2_psimd(benchmark::State& state) {
|
|
66
|
+
psimd_u16 fp16 =
|
|
67
|
+
(psimd_u16) { 0x7C00, 0x7C01, 0x7C02, 0x7C03, 0x7C04, 0x7C05, 0x7C06, 0x7C07 };
|
|
68
|
+
while (state.KeepRunning()) {
|
|
69
|
+
const psimd_f32x2 fp32 = fp16_alt_to_fp32x2_psimd(fp16);
|
|
70
|
+
|
|
71
|
+
fp16 = next_xorshift16_psimd(fp16);
|
|
72
|
+
benchmark::DoNotOptimize(fp32);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
BENCHMARK(fp16_alt_to_fp32x2_psimd);
|
|
76
|
+
#endif
|
|
77
|
+
|
|
78
|
+
static void fp16_alt_from_fp32_value(benchmark::State& state) {
|
|
79
|
+
uint32_t fp32 = UINT32_C(0x7F800000);
|
|
80
|
+
while (state.KeepRunning()) {
|
|
81
|
+
const uint16_t fp16 = fp16_alt_from_fp32_value(fp32_from_bits(fp32));
|
|
82
|
+
|
|
83
|
+
fp32 = next_xorshift32(fp32);
|
|
84
|
+
benchmark::DoNotOptimize(fp16);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
BENCHMARK(fp16_alt_from_fp32_value);
|
|
88
|
+
|
|
89
|
+
BENCHMARK_MAIN();
|