usearch 2.26.0 → 2.26.2

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.
Files changed (148) hide show
  1. package/README.md +2 -2
  2. package/cpp/test.cpp +66 -3
  3. package/include/usearch/index.hpp +9 -1
  4. package/include/usearch/index_dense.hpp +16 -5
  5. package/numkong/CITATION.cff +13 -9
  6. package/numkong/CONTRIBUTING.md +29 -24
  7. package/numkong/Cargo.toml +1 -1
  8. package/numkong/README.md +21 -7
  9. package/numkong/binding.gyp +47 -31
  10. package/numkong/build.rs +15 -5
  11. package/numkong/c/dispatch.h +0 -1
  12. package/numkong/c/parallel.c +139 -0
  13. package/numkong/c/parallel.h +47 -0
  14. package/numkong/cmake/toolchain-wasi.cmake +39 -5
  15. package/numkong/include/README.md +24 -17
  16. package/numkong/include/numkong/attention/sapphireamx.h +6 -6
  17. package/numkong/include/numkong/attention/sme.h +2 -2
  18. package/numkong/include/numkong/capabilities.h +2 -2
  19. package/numkong/include/numkong/cast/README.md +9 -7
  20. package/numkong/include/numkong/cast/loongsonasx.h +48 -40
  21. package/numkong/include/numkong/cast/serial.h +89 -11
  22. package/numkong/include/numkong/cast.h +3 -3
  23. package/numkong/include/numkong/curved/README.md +10 -10
  24. package/numkong/include/numkong/curved/neon.h +1 -0
  25. package/numkong/include/numkong/curved/neonbfdot.h +1 -0
  26. package/numkong/include/numkong/curved/smef64.h +1 -0
  27. package/numkong/include/numkong/dot/README.md +18 -18
  28. package/numkong/include/numkong/dot/alder.h +8 -8
  29. package/numkong/include/numkong/dot/haswell.h +8 -8
  30. package/numkong/include/numkong/dot/icelake.h +12 -12
  31. package/numkong/include/numkong/dot/loongsonasx.h +6 -6
  32. package/numkong/include/numkong/dot/neon.h +2 -1
  33. package/numkong/include/numkong/dot/neonbfdot.h +1 -0
  34. package/numkong/include/numkong/dot/neonfhm.h +1 -0
  35. package/numkong/include/numkong/dot/neonsdot.h +1 -0
  36. package/numkong/include/numkong/dot/powervsx.h +3 -3
  37. package/numkong/include/numkong/dot/serial.h +19 -6
  38. package/numkong/include/numkong/dot/skylake.h +4 -4
  39. package/numkong/include/numkong/dot/svehalf.h +1 -1
  40. package/numkong/include/numkong/dot/v128relaxed.h +24 -23
  41. package/numkong/include/numkong/dots/README.md +26 -26
  42. package/numkong/include/numkong/dots/genoa.h +3 -1
  43. package/numkong/include/numkong/dots/icelake.h +1 -0
  44. package/numkong/include/numkong/dots/powervsx.h +1 -1
  45. package/numkong/include/numkong/dots/serial.h +32 -33
  46. package/numkong/include/numkong/dots/sierra.h +4 -3
  47. package/numkong/include/numkong/each/README.md +5 -3
  48. package/numkong/include/numkong/each/sapphire.h +2 -0
  49. package/numkong/include/numkong/each/skylake.h +1 -0
  50. package/numkong/include/numkong/geospatial/README.md +6 -6
  51. package/numkong/include/numkong/geospatial/v128relaxed.h +1 -0
  52. package/numkong/include/numkong/maxsim/README.md +5 -5
  53. package/numkong/include/numkong/maxsim/genoa.h +4 -0
  54. package/numkong/include/numkong/maxsim/icelake.h +1 -0
  55. package/numkong/include/numkong/maxsim/serial.h +22 -9
  56. package/numkong/include/numkong/maxsim/sme.h +3 -2
  57. package/numkong/include/numkong/mesh/README.md +7 -4
  58. package/numkong/include/numkong/mesh/genoa.h +2 -2
  59. package/numkong/include/numkong/mesh/haswell.h +8 -8
  60. package/numkong/include/numkong/mesh/neon.h +6 -6
  61. package/numkong/include/numkong/mesh/neonbfdot.h +3 -2
  62. package/numkong/include/numkong/mesh/neonfhm.h +3 -2
  63. package/numkong/include/numkong/mesh/rvv.h +4 -4
  64. package/numkong/include/numkong/mesh/serial.h +17 -17
  65. package/numkong/include/numkong/mesh/skylake.h +4 -4
  66. package/numkong/include/numkong/mesh/v128relaxed.h +4 -4
  67. package/numkong/include/numkong/mesh.hpp +2 -2
  68. package/numkong/include/numkong/numkong.h +1 -1
  69. package/numkong/include/numkong/numkong.hpp +1 -1
  70. package/numkong/include/numkong/probability/README.md +17 -15
  71. package/numkong/include/numkong/probability/skylake.h +1 -1
  72. package/numkong/include/numkong/reduce/README.md +27 -21
  73. package/numkong/include/numkong/reduce/genoa.h +2 -1
  74. package/numkong/include/numkong/reduce/icelake.h +1 -0
  75. package/numkong/include/numkong/reduce/neon.h +1 -1
  76. package/numkong/include/numkong/reduce/serial.h +9 -9
  77. package/numkong/include/numkong/reduce/skylake.h +4 -4
  78. package/numkong/include/numkong/reduce.hpp +38 -0
  79. package/numkong/include/numkong/scalar/README.md +29 -28
  80. package/numkong/include/numkong/set/README.md +17 -14
  81. package/numkong/include/numkong/set/haswell.h +15 -16
  82. package/numkong/include/numkong/set/icelake.h +15 -16
  83. package/numkong/include/numkong/set/loongsonasx.h +12 -10
  84. package/numkong/include/numkong/set/neon.h +15 -19
  85. package/numkong/include/numkong/set/powervsx.h +15 -21
  86. package/numkong/include/numkong/set/serial.h +19 -20
  87. package/numkong/include/numkong/set/v128relaxed.h +10 -8
  88. package/numkong/include/numkong/sets/icelake.h +1 -0
  89. package/numkong/include/numkong/sparse/README.md +4 -4
  90. package/numkong/include/numkong/sparse/icelake.h +1 -0
  91. package/numkong/include/numkong/sparse/neon.h +1 -0
  92. package/numkong/include/numkong/sparse/serial.h +10 -3
  93. package/numkong/include/numkong/sparse/turin.h +1 -0
  94. package/numkong/include/numkong/spatial/README.md +25 -24
  95. package/numkong/include/numkong/spatial/alder.h +2 -1
  96. package/numkong/include/numkong/spatial/haswell.h +48 -40
  97. package/numkong/include/numkong/spatial/icelake.h +2 -1
  98. package/numkong/include/numkong/spatial/neon.h +54 -46
  99. package/numkong/include/numkong/spatial/neonbfdot.h +1 -1
  100. package/numkong/include/numkong/spatial/powervsx.h +54 -46
  101. package/numkong/include/numkong/spatial/serial.h +56 -46
  102. package/numkong/include/numkong/spatial/sierra.h +4 -3
  103. package/numkong/include/numkong/spatial/skylake.h +27 -22
  104. package/numkong/include/numkong/spatial/sve.h +6 -6
  105. package/numkong/include/numkong/spatial/svebfdot.h +1 -1
  106. package/numkong/include/numkong/spatial/svehalf.h +1 -1
  107. package/numkong/include/numkong/spatial/v128relaxed.h +36 -30
  108. package/numkong/include/numkong/spatials/README.md +15 -15
  109. package/numkong/include/numkong/spatials/genoa.h +3 -0
  110. package/numkong/include/numkong/spatials/graniteamx.h +2 -0
  111. package/numkong/include/numkong/spatials/icelake.h +1 -0
  112. package/numkong/include/numkong/spatials/sierra.h +1 -0
  113. package/numkong/include/numkong/tensor.hpp +236 -123
  114. package/numkong/include/numkong/trigonometry/README.md +4 -4
  115. package/numkong/include/numkong/trigonometry/serial.h +6 -6
  116. package/numkong/include/numkong/trigonometry/v128relaxed.h +1 -0
  117. package/numkong/include/numkong/types.hpp +46 -16
  118. package/numkong/include/numkong/vector.hpp +116 -23
  119. package/numkong/javascript/@numkong-darwin-arm64/package.json +1 -1
  120. package/numkong/javascript/@numkong-darwin-x64/package.json +1 -1
  121. package/numkong/javascript/@numkong-linux-arm64/package.json +1 -1
  122. package/numkong/javascript/@numkong-linux-x64/package.json +1 -1
  123. package/numkong/javascript/@numkong-win32-arm64/package.json +1 -1
  124. package/numkong/javascript/@numkong-win32-x64/package.json +1 -1
  125. package/numkong/javascript/README.md +18 -16
  126. package/numkong/javascript/numkong.c +70 -40
  127. package/numkong/package.json +8 -8
  128. package/numkong/rust/README.md +19 -9
  129. package/numkong/rust/cast.rs +52 -1
  130. package/numkong/rust/each.rs +480 -7
  131. package/numkong/rust/matrix.rs +877 -216
  132. package/numkong/rust/numkong.rs +12 -8
  133. package/numkong/rust/reduce.rs +433 -5
  134. package/numkong/rust/tensor.rs +450 -842
  135. package/numkong/rust/vector.rs +520 -101
  136. package/numkong/swift/README.md +5 -3
  137. package/numkong/test/README.md +4 -4
  138. package/numkong/test/test-wasi.mjs +17 -0
  139. package/numkong/test/test_each.cpp +30 -1
  140. package/numkong/test/test_each.py +74 -1
  141. package/numkong/test/test_reduce.cpp +51 -0
  142. package/numkong/test/test_tensor.cpp +2 -63
  143. package/numkong/test/test_tensor.py +93 -0
  144. package/package.json +1 -1
  145. package/prebuilds/darwin-arm64+x64/usearch.node +0 -0
  146. package/prebuilds/linux-arm64/usearch.node +0 -0
  147. package/prebuilds/linux-x64/usearch.node +0 -0
  148. package/prebuilds/win32-x64/usearch.node +0 -0
@@ -2108,232 +2108,893 @@ pub trait Euclideans: Dots {
2108
2108
  );
2109
2109
  }
2110
2110
 
2111
- macro_rules! impl_spatial_traits {
2112
- ($rust_ty:ty, $result_ty:ty, $ptr_ty:ty, $cast:expr,
2113
- $ang_packed:ident, $ang_sym:ident, $euc_packed:ident, $euc_sym:ident) => {
2114
- impl Angulars for $rust_ty {
2115
- type SpatialResult = $result_ty;
2116
-
2117
- unsafe fn angulars_packed(
2118
- a: *const Self,
2119
- packed: *const u8,
2120
- c: *mut Self::SpatialResult,
2121
- height: usize,
2122
- width: usize,
2123
- depth: usize,
2124
- a_stride: usize,
2125
- c_stride: usize,
2126
- ) {
2127
- $ang_packed(
2128
- $cast(a),
2129
- packed,
2130
- c,
2131
- height,
2132
- width,
2133
- depth,
2134
- a_stride,
2135
- c_stride,
2136
- )
2137
- }
2138
-
2139
- unsafe fn angulars_symmetric(
2140
- vectors: *const Self,
2141
- n_vectors: usize,
2142
- depth: usize,
2143
- stride: usize,
2144
- result: *mut Self::SpatialResult,
2145
- result_stride: usize,
2146
- row_start: usize,
2147
- row_count: usize,
2148
- ) {
2149
- $ang_sym(
2150
- $cast(vectors),
2151
- n_vectors,
2152
- depth,
2153
- stride,
2154
- result,
2155
- result_stride,
2156
- row_start,
2157
- row_count,
2158
- )
2159
- }
2160
- }
2111
+ impl Angulars for f32 {
2112
+ type SpatialResult = f64;
2161
2113
 
2162
- impl Euclideans for $rust_ty {
2163
- type SpatialResult = $result_ty;
2164
-
2165
- unsafe fn euclideans_packed(
2166
- a: *const Self,
2167
- packed: *const u8,
2168
- c: *mut Self::SpatialResult,
2169
- height: usize,
2170
- width: usize,
2171
- depth: usize,
2172
- a_stride: usize,
2173
- c_stride: usize,
2174
- ) {
2175
- $euc_packed(
2176
- $cast(a),
2177
- packed,
2178
- c,
2179
- height,
2180
- width,
2181
- depth,
2182
- a_stride,
2183
- c_stride,
2184
- )
2185
- }
2114
+ unsafe fn angulars_packed(
2115
+ a: *const Self,
2116
+ packed: *const u8,
2117
+ c: *mut Self::SpatialResult,
2118
+ height: usize,
2119
+ width: usize,
2120
+ depth: usize,
2121
+ a_stride: usize,
2122
+ c_stride: usize,
2123
+ ) {
2124
+ nk_angulars_packed_f32(a, packed, c, height, width, depth, a_stride, c_stride)
2125
+ }
2186
2126
 
2187
- unsafe fn euclideans_symmetric(
2188
- vectors: *const Self,
2189
- n_vectors: usize,
2190
- depth: usize,
2191
- stride: usize,
2192
- result: *mut Self::SpatialResult,
2193
- result_stride: usize,
2194
- row_start: usize,
2195
- row_count: usize,
2196
- ) {
2197
- $euc_sym(
2198
- $cast(vectors),
2199
- n_vectors,
2200
- depth,
2201
- stride,
2202
- result,
2203
- result_stride,
2204
- row_start,
2205
- row_count,
2206
- )
2207
- }
2208
- }
2209
- };
2127
+ unsafe fn angulars_symmetric(
2128
+ vectors: *const Self,
2129
+ n_vectors: usize,
2130
+ depth: usize,
2131
+ stride: usize,
2132
+ result: *mut Self::SpatialResult,
2133
+ result_stride: usize,
2134
+ row_start: usize,
2135
+ row_count: usize,
2136
+ ) {
2137
+ nk_angulars_symmetric_f32(
2138
+ vectors,
2139
+ n_vectors,
2140
+ depth,
2141
+ stride,
2142
+ result,
2143
+ result_stride,
2144
+ row_start,
2145
+ row_count,
2146
+ )
2147
+ }
2210
2148
  }
2211
2149
 
2212
- #[inline(always)]
2213
- fn identity_f32(p: *const f32) -> *const f32 {
2214
- p
2215
- }
2216
- #[inline(always)]
2217
- fn identity_f64(p: *const f64) -> *const f64 {
2218
- p
2150
+ impl Euclideans for f32 {
2151
+ type SpatialResult = f64;
2152
+
2153
+ unsafe fn euclideans_packed(
2154
+ a: *const Self,
2155
+ packed: *const u8,
2156
+ c: *mut Self::SpatialResult,
2157
+ height: usize,
2158
+ width: usize,
2159
+ depth: usize,
2160
+ a_stride: usize,
2161
+ c_stride: usize,
2162
+ ) {
2163
+ nk_euclideans_packed_f32(a, packed, c, height, width, depth, a_stride, c_stride)
2164
+ }
2165
+
2166
+ unsafe fn euclideans_symmetric(
2167
+ vectors: *const Self,
2168
+ n_vectors: usize,
2169
+ depth: usize,
2170
+ stride: usize,
2171
+ result: *mut Self::SpatialResult,
2172
+ result_stride: usize,
2173
+ row_start: usize,
2174
+ row_count: usize,
2175
+ ) {
2176
+ nk_euclideans_symmetric_f32(
2177
+ vectors,
2178
+ n_vectors,
2179
+ depth,
2180
+ stride,
2181
+ result,
2182
+ result_stride,
2183
+ row_start,
2184
+ row_count,
2185
+ )
2186
+ }
2219
2187
  }
2220
- #[inline(always)]
2221
- fn identity_i8(p: *const i8) -> *const i8 {
2222
- p
2188
+
2189
+ impl Angulars for f64 {
2190
+ type SpatialResult = f64;
2191
+
2192
+ unsafe fn angulars_packed(
2193
+ a: *const Self,
2194
+ packed: *const u8,
2195
+ c: *mut Self::SpatialResult,
2196
+ height: usize,
2197
+ width: usize,
2198
+ depth: usize,
2199
+ a_stride: usize,
2200
+ c_stride: usize,
2201
+ ) {
2202
+ nk_angulars_packed_f64(a, packed, c, height, width, depth, a_stride, c_stride)
2203
+ }
2204
+
2205
+ unsafe fn angulars_symmetric(
2206
+ vectors: *const Self,
2207
+ n_vectors: usize,
2208
+ depth: usize,
2209
+ stride: usize,
2210
+ result: *mut Self::SpatialResult,
2211
+ result_stride: usize,
2212
+ row_start: usize,
2213
+ row_count: usize,
2214
+ ) {
2215
+ nk_angulars_symmetric_f64(
2216
+ vectors,
2217
+ n_vectors,
2218
+ depth,
2219
+ stride,
2220
+ result,
2221
+ result_stride,
2222
+ row_start,
2223
+ row_count,
2224
+ )
2225
+ }
2223
2226
  }
2224
- #[inline(always)]
2225
- fn identity_u8(p: *const u8) -> *const u8 {
2226
- p
2227
+
2228
+ impl Euclideans for f64 {
2229
+ type SpatialResult = f64;
2230
+
2231
+ unsafe fn euclideans_packed(
2232
+ a: *const Self,
2233
+ packed: *const u8,
2234
+ c: *mut Self::SpatialResult,
2235
+ height: usize,
2236
+ width: usize,
2237
+ depth: usize,
2238
+ a_stride: usize,
2239
+ c_stride: usize,
2240
+ ) {
2241
+ nk_euclideans_packed_f64(a, packed, c, height, width, depth, a_stride, c_stride)
2242
+ }
2243
+
2244
+ unsafe fn euclideans_symmetric(
2245
+ vectors: *const Self,
2246
+ n_vectors: usize,
2247
+ depth: usize,
2248
+ stride: usize,
2249
+ result: *mut Self::SpatialResult,
2250
+ result_stride: usize,
2251
+ row_start: usize,
2252
+ row_count: usize,
2253
+ ) {
2254
+ nk_euclideans_symmetric_f64(
2255
+ vectors,
2256
+ n_vectors,
2257
+ depth,
2258
+ stride,
2259
+ result,
2260
+ result_stride,
2261
+ row_start,
2262
+ row_count,
2263
+ )
2264
+ }
2227
2265
  }
2228
- #[inline(always)]
2229
- fn cast_to_u16<Scalar>(p: *const Scalar) -> *const u16 {
2230
- p as *const u16
2266
+
2267
+ impl Angulars for f16 {
2268
+ type SpatialResult = f32;
2269
+
2270
+ unsafe fn angulars_packed(
2271
+ a: *const Self,
2272
+ packed: *const u8,
2273
+ c: *mut Self::SpatialResult,
2274
+ height: usize,
2275
+ width: usize,
2276
+ depth: usize,
2277
+ a_stride: usize,
2278
+ c_stride: usize,
2279
+ ) {
2280
+ nk_angulars_packed_f16(
2281
+ a as *const u16,
2282
+ packed,
2283
+ c,
2284
+ height,
2285
+ width,
2286
+ depth,
2287
+ a_stride,
2288
+ c_stride,
2289
+ )
2290
+ }
2291
+
2292
+ unsafe fn angulars_symmetric(
2293
+ vectors: *const Self,
2294
+ n_vectors: usize,
2295
+ depth: usize,
2296
+ stride: usize,
2297
+ result: *mut Self::SpatialResult,
2298
+ result_stride: usize,
2299
+ row_start: usize,
2300
+ row_count: usize,
2301
+ ) {
2302
+ nk_angulars_symmetric_f16(
2303
+ vectors as *const u16,
2304
+ n_vectors,
2305
+ depth,
2306
+ stride,
2307
+ result,
2308
+ result_stride,
2309
+ row_start,
2310
+ row_count,
2311
+ )
2312
+ }
2231
2313
  }
2232
- #[inline(always)]
2233
- fn cast_to_u8<Scalar>(p: *const Scalar) -> *const u8 {
2234
- p as *const u8
2314
+
2315
+ impl Euclideans for f16 {
2316
+ type SpatialResult = f32;
2317
+
2318
+ unsafe fn euclideans_packed(
2319
+ a: *const Self,
2320
+ packed: *const u8,
2321
+ c: *mut Self::SpatialResult,
2322
+ height: usize,
2323
+ width: usize,
2324
+ depth: usize,
2325
+ a_stride: usize,
2326
+ c_stride: usize,
2327
+ ) {
2328
+ nk_euclideans_packed_f16(
2329
+ a as *const u16,
2330
+ packed,
2331
+ c,
2332
+ height,
2333
+ width,
2334
+ depth,
2335
+ a_stride,
2336
+ c_stride,
2337
+ )
2338
+ }
2339
+
2340
+ unsafe fn euclideans_symmetric(
2341
+ vectors: *const Self,
2342
+ n_vectors: usize,
2343
+ depth: usize,
2344
+ stride: usize,
2345
+ result: *mut Self::SpatialResult,
2346
+ result_stride: usize,
2347
+ row_start: usize,
2348
+ row_count: usize,
2349
+ ) {
2350
+ nk_euclideans_symmetric_f16(
2351
+ vectors as *const u16,
2352
+ n_vectors,
2353
+ depth,
2354
+ stride,
2355
+ result,
2356
+ result_stride,
2357
+ row_start,
2358
+ row_count,
2359
+ )
2360
+ }
2235
2361
  }
2236
2362
 
2237
- impl_spatial_traits!(
2238
- f32,
2239
- f64,
2240
- *const f32,
2241
- identity_f32,
2242
- nk_angulars_packed_f32,
2243
- nk_angulars_symmetric_f32,
2244
- nk_euclideans_packed_f32,
2245
- nk_euclideans_symmetric_f32
2246
- );
2247
- impl_spatial_traits!(
2248
- f64,
2249
- f64,
2250
- *const f64,
2251
- identity_f64,
2252
- nk_angulars_packed_f64,
2253
- nk_angulars_symmetric_f64,
2254
- nk_euclideans_packed_f64,
2255
- nk_euclideans_symmetric_f64
2256
- );
2257
- impl_spatial_traits!(
2258
- f16,
2259
- f32,
2260
- *const u16,
2261
- cast_to_u16,
2262
- nk_angulars_packed_f16,
2263
- nk_angulars_symmetric_f16,
2264
- nk_euclideans_packed_f16,
2265
- nk_euclideans_symmetric_f16
2266
- );
2267
- impl_spatial_traits!(
2268
- bf16,
2269
- f32,
2270
- *const u16,
2271
- cast_to_u16,
2272
- nk_angulars_packed_bf16,
2273
- nk_angulars_symmetric_bf16,
2274
- nk_euclideans_packed_bf16,
2275
- nk_euclideans_symmetric_bf16
2276
- );
2277
- impl_spatial_traits!(
2278
- i8,
2279
- f32,
2280
- *const i8,
2281
- identity_i8,
2282
- nk_angulars_packed_i8,
2283
- nk_angulars_symmetric_i8,
2284
- nk_euclideans_packed_i8,
2285
- nk_euclideans_symmetric_i8
2286
- );
2287
- impl_spatial_traits!(
2288
- u8,
2289
- f32,
2290
- *const u8,
2291
- identity_u8,
2292
- nk_angulars_packed_u8,
2293
- nk_angulars_symmetric_u8,
2294
- nk_euclideans_packed_u8,
2295
- nk_euclideans_symmetric_u8
2296
- );
2297
- impl_spatial_traits!(
2298
- e4m3,
2299
- f32,
2300
- *const u8,
2301
- cast_to_u8,
2302
- nk_angulars_packed_e4m3,
2303
- nk_angulars_symmetric_e4m3,
2304
- nk_euclideans_packed_e4m3,
2305
- nk_euclideans_symmetric_e4m3
2306
- );
2307
- impl_spatial_traits!(
2308
- e5m2,
2309
- f32,
2310
- *const u8,
2311
- cast_to_u8,
2312
- nk_angulars_packed_e5m2,
2313
- nk_angulars_symmetric_e5m2,
2314
- nk_euclideans_packed_e5m2,
2315
- nk_euclideans_symmetric_e5m2
2316
- );
2317
- impl_spatial_traits!(
2318
- e2m3,
2319
- f32,
2320
- *const u8,
2321
- cast_to_u8,
2322
- nk_angulars_packed_e2m3,
2323
- nk_angulars_symmetric_e2m3,
2324
- nk_euclideans_packed_e2m3,
2325
- nk_euclideans_symmetric_e2m3
2326
- );
2327
- impl_spatial_traits!(
2328
- e3m2,
2329
- f32,
2330
- *const u8,
2331
- cast_to_u8,
2332
- nk_angulars_packed_e3m2,
2333
- nk_angulars_symmetric_e3m2,
2334
- nk_euclideans_packed_e3m2,
2335
- nk_euclideans_symmetric_e3m2
2336
- );
2363
+ impl Angulars for bf16 {
2364
+ type SpatialResult = f32;
2365
+
2366
+ unsafe fn angulars_packed(
2367
+ a: *const Self,
2368
+ packed: *const u8,
2369
+ c: *mut Self::SpatialResult,
2370
+ height: usize,
2371
+ width: usize,
2372
+ depth: usize,
2373
+ a_stride: usize,
2374
+ c_stride: usize,
2375
+ ) {
2376
+ nk_angulars_packed_bf16(
2377
+ a as *const u16,
2378
+ packed,
2379
+ c,
2380
+ height,
2381
+ width,
2382
+ depth,
2383
+ a_stride,
2384
+ c_stride,
2385
+ )
2386
+ }
2387
+
2388
+ unsafe fn angulars_symmetric(
2389
+ vectors: *const Self,
2390
+ n_vectors: usize,
2391
+ depth: usize,
2392
+ stride: usize,
2393
+ result: *mut Self::SpatialResult,
2394
+ result_stride: usize,
2395
+ row_start: usize,
2396
+ row_count: usize,
2397
+ ) {
2398
+ nk_angulars_symmetric_bf16(
2399
+ vectors as *const u16,
2400
+ n_vectors,
2401
+ depth,
2402
+ stride,
2403
+ result,
2404
+ result_stride,
2405
+ row_start,
2406
+ row_count,
2407
+ )
2408
+ }
2409
+ }
2410
+
2411
+ impl Euclideans for bf16 {
2412
+ type SpatialResult = f32;
2413
+
2414
+ unsafe fn euclideans_packed(
2415
+ a: *const Self,
2416
+ packed: *const u8,
2417
+ c: *mut Self::SpatialResult,
2418
+ height: usize,
2419
+ width: usize,
2420
+ depth: usize,
2421
+ a_stride: usize,
2422
+ c_stride: usize,
2423
+ ) {
2424
+ nk_euclideans_packed_bf16(
2425
+ a as *const u16,
2426
+ packed,
2427
+ c,
2428
+ height,
2429
+ width,
2430
+ depth,
2431
+ a_stride,
2432
+ c_stride,
2433
+ )
2434
+ }
2435
+
2436
+ unsafe fn euclideans_symmetric(
2437
+ vectors: *const Self,
2438
+ n_vectors: usize,
2439
+ depth: usize,
2440
+ stride: usize,
2441
+ result: *mut Self::SpatialResult,
2442
+ result_stride: usize,
2443
+ row_start: usize,
2444
+ row_count: usize,
2445
+ ) {
2446
+ nk_euclideans_symmetric_bf16(
2447
+ vectors as *const u16,
2448
+ n_vectors,
2449
+ depth,
2450
+ stride,
2451
+ result,
2452
+ result_stride,
2453
+ row_start,
2454
+ row_count,
2455
+ )
2456
+ }
2457
+ }
2458
+
2459
+ impl Angulars for i8 {
2460
+ type SpatialResult = f32;
2461
+
2462
+ unsafe fn angulars_packed(
2463
+ a: *const Self,
2464
+ packed: *const u8,
2465
+ c: *mut Self::SpatialResult,
2466
+ height: usize,
2467
+ width: usize,
2468
+ depth: usize,
2469
+ a_stride: usize,
2470
+ c_stride: usize,
2471
+ ) {
2472
+ nk_angulars_packed_i8(a, packed, c, height, width, depth, a_stride, c_stride)
2473
+ }
2474
+
2475
+ unsafe fn angulars_symmetric(
2476
+ vectors: *const Self,
2477
+ n_vectors: usize,
2478
+ depth: usize,
2479
+ stride: usize,
2480
+ result: *mut Self::SpatialResult,
2481
+ result_stride: usize,
2482
+ row_start: usize,
2483
+ row_count: usize,
2484
+ ) {
2485
+ nk_angulars_symmetric_i8(
2486
+ vectors,
2487
+ n_vectors,
2488
+ depth,
2489
+ stride,
2490
+ result,
2491
+ result_stride,
2492
+ row_start,
2493
+ row_count,
2494
+ )
2495
+ }
2496
+ }
2497
+
2498
+ impl Euclideans for i8 {
2499
+ type SpatialResult = f32;
2500
+
2501
+ unsafe fn euclideans_packed(
2502
+ a: *const Self,
2503
+ packed: *const u8,
2504
+ c: *mut Self::SpatialResult,
2505
+ height: usize,
2506
+ width: usize,
2507
+ depth: usize,
2508
+ a_stride: usize,
2509
+ c_stride: usize,
2510
+ ) {
2511
+ nk_euclideans_packed_i8(a, packed, c, height, width, depth, a_stride, c_stride)
2512
+ }
2513
+
2514
+ unsafe fn euclideans_symmetric(
2515
+ vectors: *const Self,
2516
+ n_vectors: usize,
2517
+ depth: usize,
2518
+ stride: usize,
2519
+ result: *mut Self::SpatialResult,
2520
+ result_stride: usize,
2521
+ row_start: usize,
2522
+ row_count: usize,
2523
+ ) {
2524
+ nk_euclideans_symmetric_i8(
2525
+ vectors,
2526
+ n_vectors,
2527
+ depth,
2528
+ stride,
2529
+ result,
2530
+ result_stride,
2531
+ row_start,
2532
+ row_count,
2533
+ )
2534
+ }
2535
+ }
2536
+
2537
+ impl Angulars for u8 {
2538
+ type SpatialResult = f32;
2539
+
2540
+ unsafe fn angulars_packed(
2541
+ a: *const Self,
2542
+ packed: *const u8,
2543
+ c: *mut Self::SpatialResult,
2544
+ height: usize,
2545
+ width: usize,
2546
+ depth: usize,
2547
+ a_stride: usize,
2548
+ c_stride: usize,
2549
+ ) {
2550
+ nk_angulars_packed_u8(a, packed, c, height, width, depth, a_stride, c_stride)
2551
+ }
2552
+
2553
+ unsafe fn angulars_symmetric(
2554
+ vectors: *const Self,
2555
+ n_vectors: usize,
2556
+ depth: usize,
2557
+ stride: usize,
2558
+ result: *mut Self::SpatialResult,
2559
+ result_stride: usize,
2560
+ row_start: usize,
2561
+ row_count: usize,
2562
+ ) {
2563
+ nk_angulars_symmetric_u8(
2564
+ vectors,
2565
+ n_vectors,
2566
+ depth,
2567
+ stride,
2568
+ result,
2569
+ result_stride,
2570
+ row_start,
2571
+ row_count,
2572
+ )
2573
+ }
2574
+ }
2575
+
2576
+ impl Euclideans for u8 {
2577
+ type SpatialResult = f32;
2578
+
2579
+ unsafe fn euclideans_packed(
2580
+ a: *const Self,
2581
+ packed: *const u8,
2582
+ c: *mut Self::SpatialResult,
2583
+ height: usize,
2584
+ width: usize,
2585
+ depth: usize,
2586
+ a_stride: usize,
2587
+ c_stride: usize,
2588
+ ) {
2589
+ nk_euclideans_packed_u8(a, packed, c, height, width, depth, a_stride, c_stride)
2590
+ }
2591
+
2592
+ unsafe fn euclideans_symmetric(
2593
+ vectors: *const Self,
2594
+ n_vectors: usize,
2595
+ depth: usize,
2596
+ stride: usize,
2597
+ result: *mut Self::SpatialResult,
2598
+ result_stride: usize,
2599
+ row_start: usize,
2600
+ row_count: usize,
2601
+ ) {
2602
+ nk_euclideans_symmetric_u8(
2603
+ vectors,
2604
+ n_vectors,
2605
+ depth,
2606
+ stride,
2607
+ result,
2608
+ result_stride,
2609
+ row_start,
2610
+ row_count,
2611
+ )
2612
+ }
2613
+ }
2614
+
2615
+ impl Angulars for e4m3 {
2616
+ type SpatialResult = f32;
2617
+
2618
+ unsafe fn angulars_packed(
2619
+ a: *const Self,
2620
+ packed: *const u8,
2621
+ c: *mut Self::SpatialResult,
2622
+ height: usize,
2623
+ width: usize,
2624
+ depth: usize,
2625
+ a_stride: usize,
2626
+ c_stride: usize,
2627
+ ) {
2628
+ nk_angulars_packed_e4m3(
2629
+ a as *const u8,
2630
+ packed,
2631
+ c,
2632
+ height,
2633
+ width,
2634
+ depth,
2635
+ a_stride,
2636
+ c_stride,
2637
+ )
2638
+ }
2639
+
2640
+ unsafe fn angulars_symmetric(
2641
+ vectors: *const Self,
2642
+ n_vectors: usize,
2643
+ depth: usize,
2644
+ stride: usize,
2645
+ result: *mut Self::SpatialResult,
2646
+ result_stride: usize,
2647
+ row_start: usize,
2648
+ row_count: usize,
2649
+ ) {
2650
+ nk_angulars_symmetric_e4m3(
2651
+ vectors as *const u8,
2652
+ n_vectors,
2653
+ depth,
2654
+ stride,
2655
+ result,
2656
+ result_stride,
2657
+ row_start,
2658
+ row_count,
2659
+ )
2660
+ }
2661
+ }
2662
+
2663
+ impl Euclideans for e4m3 {
2664
+ type SpatialResult = f32;
2665
+
2666
+ unsafe fn euclideans_packed(
2667
+ a: *const Self,
2668
+ packed: *const u8,
2669
+ c: *mut Self::SpatialResult,
2670
+ height: usize,
2671
+ width: usize,
2672
+ depth: usize,
2673
+ a_stride: usize,
2674
+ c_stride: usize,
2675
+ ) {
2676
+ nk_euclideans_packed_e4m3(
2677
+ a as *const u8,
2678
+ packed,
2679
+ c,
2680
+ height,
2681
+ width,
2682
+ depth,
2683
+ a_stride,
2684
+ c_stride,
2685
+ )
2686
+ }
2687
+
2688
+ unsafe fn euclideans_symmetric(
2689
+ vectors: *const Self,
2690
+ n_vectors: usize,
2691
+ depth: usize,
2692
+ stride: usize,
2693
+ result: *mut Self::SpatialResult,
2694
+ result_stride: usize,
2695
+ row_start: usize,
2696
+ row_count: usize,
2697
+ ) {
2698
+ nk_euclideans_symmetric_e4m3(
2699
+ vectors as *const u8,
2700
+ n_vectors,
2701
+ depth,
2702
+ stride,
2703
+ result,
2704
+ result_stride,
2705
+ row_start,
2706
+ row_count,
2707
+ )
2708
+ }
2709
+ }
2710
+
2711
+ impl Angulars for e5m2 {
2712
+ type SpatialResult = f32;
2713
+
2714
+ unsafe fn angulars_packed(
2715
+ a: *const Self,
2716
+ packed: *const u8,
2717
+ c: *mut Self::SpatialResult,
2718
+ height: usize,
2719
+ width: usize,
2720
+ depth: usize,
2721
+ a_stride: usize,
2722
+ c_stride: usize,
2723
+ ) {
2724
+ nk_angulars_packed_e5m2(
2725
+ a as *const u8,
2726
+ packed,
2727
+ c,
2728
+ height,
2729
+ width,
2730
+ depth,
2731
+ a_stride,
2732
+ c_stride,
2733
+ )
2734
+ }
2735
+
2736
+ unsafe fn angulars_symmetric(
2737
+ vectors: *const Self,
2738
+ n_vectors: usize,
2739
+ depth: usize,
2740
+ stride: usize,
2741
+ result: *mut Self::SpatialResult,
2742
+ result_stride: usize,
2743
+ row_start: usize,
2744
+ row_count: usize,
2745
+ ) {
2746
+ nk_angulars_symmetric_e5m2(
2747
+ vectors as *const u8,
2748
+ n_vectors,
2749
+ depth,
2750
+ stride,
2751
+ result,
2752
+ result_stride,
2753
+ row_start,
2754
+ row_count,
2755
+ )
2756
+ }
2757
+ }
2758
+
2759
+ impl Euclideans for e5m2 {
2760
+ type SpatialResult = f32;
2761
+
2762
+ unsafe fn euclideans_packed(
2763
+ a: *const Self,
2764
+ packed: *const u8,
2765
+ c: *mut Self::SpatialResult,
2766
+ height: usize,
2767
+ width: usize,
2768
+ depth: usize,
2769
+ a_stride: usize,
2770
+ c_stride: usize,
2771
+ ) {
2772
+ nk_euclideans_packed_e5m2(
2773
+ a as *const u8,
2774
+ packed,
2775
+ c,
2776
+ height,
2777
+ width,
2778
+ depth,
2779
+ a_stride,
2780
+ c_stride,
2781
+ )
2782
+ }
2783
+
2784
+ unsafe fn euclideans_symmetric(
2785
+ vectors: *const Self,
2786
+ n_vectors: usize,
2787
+ depth: usize,
2788
+ stride: usize,
2789
+ result: *mut Self::SpatialResult,
2790
+ result_stride: usize,
2791
+ row_start: usize,
2792
+ row_count: usize,
2793
+ ) {
2794
+ nk_euclideans_symmetric_e5m2(
2795
+ vectors as *const u8,
2796
+ n_vectors,
2797
+ depth,
2798
+ stride,
2799
+ result,
2800
+ result_stride,
2801
+ row_start,
2802
+ row_count,
2803
+ )
2804
+ }
2805
+ }
2806
+
2807
+ impl Angulars for e2m3 {
2808
+ type SpatialResult = f32;
2809
+
2810
+ unsafe fn angulars_packed(
2811
+ a: *const Self,
2812
+ packed: *const u8,
2813
+ c: *mut Self::SpatialResult,
2814
+ height: usize,
2815
+ width: usize,
2816
+ depth: usize,
2817
+ a_stride: usize,
2818
+ c_stride: usize,
2819
+ ) {
2820
+ nk_angulars_packed_e2m3(
2821
+ a as *const u8,
2822
+ packed,
2823
+ c,
2824
+ height,
2825
+ width,
2826
+ depth,
2827
+ a_stride,
2828
+ c_stride,
2829
+ )
2830
+ }
2831
+
2832
+ unsafe fn angulars_symmetric(
2833
+ vectors: *const Self,
2834
+ n_vectors: usize,
2835
+ depth: usize,
2836
+ stride: usize,
2837
+ result: *mut Self::SpatialResult,
2838
+ result_stride: usize,
2839
+ row_start: usize,
2840
+ row_count: usize,
2841
+ ) {
2842
+ nk_angulars_symmetric_e2m3(
2843
+ vectors as *const u8,
2844
+ n_vectors,
2845
+ depth,
2846
+ stride,
2847
+ result,
2848
+ result_stride,
2849
+ row_start,
2850
+ row_count,
2851
+ )
2852
+ }
2853
+ }
2854
+
2855
+ impl Euclideans for e2m3 {
2856
+ type SpatialResult = f32;
2857
+
2858
+ unsafe fn euclideans_packed(
2859
+ a: *const Self,
2860
+ packed: *const u8,
2861
+ c: *mut Self::SpatialResult,
2862
+ height: usize,
2863
+ width: usize,
2864
+ depth: usize,
2865
+ a_stride: usize,
2866
+ c_stride: usize,
2867
+ ) {
2868
+ nk_euclideans_packed_e2m3(
2869
+ a as *const u8,
2870
+ packed,
2871
+ c,
2872
+ height,
2873
+ width,
2874
+ depth,
2875
+ a_stride,
2876
+ c_stride,
2877
+ )
2878
+ }
2879
+
2880
+ unsafe fn euclideans_symmetric(
2881
+ vectors: *const Self,
2882
+ n_vectors: usize,
2883
+ depth: usize,
2884
+ stride: usize,
2885
+ result: *mut Self::SpatialResult,
2886
+ result_stride: usize,
2887
+ row_start: usize,
2888
+ row_count: usize,
2889
+ ) {
2890
+ nk_euclideans_symmetric_e2m3(
2891
+ vectors as *const u8,
2892
+ n_vectors,
2893
+ depth,
2894
+ stride,
2895
+ result,
2896
+ result_stride,
2897
+ row_start,
2898
+ row_count,
2899
+ )
2900
+ }
2901
+ }
2902
+
2903
+ impl Angulars for e3m2 {
2904
+ type SpatialResult = f32;
2905
+
2906
+ unsafe fn angulars_packed(
2907
+ a: *const Self,
2908
+ packed: *const u8,
2909
+ c: *mut Self::SpatialResult,
2910
+ height: usize,
2911
+ width: usize,
2912
+ depth: usize,
2913
+ a_stride: usize,
2914
+ c_stride: usize,
2915
+ ) {
2916
+ nk_angulars_packed_e3m2(
2917
+ a as *const u8,
2918
+ packed,
2919
+ c,
2920
+ height,
2921
+ width,
2922
+ depth,
2923
+ a_stride,
2924
+ c_stride,
2925
+ )
2926
+ }
2927
+
2928
+ unsafe fn angulars_symmetric(
2929
+ vectors: *const Self,
2930
+ n_vectors: usize,
2931
+ depth: usize,
2932
+ stride: usize,
2933
+ result: *mut Self::SpatialResult,
2934
+ result_stride: usize,
2935
+ row_start: usize,
2936
+ row_count: usize,
2937
+ ) {
2938
+ nk_angulars_symmetric_e3m2(
2939
+ vectors as *const u8,
2940
+ n_vectors,
2941
+ depth,
2942
+ stride,
2943
+ result,
2944
+ result_stride,
2945
+ row_start,
2946
+ row_count,
2947
+ )
2948
+ }
2949
+ }
2950
+
2951
+ impl Euclideans for e3m2 {
2952
+ type SpatialResult = f32;
2953
+
2954
+ unsafe fn euclideans_packed(
2955
+ a: *const Self,
2956
+ packed: *const u8,
2957
+ c: *mut Self::SpatialResult,
2958
+ height: usize,
2959
+ width: usize,
2960
+ depth: usize,
2961
+ a_stride: usize,
2962
+ c_stride: usize,
2963
+ ) {
2964
+ nk_euclideans_packed_e3m2(
2965
+ a as *const u8,
2966
+ packed,
2967
+ c,
2968
+ height,
2969
+ width,
2970
+ depth,
2971
+ a_stride,
2972
+ c_stride,
2973
+ )
2974
+ }
2975
+
2976
+ unsafe fn euclideans_symmetric(
2977
+ vectors: *const Self,
2978
+ n_vectors: usize,
2979
+ depth: usize,
2980
+ stride: usize,
2981
+ result: *mut Self::SpatialResult,
2982
+ result_stride: usize,
2983
+ row_start: usize,
2984
+ row_count: usize,
2985
+ ) {
2986
+ nk_euclideans_symmetric_e3m2(
2987
+ vectors as *const u8,
2988
+ n_vectors,
2989
+ depth,
2990
+ stride,
2991
+ result,
2992
+ result_stride,
2993
+ row_start,
2994
+ row_count,
2995
+ )
2996
+ }
2997
+ }
2337
2998
  // Manual impls for 4-bit packed types: k must be multiplied by 2 (storage → nibbles).
2338
2999
 
2339
3000
  impl Angulars for u4x2 {