@@ -28,44 +28,24 @@ enum class IndicesDataType {
28
28
29
29
// / Arguments to brute-force GPU k-nearest neighbor searching
30
30
struct GpuDistanceParams {
31
- GpuDistanceParams ()
32
- : metric(faiss::MetricType::METRIC_L2),
33
- metricArg (0 ),
34
- k(0 ),
35
- dims(0 ),
36
- vectors(nullptr ),
37
- vectorType(DistanceDataType::F32),
38
- vectorsRowMajor(true ),
39
- numVectors(0 ),
40
- vectorNorms(nullptr ),
41
- queries(nullptr ),
42
- queryType(DistanceDataType::F32),
43
- queriesRowMajor(true ),
44
- numQueries(0 ),
45
- outDistances(nullptr ),
46
- ignoreOutDistances(false ),
47
- outIndicesType(IndicesDataType::I64),
48
- outIndices(nullptr ),
49
- device(-1 ) {}
50
-
51
31
//
52
32
// Search parameters
53
33
//
54
34
55
35
// / Search parameter: distance metric
56
- faiss::MetricType metric;
36
+ faiss::MetricType metric = METRIC_L2 ;
57
37
58
38
// / Search parameter: distance metric argument (if applicable)
59
39
// / For metric == METRIC_Lp, this is the p-value
60
- float metricArg;
40
+ float metricArg = 0 ;
61
41
62
42
// / Search parameter: return k nearest neighbors
63
43
// / If the value provided is -1, then we report all pairwise distances
64
44
// / without top-k filtering
65
- int k;
45
+ int k = 0 ;
66
46
67
47
// / Vector dimensionality
68
- int dims;
48
+ int dims = 0 ;
69
49
70
50
//
71
51
// Vectors being queried
@@ -74,14 +54,14 @@ struct GpuDistanceParams {
74
54
// / If vectorsRowMajor is true, this is
75
55
// / numVectors x dims, with dims innermost; otherwise,
76
56
// / dims x numVectors, with numVectors innermost
77
- const void * vectors;
78
- DistanceDataType vectorType;
79
- bool vectorsRowMajor;
80
- idx_t numVectors;
57
+ const void * vectors = nullptr ;
58
+ DistanceDataType vectorType = DistanceDataType::F32 ;
59
+ bool vectorsRowMajor = true ;
60
+ idx_t numVectors = 0 ;
81
61
82
62
// / Precomputed L2 norms for each vector in `vectors`, which can be
83
63
// / optionally provided in advance to speed computation for METRIC_L2
84
- const float * vectorNorms;
64
+ const float * vectorNorms = nullptr ;
85
65
86
66
//
87
67
// The query vectors (i.e., find k-nearest neighbors in `vectors` for each
@@ -91,10 +71,10 @@ struct GpuDistanceParams {
91
71
// / If queriesRowMajor is true, this is
92
72
// / numQueries x dims, with dims innermost; otherwise,
93
73
// / dims x numQueries, with numQueries innermost
94
- const void * queries;
95
- DistanceDataType queryType;
96
- bool queriesRowMajor;
97
- idx_t numQueries;
74
+ const void * queries = nullptr ;
75
+ DistanceDataType queryType = DistanceDataType::F32 ;
76
+ bool queriesRowMajor = true ;
77
+ idx_t numQueries = 0 ;
98
78
99
79
//
100
80
// Output results
@@ -103,16 +83,16 @@ struct GpuDistanceParams {
103
83
// / A region of memory size numQueries x k, with k
104
84
// / innermost (row major) if k > 0, or if k == -1, a region of memory of
105
85
// / size numQueries x numVectors
106
- float * outDistances;
86
+ float * outDistances = nullptr ;
107
87
108
88
// / Do we only care about the indices reported, rather than the output
109
89
// / distances? Not used if k == -1 (all pairwise distances)
110
- bool ignoreOutDistances;
90
+ bool ignoreOutDistances = false ;
111
91
112
92
// / A region of memory size numQueries x k, with k
113
93
// / innermost (row major). Not used if k == -1 (all pairwise distances)
114
- IndicesDataType outIndicesType;
115
- void * outIndices;
94
+ IndicesDataType outIndicesType = IndicesDataType::I64 ;
95
+ void * outIndices = nullptr ;
116
96
117
97
//
118
98
// Execution information
@@ -123,7 +103,7 @@ struct GpuDistanceParams {
123
103
// / (via cudaGetDevice/cudaSetDevice) is used
124
104
// / Otherwise, an integer 0 <= device < numDevices indicates the device for
125
105
// / execution
126
- int device;
106
+ int device = - 1 ;
127
107
128
108
// / Should the index dispatch down to RAFT?
129
109
bool use_raft = false ;
0 commit comments