Faiss
Main Page
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
gpu
utils
Comparators.cuh
1
/**
2
* Copyright (c) 2015-present, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD+Patents license found in the
6
* LICENSE file in the root directory of this source tree.
7
*/
8
9
10
#pragma once
11
12
#include <cuda.h>
13
#include "Float16.cuh"
14
15
namespace
faiss {
namespace
gpu {
16
17
template
<
typename
T>
18
struct
Comparator
{
19
__device__
static
inline
bool
lt(T a, T b) {
20
return
a < b;
21
}
22
23
__device__
static
inline
bool
gt(T a, T b) {
24
return
a > b;
25
}
26
};
27
28
#ifdef FAISS_USE_FLOAT16
29
30
template
<>
31
struct
Comparator
<half> {
32
__device__
static
inline
bool
lt(half a, half b) {
33
#if FAISS_USE_FULL_FLOAT16
34
return
__hlt(a, b);
35
#else
36
return
__half2float(a) < __half2float(b);
37
#endif // FAISS_USE_FULL_FLOAT16
38
}
39
40
__device__
static
inline
bool
gt(half a, half b) {
41
#if FAISS_USE_FULL_FLOAT16
42
return
__hgt(a, b);
43
#else
44
return
__half2float(a) > __half2float(b);
45
#endif // FAISS_USE_FULL_FLOAT16
46
}
47
};
48
49
#endif // FAISS_USE_FLOAT16
50
51
} }
// namespace
faiss::gpu::Comparator
Definition:
Comparators.cuh:18
Generated by
1.8.5