usearch 2.9.2 → 2.10.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/README.md +39 -38
- package/javascript/{types → dist/cjs}/usearch.d.ts +90 -115
- package/javascript/dist/cjs/usearch.js +531 -0
- package/javascript/dist/esm/usearch.d.ts +212 -0
- package/javascript/{usearch.js → dist/esm/usearch.js} +199 -153
- package/package.json +25 -23
- 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/.clang-format +0 -10
- package/.clang-tidy +0 -60
- package/.cmake-format.py +0 -19
- package/.dockerignore +0 -93
- package/.gitattributes +0 -9
- package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -90
- package/.github/ISSUE_TEMPLATE/config.yml +0 -5
- package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -64
- package/.github/workflows/Dockerfile.libs +0 -36
- package/.github/workflows/prerelease.yml +0 -331
- package/.github/workflows/release.yml +0 -722
- package/.github/workflows/update_version.sh +0 -15
- package/.gitmodules +0 -9
- package/.releaserc +0 -90
- package/CITATION.cff +0 -11
- package/CMakeLists.txt +0 -324
- package/CODE_OF_CONDUCT.md +0 -128
- package/CONTRIBUTING.md +0 -361
- package/Cargo.toml +0 -19
- package/Dockerfile +0 -16
- package/VERSION +0 -1
- package/assets/unum.png +0 -0
- package/assets/usearch-approaches-transparent.png +0 -0
- package/assets/usearch-approaches-white.png +0 -0
- package/assets/usearch-neighbor-types.png +0 -0
- package/binding.gyp +0 -87
- package/build.gradle +0 -204
- package/build.rs +0 -18
- package/c/CMakeLists.txt +0 -25
- package/c/README.md +0 -34
- package/c/lib.cpp +0 -358
- package/c/test.c +0 -382
- package/c/usearch.h +0 -311
- package/cmake/clipp.cmake +0 -7
- package/cmake/config.cmake.in +0 -15
- package/cmake/emscripten.cmake +0 -8
- package/cmake/jemalloc.cmake +0 -62
- package/cmake/pkg-config.pc.in +0 -4
- package/cmake/usearchConfigVersion.cmake.in +0 -20
- package/conanfile.py +0 -26
- package/cpp/CMakeLists.txt +0 -14
- package/cpp/README.md +0 -161
- package/cpp/bench.cpp +0 -618
- package/cpp/test.cpp +0 -323
- package/fp16/CMakeLists.txt +0 -176
- package/fp16/LICENSE +0 -11
- package/fp16/README.md +0 -20
- package/fp16/bench/alt-element.cc +0 -89
- package/fp16/bench/from-alt-array.cc +0 -175
- package/fp16/bench/from-ieee-array.cc +0 -399
- package/fp16/bench/ieee-element.cc +0 -272
- package/fp16/bench/to-alt-array.cc +0 -91
- package/fp16/bench/to-ieee-array.cc +0 -303
- package/fp16/cmake/DownloadGoogleBenchmark.cmake +0 -15
- package/fp16/cmake/DownloadGoogleTest.cmake +0 -15
- package/fp16/cmake/DownloadPSimd.cmake +0 -15
- package/fp16/configure.py +0 -65
- package/fp16/confu.yaml +0 -8
- package/fp16/include/fp16/__init__.py +0 -0
- package/fp16/include/fp16/avx.py +0 -50
- package/fp16/include/fp16/avx2.py +0 -53
- package/fp16/include/fp16/bitcasts.h +0 -92
- package/fp16/include/fp16/fp16.h +0 -451
- package/fp16/include/fp16/psimd.h +0 -131
- package/fp16/include/fp16.h +0 -11
- package/fp16/jni/Android.mk +0 -6
- package/fp16/jni/Application.mk +0 -4
- package/fp16/test/alt-from-fp32-value.cc +0 -498
- package/fp16/test/alt-to-fp32-bits.cc +0 -263
- package/fp16/test/alt-to-fp32-psimd.cc +0 -145
- package/fp16/test/alt-to-fp32-value.cc +0 -348
- package/fp16/test/alt-to-fp32x2-psimd.cc +0 -245
- package/fp16/test/bitcasts.cc +0 -56
- package/fp16/test/ieee-from-fp32-value.cc +0 -523
- package/fp16/test/ieee-to-fp32-bits.cc +0 -333
- package/fp16/test/ieee-to-fp32-psimd.cc +0 -312
- package/fp16/test/ieee-to-fp32-value.cc +0 -420
- package/fp16/test/ieee-to-fp32x2-psimd.cc +0 -541
- package/fp16/test/peachpy/alt-xmm-to-fp32-xmm-avx.cc +0 -96
- package/fp16/test/peachpy/alt-xmm-to-fp32-ymm-avx2.cc +0 -96
- package/fp16/test/peachpy/stubs.py +0 -38
- package/fp16/test/tables.cc +0 -530
- package/fp16/test/tables.h +0 -13
- package/fp16/third-party/THHalf.h +0 -92
- package/fp16/third-party/eigen-half.h +0 -170
- package/fp16/third-party/float16-compressor.h +0 -80
- package/fp16/third-party/half.hpp +0 -2916
- package/fp16/third-party/npy-halffloat.h +0 -328
- package/include/usearch/index.hpp +0 -3836
- package/include/usearch/index_dense.hpp +0 -2004
- package/include/usearch/index_plugins.hpp +0 -2213
- package/javascript/lib.cpp +0 -341
- package/javascript/types/usearch.d.ts.map +0 -1
- package/javascript/usearch.test.js +0 -74
- package/package-ci.json +0 -10
- package/pyproject.toml +0 -51
- package/setup.py +0 -201
- package/simsimd/.releaserc +0 -86
- package/simsimd/CONTRIBUTING.md +0 -88
- package/simsimd/Cargo.lock +0 -709
- package/simsimd/Cargo.toml +0 -44
- package/simsimd/LICENSE +0 -201
- package/simsimd/README.md +0 -317
- package/simsimd/binding.gyp +0 -36
- package/simsimd/build.rs +0 -20
- package/simsimd/include/simsimd/binary.h +0 -245
- package/simsimd/include/simsimd/complex.h +0 -174
- package/simsimd/include/simsimd/probability.h +0 -548
- package/simsimd/include/simsimd/simsimd.h +0 -465
- package/simsimd/include/simsimd/spatial.h +0 -1267
- package/simsimd/include/simsimd/types.h +0 -208
- package/simsimd/javascript/bench.js +0 -127
- package/simsimd/javascript/fallback.ts +0 -193
- package/simsimd/javascript/lib.c +0 -102
- package/simsimd/javascript/node-gyp-build.d.ts +0 -1
- package/simsimd/javascript/simsimd.ts +0 -124
- package/simsimd/javascript/test.mjs +0 -153
- package/simsimd/javascript/tsconfig-base.json +0 -25
- package/simsimd/javascript/tsconfig-cjs.json +0 -8
- package/simsimd/javascript/tsconfig-esm.json +0 -8
- package/simsimd/package-lock.json +0 -1688
- package/simsimd/package.json +0 -61
- package/simsimd/rust/benches/cosine.rs +0 -27
- package/simsimd/rust/benches/native.rs +0 -30
- package/simsimd/rust/benches/sqeuclidean.rs +0 -27
- package/simsimd/rust/lib.c +0 -45
- package/simsimd/rust/lib.rs +0 -550
- package/sqlite/README.md +0 -178
- package/sqlite/lib.cpp +0 -325
- package/stringzilla/CONTRIBUTING.md +0 -446
- package/stringzilla/Cargo.lock +0 -25
- package/stringzilla/Cargo.toml +0 -26
- package/stringzilla/LICENSE +0 -201
- package/stringzilla/README.md +0 -1422
- package/stringzilla/VERSION +0 -1
- package/stringzilla/assets/cover-strinzilla.jpeg +0 -0
- package/stringzilla/assets/meme-stringzilla-v2.jpeg +0 -0
- package/stringzilla/assets/meme-stringzilla-v3.jpeg +0 -0
- package/stringzilla/binding.gyp +0 -16
- package/stringzilla/build.rs +0 -87
- package/stringzilla/c/lib.c +0 -337
- package/stringzilla/cli/README.md +0 -65
- package/stringzilla/cli/__init__.py +0 -0
- package/stringzilla/cli/split.py +0 -105
- package/stringzilla/cli/wc.py +0 -117
- package/stringzilla/include/stringzilla/experimental.h +0 -845
- package/stringzilla/include/stringzilla/module.modulemap +0 -9
- package/stringzilla/include/stringzilla/stringzilla.h +0 -5370
- package/stringzilla/include/stringzilla/stringzilla.hpp +0 -3838
- package/stringzilla/javascript/lib.c +0 -125
- package/stringzilla/javascript/stringzilla.js +0 -22
- package/stringzilla/package-ci.json +0 -10
- package/stringzilla/package.json +0 -32
- package/stringzilla/rust/lib.rs +0 -873
- package/stringzilla/swift/StringProtocol+StringZilla.swift +0 -280
- package/stringzilla/swift/Test.swift +0 -60
- package/tsconfig.json +0 -21
- package/wasmer.toml +0 -12
- package/winlibinstaller.bat +0 -42
- /package/{simsimd/javascript/dist-package-cjs.json → javascript/dist/cjs/package.json} +0 -0
- /package/{simsimd/javascript/dist-package-esm.json → javascript/dist/esm/package.json} +0 -0
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR)
|
|
2
|
-
|
|
3
|
-
PROJECT(psimd-download NONE)
|
|
4
|
-
|
|
5
|
-
INCLUDE(ExternalProject)
|
|
6
|
-
ExternalProject_Add(psimd
|
|
7
|
-
GIT_REPOSITORY https://github.com/Maratyszcza/psimd.git
|
|
8
|
-
GIT_TAG master
|
|
9
|
-
SOURCE_DIR "${CMAKE_BINARY_DIR}/psimd-source"
|
|
10
|
-
BINARY_DIR "${CMAKE_BINARY_DIR}/psimd"
|
|
11
|
-
CONFIGURE_COMMAND ""
|
|
12
|
-
BUILD_COMMAND ""
|
|
13
|
-
INSTALL_COMMAND ""
|
|
14
|
-
TEST_COMMAND ""
|
|
15
|
-
)
|
package/fp16/configure.py
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import confu
|
|
5
|
-
parser = confu.standard_parser("FP16 configuration script")
|
|
6
|
-
parser.add_argument("--compare", dest="compare", action="store_true",
|
|
7
|
-
help="Enable performance comparison with other half-precision implementations")
|
|
8
|
-
|
|
9
|
-
def main(args):
|
|
10
|
-
options = parser.parse_args(args)
|
|
11
|
-
build = confu.Build.from_options(options)
|
|
12
|
-
|
|
13
|
-
build.export_cpath("include", ["fp16.h"])
|
|
14
|
-
|
|
15
|
-
with build.options(source_dir="test", extra_include_dirs="test", deps=[build.deps.googletest, build.deps.psimd]):
|
|
16
|
-
fp16_tables = build.cxx("tables.cc")
|
|
17
|
-
build.unittest("ieee-to-fp32-bits",
|
|
18
|
-
[build.cxx("ieee-to-fp32-bits.cc"), fp16_tables])
|
|
19
|
-
build.unittest("ieee-to-fp32-value",
|
|
20
|
-
[build.cxx("ieee-to-fp32-value.cc"), fp16_tables])
|
|
21
|
-
build.unittest("ieee-from-fp32-value",
|
|
22
|
-
[build.cxx("ieee-from-fp32-value.cc"), fp16_tables])
|
|
23
|
-
|
|
24
|
-
build.unittest("alt-to-fp32-bits",
|
|
25
|
-
[build.cxx("alt-to-fp32-bits.cc"), fp16_tables])
|
|
26
|
-
build.unittest("alt-to-fp32-value",
|
|
27
|
-
[build.cxx("alt-to-fp32-value.cc"), fp16_tables])
|
|
28
|
-
build.unittest("alt-from-fp32-value",
|
|
29
|
-
[build.cxx("alt-from-fp32-value.cc"), fp16_tables])
|
|
30
|
-
|
|
31
|
-
if build.target.is_x86_64:
|
|
32
|
-
stubs = build.peachpy("peachpy/stubs.py")
|
|
33
|
-
build.unittest("alt-xmm-to-fp32-ymm-avx", [build.cxx("peachpy/alt-xmm-to-fp32-xmm-avx.cc"), stubs])
|
|
34
|
-
build.unittest("alt-xmm-to-fp32-ymm-avx2", [build.cxx("peachpy/alt-xmm-to-fp32-ymm-avx2.cc"), stubs])
|
|
35
|
-
|
|
36
|
-
if not build.target.is_emscripten:
|
|
37
|
-
build.unittest("ieee-to-fp32-psimd", build.cxx("ieee-to-fp32-psimd.cc"))
|
|
38
|
-
build.unittest("alt-to-fp32-psimd", build.cxx("alt-to-fp32-psimd.cc"))
|
|
39
|
-
|
|
40
|
-
build.unittest("ieee-to-fp32x2-psimd", build.cxx("ieee-to-fp32x2-psimd.cc"))
|
|
41
|
-
build.unittest("alt-to-fp32x2-psimd", build.cxx("alt-to-fp32x2-psimd.cc"))
|
|
42
|
-
|
|
43
|
-
build.unittest("bitcasts", build.cxx("bitcasts.cc"))
|
|
44
|
-
|
|
45
|
-
macros = ["BENCHMARK_HAS_NO_INLINE_ASSEMBLY"]
|
|
46
|
-
if options.compare:
|
|
47
|
-
macros.append("FP16_COMPARATIVE_BENCHMARKS")
|
|
48
|
-
with build.options(source_dir="bench", extra_include_dirs=".", macros=macros,
|
|
49
|
-
deps=[build.deps.googlebenchmark, build.deps.psimd]):
|
|
50
|
-
|
|
51
|
-
build.benchmark("ieee-element-bench", build.cxx("ieee-element.cc"))
|
|
52
|
-
build.benchmark("alt-element-bench", build.cxx("alt-element.cc"))
|
|
53
|
-
|
|
54
|
-
build.benchmark("from-ieee-array-bench", build.cxx("from-ieee-array.cc"))
|
|
55
|
-
build.benchmark("from-alt-array-bench", build.cxx("from-alt-array.cc"))
|
|
56
|
-
|
|
57
|
-
build.benchmark("to-ieee-array-bench", build.cxx("to-ieee-array.cc"))
|
|
58
|
-
build.benchmark("to-alt-array-bench", build.cxx("to-alt-array.cc"))
|
|
59
|
-
|
|
60
|
-
return build
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if __name__ == "__main__":
|
|
64
|
-
import sys
|
|
65
|
-
main(sys.argv[1:]).generate()
|
package/fp16/confu.yaml
DELETED
|
File without changes
|
package/fp16/include/fp16/avx.py
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
from peachpy import *
|
|
2
|
-
from peachpy.x86_64 import *
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def fp16_alt_xmm_to_fp32_xmm(xmm_half):
|
|
6
|
-
xmm_zero = XMMRegister()
|
|
7
|
-
VPXOR(xmm_zero, xmm_zero, xmm_zero)
|
|
8
|
-
|
|
9
|
-
xmm_word = XMMRegister()
|
|
10
|
-
VPUNPCKLWD(xmm_word, xmm_zero, xmm_half)
|
|
11
|
-
|
|
12
|
-
xmm_shl1_half = XMMRegister()
|
|
13
|
-
VPADDW(xmm_shl1_half, xmm_half, xmm_half)
|
|
14
|
-
|
|
15
|
-
xmm_shl1_nonsign = XMMRegister()
|
|
16
|
-
VPADDD(xmm_shl1_nonsign, xmm_word, xmm_word)
|
|
17
|
-
|
|
18
|
-
sign_mask = Constant.float32x4(-0.0)
|
|
19
|
-
|
|
20
|
-
xmm_sign = XMMRegister()
|
|
21
|
-
VANDPS(xmm_sign, xmm_word, sign_mask)
|
|
22
|
-
|
|
23
|
-
xmm_shr3_nonsign = XMMRegister()
|
|
24
|
-
VPSRLD(xmm_shr3_nonsign, xmm_shl1_nonsign, 4)
|
|
25
|
-
|
|
26
|
-
exp_offset = Constant.uint32x4(0x38000000)
|
|
27
|
-
|
|
28
|
-
xmm_norm_nonsign = XMMRegister()
|
|
29
|
-
VPADDD(xmm_norm_nonsign, xmm_shr3_nonsign, exp_offset)
|
|
30
|
-
|
|
31
|
-
magic_mask = Constant.uint16x8(0x3E80)
|
|
32
|
-
xmm_denorm_nonsign = XMMRegister()
|
|
33
|
-
VPUNPCKLWD(xmm_denorm_nonsign, xmm_shl1_half, magic_mask)
|
|
34
|
-
|
|
35
|
-
magic_bias = Constant.float32x4(0.25)
|
|
36
|
-
VSUBPS(xmm_denorm_nonsign, xmm_denorm_nonsign, magic_bias)
|
|
37
|
-
|
|
38
|
-
xmm_denorm_cutoff = XMMRegister()
|
|
39
|
-
VMOVDQA(xmm_denorm_cutoff, Constant.uint32x4(0x00800000))
|
|
40
|
-
|
|
41
|
-
xmm_denorm_mask = XMMRegister()
|
|
42
|
-
VPCMPGTD(xmm_denorm_mask, xmm_denorm_cutoff, xmm_shr3_nonsign)
|
|
43
|
-
|
|
44
|
-
xmm_nonsign = XMMRegister()
|
|
45
|
-
VBLENDVPS(xmm_nonsign, xmm_norm_nonsign, xmm_denorm_nonsign, xmm_denorm_mask)
|
|
46
|
-
|
|
47
|
-
xmm_float = XMMRegister()
|
|
48
|
-
VORPS(xmm_float, xmm_nonsign, xmm_sign)
|
|
49
|
-
|
|
50
|
-
return xmm_float
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
from peachpy import *
|
|
2
|
-
from peachpy.x86_64 import *
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def fp16_alt_xmm_to_fp32_ymm(xmm_half):
|
|
6
|
-
ymm_half = YMMRegister()
|
|
7
|
-
VPERMQ(ymm_half, xmm_half.as_ymm, 0b01010000)
|
|
8
|
-
|
|
9
|
-
ymm_zero = YMMRegister()
|
|
10
|
-
VPXOR(ymm_zero.as_xmm, ymm_zero.as_xmm, ymm_zero.as_xmm)
|
|
11
|
-
|
|
12
|
-
ymm_word = YMMRegister()
|
|
13
|
-
VPUNPCKLWD(ymm_word, ymm_zero, ymm_half)
|
|
14
|
-
|
|
15
|
-
ymm_shl1_half = YMMRegister()
|
|
16
|
-
VPADDW(ymm_shl1_half, ymm_half, ymm_half)
|
|
17
|
-
|
|
18
|
-
ymm_shl1_nonsign = YMMRegister()
|
|
19
|
-
VPADDD(ymm_shl1_nonsign, ymm_word, ymm_word)
|
|
20
|
-
|
|
21
|
-
sign_mask = Constant.float32x8(-0.0)
|
|
22
|
-
|
|
23
|
-
ymm_sign = YMMRegister()
|
|
24
|
-
VANDPS(ymm_sign, ymm_word, sign_mask)
|
|
25
|
-
|
|
26
|
-
ymm_shr3_nonsign = YMMRegister()
|
|
27
|
-
VPSRLD(ymm_shr3_nonsign, ymm_shl1_nonsign, 4)
|
|
28
|
-
|
|
29
|
-
exp_offset = Constant.uint32x8(0x38000000)
|
|
30
|
-
|
|
31
|
-
ymm_norm_nonsign = YMMRegister()
|
|
32
|
-
VPADDD(ymm_norm_nonsign, ymm_shr3_nonsign, exp_offset)
|
|
33
|
-
|
|
34
|
-
magic_mask = Constant.uint16x16(0x3E80)
|
|
35
|
-
ymm_denorm_nonsign = YMMRegister()
|
|
36
|
-
VPUNPCKLWD(ymm_denorm_nonsign, ymm_shl1_half, magic_mask)
|
|
37
|
-
|
|
38
|
-
magic_bias = Constant.float32x8(0.25)
|
|
39
|
-
VSUBPS(ymm_denorm_nonsign, ymm_denorm_nonsign, magic_bias)
|
|
40
|
-
|
|
41
|
-
ymm_denorm_cutoff = YMMRegister()
|
|
42
|
-
VMOVDQA(ymm_denorm_cutoff, Constant.uint32x8(0x00800000))
|
|
43
|
-
|
|
44
|
-
ymm_denorm_mask = YMMRegister()
|
|
45
|
-
VPCMPGTD(ymm_denorm_mask, ymm_denorm_cutoff, ymm_shr3_nonsign)
|
|
46
|
-
|
|
47
|
-
ymm_nonsign = YMMRegister()
|
|
48
|
-
VBLENDVPS(ymm_nonsign, ymm_norm_nonsign, ymm_denorm_nonsign, ymm_denorm_mask)
|
|
49
|
-
|
|
50
|
-
ymm_float = YMMRegister()
|
|
51
|
-
VORPS(ymm_float, ymm_nonsign, ymm_sign)
|
|
52
|
-
|
|
53
|
-
return ymm_float
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
#ifndef FP16_BITCASTS_H
|
|
3
|
-
#define FP16_BITCASTS_H
|
|
4
|
-
|
|
5
|
-
#if defined(__cplusplus) && (__cplusplus >= 201103L)
|
|
6
|
-
#include <cstdint>
|
|
7
|
-
#elif !defined(__OPENCL_VERSION__)
|
|
8
|
-
#include <stdint.h>
|
|
9
|
-
#endif
|
|
10
|
-
|
|
11
|
-
#if defined(__INTEL_COMPILER)
|
|
12
|
-
#include <immintrin.h>
|
|
13
|
-
#endif
|
|
14
|
-
|
|
15
|
-
#if defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
|
|
16
|
-
#include <intrin.h>
|
|
17
|
-
#endif
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
static inline float fp32_from_bits(uint32_t w) {
|
|
21
|
-
#if defined(__OPENCL_VERSION__)
|
|
22
|
-
return as_float(w);
|
|
23
|
-
#elif defined(__CUDA_ARCH__)
|
|
24
|
-
return __uint_as_float((unsigned int) w);
|
|
25
|
-
#elif defined(__INTEL_COMPILER)
|
|
26
|
-
return _castu32_f32(w);
|
|
27
|
-
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
|
|
28
|
-
return _CopyFloatFromInt32((__int32) w);
|
|
29
|
-
#else
|
|
30
|
-
union {
|
|
31
|
-
uint32_t as_bits;
|
|
32
|
-
float as_value;
|
|
33
|
-
} fp32 = { w };
|
|
34
|
-
return fp32.as_value;
|
|
35
|
-
#endif
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
static inline uint32_t fp32_to_bits(float f) {
|
|
39
|
-
#if defined(__OPENCL_VERSION__)
|
|
40
|
-
return as_uint(f);
|
|
41
|
-
#elif defined(__CUDA_ARCH__)
|
|
42
|
-
return (uint32_t) __float_as_uint(f);
|
|
43
|
-
#elif defined(__INTEL_COMPILER)
|
|
44
|
-
return _castf32_u32(f);
|
|
45
|
-
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
|
|
46
|
-
return (uint32_t) _CopyInt32FromFloat(f);
|
|
47
|
-
#else
|
|
48
|
-
union {
|
|
49
|
-
float as_value;
|
|
50
|
-
uint32_t as_bits;
|
|
51
|
-
} fp32 = { f };
|
|
52
|
-
return fp32.as_bits;
|
|
53
|
-
#endif
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
static inline double fp64_from_bits(uint64_t w) {
|
|
57
|
-
#if defined(__OPENCL_VERSION__)
|
|
58
|
-
return as_double(w);
|
|
59
|
-
#elif defined(__CUDA_ARCH__)
|
|
60
|
-
return __longlong_as_double((long long) w);
|
|
61
|
-
#elif defined(__INTEL_COMPILER)
|
|
62
|
-
return _castu64_f64(w);
|
|
63
|
-
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
|
|
64
|
-
return _CopyDoubleFromInt64((__int64) w);
|
|
65
|
-
#else
|
|
66
|
-
union {
|
|
67
|
-
uint64_t as_bits;
|
|
68
|
-
double as_value;
|
|
69
|
-
} fp64 = { w };
|
|
70
|
-
return fp64.as_value;
|
|
71
|
-
#endif
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
static inline uint64_t fp64_to_bits(double f) {
|
|
75
|
-
#if defined(__OPENCL_VERSION__)
|
|
76
|
-
return as_ulong(f);
|
|
77
|
-
#elif defined(__CUDA_ARCH__)
|
|
78
|
-
return (uint64_t) __double_as_longlong(f);
|
|
79
|
-
#elif defined(__INTEL_COMPILER)
|
|
80
|
-
return _castf64_u64(f);
|
|
81
|
-
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
|
|
82
|
-
return (uint64_t) _CopyInt64FromDouble(f);
|
|
83
|
-
#else
|
|
84
|
-
union {
|
|
85
|
-
double as_value;
|
|
86
|
-
uint64_t as_bits;
|
|
87
|
-
} fp64 = { f };
|
|
88
|
-
return fp64.as_bits;
|
|
89
|
-
#endif
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
#endif /* FP16_BITCASTS_H */
|