@@ -28,44 +28,24 @@ enum class IndicesDataType {
2828
2929// / Arguments to brute-force GPU k-nearest neighbor searching
3030struct 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-
5131 //
5232 // Search parameters
5333 //
5434
5535 // / Search parameter: distance metric
56- faiss::MetricType metric;
36+ faiss::MetricType metric = METRIC_L2 ;
5737
5838 // / Search parameter: distance metric argument (if applicable)
5939 // / For metric == METRIC_Lp, this is the p-value
60- float metricArg;
40+ float metricArg = 0 ;
6141
6242 // / Search parameter: return k nearest neighbors
6343 // / If the value provided is -1, then we report all pairwise distances
6444 // / without top-k filtering
65- int k;
45+ int k = 0 ;
6646
6747 // / Vector dimensionality
68- int dims;
48+ int dims = 0 ;
6949
7050 //
7151 // Vectors being queried
@@ -74,14 +54,14 @@ struct GpuDistanceParams {
7454 // / If vectorsRowMajor is true, this is
7555 // / numVectors x dims, with dims innermost; otherwise,
7656 // / 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 ;
8161
8262 // / Precomputed L2 norms for each vector in `vectors`, which can be
8363 // / optionally provided in advance to speed computation for METRIC_L2
84- const float * vectorNorms;
64+ const float * vectorNorms = nullptr ;
8565
8666 //
8767 // The query vectors (i.e., find k-nearest neighbors in `vectors` for each
@@ -91,10 +71,10 @@ struct GpuDistanceParams {
9171 // / If queriesRowMajor is true, this is
9272 // / numQueries x dims, with dims innermost; otherwise,
9373 // / 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 ;
9878
9979 //
10080 // Output results
@@ -103,16 +83,16 @@ struct GpuDistanceParams {
10383 // / A region of memory size numQueries x k, with k
10484 // / innermost (row major) if k > 0, or if k == -1, a region of memory of
10585 // / size numQueries x numVectors
106- float * outDistances;
86+ float * outDistances = nullptr ;
10787
10888 // / Do we only care about the indices reported, rather than the output
10989 // / distances? Not used if k == -1 (all pairwise distances)
110- bool ignoreOutDistances;
90+ bool ignoreOutDistances = false ;
11191
11292 // / A region of memory size numQueries x k, with k
11393 // / 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 ;
11696
11797 //
11898 // Execution information
@@ -123,7 +103,7 @@ struct GpuDistanceParams {
123103 // / (via cudaGetDevice/cudaSetDevice) is used
124104 // / Otherwise, an integer 0 <= device < numDevices indicates the device for
125105 // / execution
126- int device;
106+ int device = - 1 ;
127107
128108 // / Should the index dispatch down to RAFT?
129109 bool use_raft = false ;
0 commit comments