<divclass="line"><aname="l00002"></a><spanclass="lineno"> 2</span> <spanclass="comment"> * Copyright (c) Facebook, Inc. and its affiliates.</span></div>
<divclass="line"><aname="l00004"></a><spanclass="lineno"> 4</span> <spanclass="comment"> * This source code is licensed under the MIT license found in the</span></div>
<divclass="line"><aname="l00005"></a><spanclass="lineno"> 5</span> <spanclass="comment"> * LICENSE file in the root directory of this source tree.</span></div>
<divclass="line"><aname="l00024"></a><spanclass="lineno"> 24</span> <spanclass="comment">/// Base inverted list functionality for IVFFlat and IVFPQ</span></div>
<divclass="line"><aname="l00036"></a><spanclass="lineno"> 36</span> <spanclass="comment"> /// Reserve GPU memory in our inverted lists for this number of vectors</span></div>
<divclass="line"><aname="l00039"></a><spanclass="lineno"> 39</span> <spanclass="comment"> /// Clear out all inverted lists, but retain the coarse quantizer</span></div>
<divclass="line"><aname="l00040"></a><spanclass="lineno"> 40</span> <spanclass="comment"> /// and the product quantizer info</span></div>
<divclass="line"><aname="l00043"></a><spanclass="lineno"> 43</span> <spanclass="comment"> /// Return the number of dimensions we are indexing</span></div>
<divclass="line"><aname="l00046"></a><spanclass="lineno"> 46</span> <spanclass="comment"> /// After adding vectors, one can call this to reclaim device memory</span></div>
<divclass="line"><aname="l00047"></a><spanclass="lineno"> 47</span> <spanclass="comment"> /// to exactly the amount needed. Returns space reclaimed in bytes</span></div>
<divclass="line"><aname="l00053"></a><spanclass="lineno"> 53</span> <spanclass="comment"> /// For debugging purposes, return the list length of a particular</span></div>
<divclass="line"><aname="l00057"></a><spanclass="lineno"> 57</span> <spanclass="comment"> /// Return the list indices of a particular list back to the CPU</span></div>
<divclass="line"><aname="l00061"></a><spanclass="lineno"> 61</span> <spanclass="comment"> /// Reclaim memory consumed on the device for our inverted lists</span></div>
<divclass="line"><aname="l00062"></a><spanclass="lineno"> 62</span> <spanclass="comment"> /// `exact` means we trim exactly to the memory needed</span></div>
<divclass="line"><aname="l00065"></a><spanclass="lineno"> 65</span> <spanclass="comment"> /// Update all device-side list pointer and size information</span></div>
<divclass="line"><aname="l00068"></a><spanclass="lineno"> 68</span> <spanclass="comment"> /// For a set of list IDs, update device-side list pointer and size</span></div>
<divclass="line"><aname="l00073"></a><spanclass="lineno"> 73</span> <spanclass="comment"> /// Shared function to copy indices from CPU to GPU</span></div>
<divclass="line"><aname="l00079"></a><spanclass="lineno"> 79</span> <spanclass="comment"> /// Collection of GPU resources that we use</span></div>
<divclass="line"><aname="l00094"></a><spanclass="lineno"> 94</span> <spanclass="comment"> /// How are user indices stored on the GPU?</span></div>
<divclass="line"><aname="l00097"></a><spanclass="lineno"> 97</span> <spanclass="comment"> /// What memory space our inverted list storage is in</span></div>
<divclass="line"><aname="l00100"></a><spanclass="lineno"> 100</span> <spanclass="comment"> /// Device representation of all inverted list data</span></div>
<divclass="line"><aname="l00101"></a><spanclass="lineno"> 101</span> <spanclass="comment"> /// id -> data</span></div>
<divclass="line"><aname="l00104"></a><spanclass="lineno"> 104</span> <spanclass="comment"> /// Device representation of all inverted list index pointers</span></div>
<divclass="line"><aname="l00105"></a><spanclass="lineno"> 105</span> <spanclass="comment"> /// id -> data</span></div>
<divclass="line"><aname="l00108"></a><spanclass="lineno"> 108</span> <spanclass="comment"> /// Device representation of all inverted list lengths</span></div>
<divclass="line"><aname="l00109"></a><spanclass="lineno"> 109</span> <spanclass="comment"> /// id -> length</span></div>
<divclass="line"><aname="l00115"></a><spanclass="lineno"> 115</span> <spanclass="comment"> /// Device memory for each separate list, as managed by the host.</span></div>
<divclass="line"><aname="l00116"></a><spanclass="lineno"> 116</span> <spanclass="comment"> /// Device memory as stored in DeviceVector is stored as unique_ptr</span></div>
<divclass="line"><aname="l00117"></a><spanclass="lineno"> 117</span> <spanclass="comment"> /// since deviceListSummary_ pointers must remain valid despite</span></div>
<divclass="line"><aname="l00118"></a><spanclass="lineno"> 118</span> <spanclass="comment"> /// resizing of deviceLists_</span></div>
<divclass="line"><aname="l00122"></a><spanclass="lineno"> 122</span> <spanclass="comment"> /// If we are storing indices on the CPU (indicesOptions_ is</span></div>
<divclass="line"><aname="l00123"></a><spanclass="lineno"> 123</span> <spanclass="comment"> /// INDICES_CPU), then this maintains a CPU-side map of what</span></div>
<divclass="line"><aname="l00124"></a><spanclass="lineno"> 124</span> <spanclass="comment"> /// (inverted list id, offset) maps to which user index</span></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1IVFBase_html_accc4d96c14643e5f471220cb1e92ac70"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1IVFBase.html#accc4d96c14643e5f471220cb1e92ac70">faiss::gpu::IVFBase::numLists_</a></div><divclass="ttdeci">const int numLists_</div><divclass="ttdoc">Number of inverted lists we maintain. </div><divclass="ttdef"><b>Definition:</b><ahref="IVFBase_8cuh_source.html#l00089">IVFBase.cuh:89</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1IVFBase_html_ae25ea0901fb628844868413f51c85bda"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1IVFBase.html#ae25ea0901fb628844868413f51c85bda">faiss::gpu::IVFBase::maxListLength_</a></div><divclass="ttdeci">int maxListLength_</div><divclass="ttdoc">Maximum list length seen. </div><divclass="ttdef"><b>Definition:</b><ahref="IVFBase_8cuh_source.html#l00113">IVFBase.cuh:113</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1IVFBase_html_a80130acfe0a2a4d387a5c9ee4c386b9c"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1IVFBase.html#a80130acfe0a2a4d387a5c9ee4c386b9c">faiss::gpu::IVFBase::IVFBase</a></div><divclass="ttdeci">IVFBase(GpuResources *resources, FlatIndex *quantizer, int bytesPerVector, IndicesOptions indicesOptions, MemorySpace space)</div><divclass="ttdef"><b>Definition:</b><ahref="IVFBase_8cu_source.html#l00023">IVFBase.cu:23</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1IVFBase_html_a53f3c382a79b7f89630a85dfbc3a1fed"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1IVFBase.html#a53f3c382a79b7f89630a85dfbc3a1fed">faiss::gpu::IVFBase::listOffsetToUserIndex_</a></div><divclass="ttdeci">std::vector< std::vector< long >> listOffsetToUserIndex_</div><divclass="ttdef"><b>Definition:</b><ahref="IVFBase_8cuh_source.html#l00125">IVFBase.cuh:125</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1FlatIndex_html"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1FlatIndex.html">faiss::gpu::FlatIndex</a></div><divclass="ttdoc">Holder of GPU resources for a particular flat index. </div><divclass="ttdef"><b>Definition:</b><ahref="FlatIndex_8cuh_source.html#l00021">FlatIndex.cuh:21</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1IVFBase_html_a4d44e8aebc380b7c846a8d8e6e835540"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1IVFBase.html#a4d44e8aebc380b7c846a8d8e6e835540">faiss::gpu::IVFBase::getDim</a></div><divclass="ttdeci">int getDim() const </div><divclass="ttdoc">Return the number of dimensions we are indexing. </div><divclass="ttdef"><b>Definition:</b><ahref="IVFBase_8cu_source.html#l00098">IVFBase.cu:98</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1IVFBase_html_a02e1e2d080ee31bf7835f89b9f2a13a9"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1IVFBase.html#a02e1e2d080ee31bf7835f89b9f2a13a9">faiss::gpu::IVFBase::reserveMemory</a></div><divclass="ttdeci">void reserveMemory(size_t numVecs)</div><divclass="ttdoc">Reserve GPU memory in our inverted lists for this number of vectors. </div><divclass="ttdef"><b>Definition:</b><ahref="IVFBase_8cu_source.html#l00043">IVFBase.cu:43</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1IVFBase_html"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1IVFBase.html">faiss::gpu::IVFBase</a></div><divclass="ttdoc">Base inverted list functionality for IVFFlat and IVFPQ. </div><divclass="ttdef"><b>Definition:</b><ahref="IVFBase_8cuh_source.html#l00025">IVFBase.cuh:25</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1IVFBase_html_a3a1c2031a4763f7d55bc8a400c63af66"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1IVFBase.html#a3a1c2031a4763f7d55bc8a400c63af66">faiss::gpu::IVFBase::deviceListLengths_</a></div><divclass="ttdeci">thrust::device_vector< int > deviceListLengths_</div><divclass="ttdef"><b>Definition:</b><ahref="IVFBase_8cuh_source.html#l00110">IVFBase.cuh:110</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1IVFBase_html_a05e6400358ec1f529a67209d3f24cc63"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1IVFBase.html#a05e6400358ec1f529a67209d3f24cc63">faiss::gpu::IVFBase::resources_</a></div><divclass="ttdeci">GpuResources * resources_</div><divclass="ttdoc">Collection of GPU resources that we use. </div><divclass="ttdef"><b>Definition:</b><ahref="IVFBase_8cuh_source.html#l00080">IVFBase.cuh:80</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1IVFBase_html_a319568b832518392fed33ea4f8bfc613"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1IVFBase.html#a319568b832518392fed33ea4f8bfc613">faiss::gpu::IVFBase::bytesPerVector_</a></div><divclass="ttdeci">const int bytesPerVector_</div><divclass="ttdoc">Number of bytes per vector in the list. </div><divclass="ttdef"><b>Definition:</b><ahref="IVFBase_8cuh_source.html#l00092">IVFBase.cuh:92</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1IVFBase_html_acc695610c9513952b8d234dc0db78e5c"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1IVFBase.html#acc695610c9513952b8d234dc0db78e5c">faiss::gpu::IVFBase::updateDeviceListInfo_</a></div><divclass="ttdeci">void updateDeviceListInfo_(cudaStream_t stream)</div><divclass="ttdoc">Update all device-side list pointer and size information. </div><divclass="ttdef"><b>Definition:</b><ahref="IVFBase_8cu_source.html#l00136">IVFBase.cu:136</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1IVFBase_html_a4a4ed220b9433aa788ed32db8f20a9db"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1IVFBase.html#a4a4ed220b9433aa788ed32db8f20a9db">faiss::gpu::IVFBase::getListIndices</a></div><divclass="ttdeci">std::vector< long > getListIndices(int listId) const </div><divclass="ttdoc">Return the list indices of a particular list back to the CPU. </div><divclass="ttdef"><b>Definition:</b><ahref="IVFBase_8cu_source.html#l00205">IVFBase.cu:205</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1IVFBase_html_afb6d10e23d6448c10f472b9234e0bcab"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1IVFBase.html#afb6d10e23d6448c10f472b9234e0bcab">faiss::gpu::IVFBase::indicesOptions_</a></div><divclass="ttdeci">const IndicesOptions indicesOptions_</div><divclass="ttdoc">How are user indices stored on the GPU? </div><divclass="ttdef"><b>Definition:</b><ahref="IVFBase_8cuh_source.html#l00095">IVFBase.cuh:95</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1IVFBase_html_a30499eb61763df72cab25ea9d1235251"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1IVFBase.html#a30499eb61763df72cab25ea9d1235251">faiss::gpu::IVFBase::space_</a></div><divclass="ttdeci">const MemorySpace space_</div><divclass="ttdoc">What memory space our inverted list storage is in. </div><divclass="ttdef"><b>Definition:</b><ahref="IVFBase_8cuh_source.html#l00098">IVFBase.cuh:98</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1IVFBase_html_aba3e3cfa469e5187f2d553fff10e0250"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1IVFBase.html#aba3e3cfa469e5187f2d553fff10e0250">faiss::gpu::IVFBase::dim_</a></div><divclass="ttdeci">const int dim_</div><divclass="ttdoc">Expected dimensionality of the vectors. </div><divclass="ttdef"><b>Definition:</b><ahref="IVFBase_8cuh_source.html#l00086">IVFBase.cuh:86</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1IVFBase_html_a5027720549de98f4e609d6339099df35"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1IVFBase.html#a5027720549de98f4e609d6339099df35">faiss::gpu::IVFBase::addIndicesFromCpu_</a></div><divclass="ttdeci">void addIndicesFromCpu_(int listId, const long *indices, size_t numVecs)</div><divclass="ttdoc">Shared function to copy indices from CPU to GPU. </div><divclass="ttdef"><b>Definition:</b><ahref="IVFBase_8cu_source.html#l00243">IVFBase.cu:243</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1IVFBase_html_abd66dc9d32e6150b930d78f74d7dd2d7"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1IVFBase.html#abd66dc9d32e6150b930d78f74d7dd2d7">faiss::gpu::IVFBase::getNumLists</a></div><divclass="ttdeci">size_t getNumLists() const </div><divclass="ttdoc">Returns the number of inverted lists. </div><divclass="ttdef"><b>Definition:</b><ahref="IVFBase_8cu_source.html#l00193">IVFBase.cu:193</a></div></div>