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 CC-by-NC license found in the
6
* LICENSE file in the root directory of this source tree.
7
*/
8
9
// Copyright 2004-present Facebook. All Rights Reserved.
10
11
#pragma once
12
13
#include <cuda.h>
14
#include "Float16.cuh"
15
16
namespace
faiss {
namespace
gpu {
17
18
template
<
typename
T>
19
struct
Comparator
{
20
__device__
static
inline
bool
lt(T a, T b) {
21
return
a < b;
22
}
23
24
__device__
static
inline
bool
gt(T a, T b) {
25
return
a > b;
26
}
27
};
28
29
#ifdef FAISS_USE_FLOAT16
30
31
template
<>
32
struct
Comparator
<half> {
33
__device__
static
inline
bool
lt(half a, half b) {
34
#if FAISS_USE_FULL_FLOAT16
35
return
__hlt(a, b);
36
#else
37
return
__half2float(a) < __half2float(b);
38
#endif // FAISS_USE_FULL_FLOAT16
39
}
40
41
__device__
static
inline
bool
gt(half a, half b) {
42
#if FAISS_USE_FULL_FLOAT16
43
return
__hgt(a, b);
44
#else
45
return
__half2float(a) > __half2float(b);
46
#endif // FAISS_USE_FULL_FLOAT16
47
}
48
};
49
50
#endif // FAISS_USE_FLOAT16
51
52
} }
// namespace
faiss::gpu::Comparator
Definition:
Comparators.cuh:19
Generated by
1.8.5