contrib/faiss/faiss/utils/distances_fused/distances_fused.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) Meta Platforms, Inc. and affiliates. |
3 | | * |
4 | | * This source code is licensed under the MIT license found in the |
5 | | * LICENSE file in the root directory of this source tree. |
6 | | */ |
7 | | |
8 | | #include <faiss/utils/distances_fused/distances_fused.h> |
9 | | |
10 | | #include <faiss/impl/platform_macros.h> |
11 | | |
12 | | #include <faiss/utils/distances_fused/avx512.h> |
13 | | #include <faiss/utils/distances_fused/simdlib_based.h> |
14 | | |
15 | | namespace faiss { |
16 | | |
17 | | bool exhaustive_L2sqr_fused_cmax( |
18 | | const float* x, |
19 | | const float* y, |
20 | | size_t d, |
21 | | size_t nx, |
22 | | size_t ny, |
23 | | Top1BlockResultHandler<CMax<float, int64_t>>& res, |
24 | 135 | const float* y_norms) { |
25 | 135 | if (nx == 0 || ny == 0) { |
26 | | // nothing to do |
27 | 0 | return true; |
28 | 0 | } |
29 | | |
30 | | #ifdef __AVX512F__ |
31 | | // avx512 kernel |
32 | | return exhaustive_L2sqr_fused_cmax_AVX512(x, y, d, nx, ny, res, y_norms); |
33 | | #elif defined(__AVX2__) || defined(__aarch64__) |
34 | | // avx2 or arm neon kernel |
35 | 135 | return exhaustive_L2sqr_fused_cmax_simdlib(x, y, d, nx, ny, res, y_norms); |
36 | | #else |
37 | | // not supported, please use a general-purpose kernel |
38 | | return false; |
39 | | #endif |
40 | 135 | } |
41 | | |
42 | | } // namespace faiss |