usearch 0.1.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.
- package/.clang-format +10 -0
- package/.github/workflows/package.json +82 -0
- package/.github/workflows/release.yml +111 -0
- package/.gitmodules +6 -0
- package/.vscode/launch.json +116 -0
- package/.vscode/settings.json +109 -0
- package/.vscode/tasks.json +35 -0
- package/CMakeLists.txt +84 -0
- package/CMakeListsInstructuons.md +109 -0
- package/README.md +69 -0
- package/VERSION +1 -0
- package/assets/unum.png +0 -0
- package/binding.gyp +28 -0
- package/build.rs +14 -0
- package/cargo.toml +15 -0
- package/cmake/clipp.cmake +8 -0
- package/cmake/jemalloc.cmake +80 -0
- package/docs/Makefile +20 -0
- package/docs/_static/custom.css +26 -0
- package/docs/_static/custom.js +7 -0
- package/docs/conf.py +48 -0
- package/docs/index.rst +10 -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/usearch.hpp +1345 -0
- package/package.json +19 -0
- package/pyproject.toml +33 -0
- package/setup.py +63 -0
- package/simsimd/.clang-format +10 -0
- package/simsimd/.vscode/launch.json +24 -0
- package/simsimd/.vscode/settings.json +73 -0
- package/simsimd/.vscode/tasks.json +17 -0
- package/simsimd/CMakeLists.txt +82 -0
- package/simsimd/LICENSE +201 -0
- package/simsimd/README.md +73 -0
- package/simsimd/bench.cxx +82 -0
- package/simsimd/include/simsimd/simsimd.h +322 -0
- package/simsimd/include/simsimd/simsimd.hpp +443 -0
- package/src/advanced.hpp +489 -0
- package/src/bench.cpp +415 -0
- package/src/bench.py +89 -0
- package/src/javascript.cpp +198 -0
- package/src/main.rs +42 -0
- package/src/python.cpp +226 -0
- package/src/rust.cpp +23 -0
- package/src/rust.h +22 -0
- package/src/test.js +17 -0
- package/src/test.py +20 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#include <gtest/gtest.h>
|
|
2
|
+
|
|
3
|
+
#include <cstdint>
|
|
4
|
+
|
|
5
|
+
#include <fp16.h>
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
extern "C" void fp16_alt_xmm_to_fp32_ymm_peachpy__avx2(const uint16_t* fp16, uint32_t* fp32);
|
|
9
|
+
const size_t vector_elements = 8;
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
TEST(FP16_ALT_XMM_TO_FP32_YMM, positive_normalized_values) {
|
|
13
|
+
const uint32_t exponentBias = 15;
|
|
14
|
+
for (int32_t e = -14; e <= 16; e++) {
|
|
15
|
+
for (uint16_t h = 0; h < 0x0400; h += vector_elements) {
|
|
16
|
+
uint16_t fp16[vector_elements];
|
|
17
|
+
for (size_t i = 0; i < vector_elements; i++) {
|
|
18
|
+
fp16[i] = h + ((e + exponentBias) << 10) + i;
|
|
19
|
+
}
|
|
20
|
+
uint32_t fp32[vector_elements];
|
|
21
|
+
fp16_alt_xmm_to_fp32_ymm_peachpy__avx2(fp16, fp32);
|
|
22
|
+
|
|
23
|
+
for (size_t i = 0; i < vector_elements; i++) {
|
|
24
|
+
EXPECT_EQ(fp16_alt_to_fp32_bits(fp16[i]), fp32[i]) <<
|
|
25
|
+
std::hex << std::uppercase << std::setfill('0') <<
|
|
26
|
+
"F16 = 0x" << std::setw(4) << fp16[i] << ", " <<
|
|
27
|
+
"F32(F16) = 0x" << std::setw(8) << fp32[i] << ", " <<
|
|
28
|
+
"F32 = 0x" << std::setw(8) << fp16_alt_to_fp32_bits(fp16[i]) <<
|
|
29
|
+
", lane " << i << "/" << vector_elements;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
TEST(FP16_ALT_XMM_TO_FP32_YMM, negative_normalized_values) {
|
|
36
|
+
const uint32_t exponentBias = 15;
|
|
37
|
+
for (int32_t e = -14; e <= 16; e++) {
|
|
38
|
+
for (uint16_t h = 0; h < 0x0400; h += vector_elements) {
|
|
39
|
+
uint16_t fp16[vector_elements];
|
|
40
|
+
for (size_t i = 0; i < vector_elements; i++) {
|
|
41
|
+
fp16[i] = 0x8000 + h + ((e + exponentBias) << 10) + i;
|
|
42
|
+
}
|
|
43
|
+
uint32_t fp32[vector_elements];
|
|
44
|
+
fp16_alt_xmm_to_fp32_ymm_peachpy__avx2(fp16, fp32);
|
|
45
|
+
|
|
46
|
+
for (size_t i = 0; i < vector_elements; i++) {
|
|
47
|
+
EXPECT_EQ(fp16_alt_to_fp32_bits(fp16[i]), fp32[i]) <<
|
|
48
|
+
std::hex << std::uppercase << std::setfill('0') <<
|
|
49
|
+
"F16 = 0x" << std::setw(4) << fp16[i] << ", " <<
|
|
50
|
+
"F32(F16) = 0x" << std::setw(8) << fp32[i] << ", " <<
|
|
51
|
+
"F32 = 0x" << std::setw(8) << fp16_alt_to_fp32_bits(fp16[i]) <<
|
|
52
|
+
", lane " << i << "/" << vector_elements;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
TEST(FP16_ALT_XMM_TO_FP32_YMM, positive_denormalized_values) {
|
|
59
|
+
for (uint16_t h = 0; h < 0x0400; h += vector_elements) {
|
|
60
|
+
uint16_t fp16[vector_elements];
|
|
61
|
+
for (size_t i = 0; i < vector_elements; i++) {
|
|
62
|
+
fp16[i] = h + i;
|
|
63
|
+
}
|
|
64
|
+
uint32_t fp32[vector_elements];
|
|
65
|
+
fp16_alt_xmm_to_fp32_ymm_peachpy__avx2(fp16, fp32);
|
|
66
|
+
|
|
67
|
+
for (size_t i = 0; i < vector_elements; i++) {
|
|
68
|
+
EXPECT_EQ(fp16_alt_to_fp32_bits(fp16[i]), fp32[i]) <<
|
|
69
|
+
std::hex << std::uppercase << std::setfill('0') <<
|
|
70
|
+
"F16 = 0x" << std::setw(4) << fp16[i] << ", " <<
|
|
71
|
+
"F32(F16) = 0x" << std::setw(8) << fp32[i] << ", " <<
|
|
72
|
+
"F32 = 0x" << std::setw(8) << fp16_alt_to_fp32_bits(fp16[i]) <<
|
|
73
|
+
", lane " << i << "/" << vector_elements;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
TEST(FP16_ALT_XMM_TO_FP32_YMM, negative_denormalized_values) {
|
|
79
|
+
for (uint16_t h = 0; h < 0x0400; h += vector_elements) {
|
|
80
|
+
uint16_t fp16[vector_elements];
|
|
81
|
+
for (size_t i = 0; i < vector_elements; i++) {
|
|
82
|
+
fp16[i] = 0x8000 + h + i;
|
|
83
|
+
}
|
|
84
|
+
uint32_t fp32[vector_elements];
|
|
85
|
+
fp16_alt_xmm_to_fp32_ymm_peachpy__avx2(fp16, fp32);
|
|
86
|
+
|
|
87
|
+
for (size_t i = 0; i < vector_elements; i++) {
|
|
88
|
+
EXPECT_EQ(fp16_alt_to_fp32_bits(fp16[i]), fp32[i]) <<
|
|
89
|
+
std::hex << std::uppercase << std::setfill('0') <<
|
|
90
|
+
"F16 = 0x" << std::setw(4) << fp16[i] << ", " <<
|
|
91
|
+
"F32(F16) = 0x" << std::setw(8) << fp32[i] << ", " <<
|
|
92
|
+
"F32 = 0x" << std::setw(8) << fp16_alt_to_fp32_bits(fp16[i]) <<
|
|
93
|
+
", lane " << i << "/" << vector_elements;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from peachpy import *
|
|
2
|
+
from peachpy.x86_64 import *
|
|
3
|
+
|
|
4
|
+
import fp16.avx, fp16.avx2
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
arg_fp16 = Argument(ptr(const_uint16_t), name="fp16")
|
|
8
|
+
arg_fp32 = Argument(ptr(uint32_t), name="fp32")
|
|
9
|
+
|
|
10
|
+
with Function("fp16_alt_xmm_to_fp32_ymm_peachpy__avx2", (arg_fp16, arg_fp32), target=uarch.default + isa.avx2):
|
|
11
|
+
|
|
12
|
+
reg_fp16 = GeneralPurposeRegister64()
|
|
13
|
+
LOAD.ARGUMENT(reg_fp16, arg_fp16)
|
|
14
|
+
|
|
15
|
+
reg_fp32 = GeneralPurposeRegister64()
|
|
16
|
+
LOAD.ARGUMENT(reg_fp32, arg_fp32)
|
|
17
|
+
|
|
18
|
+
xmm_fp16 = XMMRegister()
|
|
19
|
+
VMOVUPS(xmm_fp16, [reg_fp16])
|
|
20
|
+
ymm_fp32 = fp16.avx2.fp16_alt_xmm_to_fp32_ymm(xmm_fp16)
|
|
21
|
+
VMOVUPS([reg_fp32], ymm_fp32)
|
|
22
|
+
|
|
23
|
+
RETURN()
|
|
24
|
+
|
|
25
|
+
with Function("fp16_alt_xmm_to_fp32_xmm_peachpy__avx", (arg_fp16, arg_fp32), target=uarch.default + isa.avx):
|
|
26
|
+
|
|
27
|
+
reg_fp16 = GeneralPurposeRegister64()
|
|
28
|
+
LOAD.ARGUMENT(reg_fp16, arg_fp16)
|
|
29
|
+
|
|
30
|
+
reg_fp32 = GeneralPurposeRegister64()
|
|
31
|
+
LOAD.ARGUMENT(reg_fp32, arg_fp32)
|
|
32
|
+
|
|
33
|
+
xmm_fp16 = XMMRegister()
|
|
34
|
+
VMOVUPS(xmm_fp16, [reg_fp16])
|
|
35
|
+
xmm_fp32 = fp16.avx.fp16_alt_xmm_to_fp32_xmm(xmm_fp16)
|
|
36
|
+
VMOVUPS([reg_fp32], xmm_fp32)
|
|
37
|
+
|
|
38
|
+
RETURN()
|