<divclass="line"><aname="l00005"></a><spanclass="lineno"> 5</span> <spanclass="comment"> * This source code is licensed under the BSD+Patents license found in the</span></div>
<divclass="line"><aname="l00006"></a><spanclass="lineno"> 6</span> <spanclass="comment"> * LICENSE file in the root directory of this source tree.</span></div>
<divclass="line"><aname="l00009"></a><spanclass="lineno"> 9</span> <spanclass="comment">// Copyright 2004-present Facebook. All Rights Reserved.</span></div>
<divclass="line"><aname="l00026"></a><spanclass="lineno"> 26</span> <spanclass="comment">/// Base inverted list functionality for IVFFlat and IVFPQ</span></div>
<divclass="line"><aname="l00038"></a><spanclass="lineno"> 38</span> <spanclass="comment"> /// Reserve GPU memory in our inverted lists for this number of vectors</span></div>
<divclass="line"><aname="l00041"></a><spanclass="lineno"> 41</span> <spanclass="comment"> /// Clear out all inverted lists, but retain the coarse quantizer</span></div>
<divclass="line"><aname="l00042"></a><spanclass="lineno"> 42</span> <spanclass="comment"> /// and the product quantizer info</span></div>
<divclass="line"><aname="l00045"></a><spanclass="lineno"> 45</span> <spanclass="comment"> /// Return the number of dimensions we are indexing</span></div>
<divclass="line"><aname="l00048"></a><spanclass="lineno"> 48</span> <spanclass="comment"> /// After adding vectors, one can call this to reclaim device memory</span></div>
<divclass="line"><aname="l00049"></a><spanclass="lineno"> 49</span> <spanclass="comment"> /// to exactly the amount needed. Returns space reclaimed in bytes</span></div>
<divclass="line"><aname="l00055"></a><spanclass="lineno"> 55</span> <spanclass="comment"> /// For debugging purposes, return the list length of a particular</span></div>
<divclass="line"><aname="l00059"></a><spanclass="lineno"> 59</span> <spanclass="comment"> /// Return the list indices of a particular list back to the CPU</span></div>
<divclass="line"><aname="l00063"></a><spanclass="lineno"> 63</span> <spanclass="comment"> /// Reclaim memory consumed on the device for our inverted lists</span></div>
<divclass="line"><aname="l00064"></a><spanclass="lineno"> 64</span> <spanclass="comment"> /// `exact` means we trim exactly to the memory needed</span></div>
<divclass="line"><aname="l00067"></a><spanclass="lineno"> 67</span> <spanclass="comment"> /// Update all device-side list pointer and size information</span></div>
<divclass="line"><aname="l00070"></a><spanclass="lineno"> 70</span> <spanclass="comment"> /// For a set of list IDs, update device-side list pointer and size</span></div>
<divclass="line"><aname="l00075"></a><spanclass="lineno"> 75</span> <spanclass="comment"> /// Shared function to copy indices from CPU to GPU</span></div>
<divclass="line"><aname="l00081"></a><spanclass="lineno"> 81</span> <spanclass="comment"> /// Collection of GPU resources that we use</span></div>
<divclass="line"><aname="l00096"></a><spanclass="lineno"> 96</span> <spanclass="comment"> /// How are user indices stored on the GPU?</span></div>
<divclass="line"><aname="l00099"></a><spanclass="lineno"> 99</span> <spanclass="comment"> /// What memory space our inverted list storage is in</span></div>
<divclass="line"><aname="l00102"></a><spanclass="lineno"> 102</span> <spanclass="comment"> /// Device representation of all inverted list data</span></div>
<divclass="line"><aname="l00106"></a><spanclass="lineno"> 106</span> <spanclass="comment"> /// Device representation of all inverted list index pointers</span></div>
<divclass="line"><aname="l00107"></a><spanclass="lineno"> 107</span> <spanclass="comment"> /// id -> data</span></div>
<divclass="line"><aname="l00110"></a><spanclass="lineno"> 110</span> <spanclass="comment"> /// Device representation of all inverted list lengths</span></div>
<divclass="line"><aname="l00111"></a><spanclass="lineno"> 111</span> <spanclass="comment"> /// id -> length</span></div>
<divclass="line"><aname="l00117"></a><spanclass="lineno"> 117</span> <spanclass="comment"> /// Device memory for each separate list, as managed by the host.</span></div>
<divclass="line"><aname="l00118"></a><spanclass="lineno"> 118</span> <spanclass="comment"> /// Device memory as stored in DeviceVector is stored as unique_ptr</span></div>
<divclass="line"><aname="l00119"></a><spanclass="lineno"> 119</span> <spanclass="comment"> /// since deviceListSummary_ pointers must remain valid despite</span></div>
<divclass="line"><aname="l00120"></a><spanclass="lineno"> 120</span> <spanclass="comment"> /// resizing of deviceLists_</span></div>
<divclass="line"><aname="l00124"></a><spanclass="lineno"> 124</span> <spanclass="comment"> /// If we are storing indices on the CPU (indicesOptions_ is</span></div>
<divclass="line"><aname="l00125"></a><spanclass="lineno"> 125</span> <spanclass="comment"> /// INDICES_CPU), then this maintains a CPU-side map of what</span></div>
<divclass="line"><aname="l00126"></a><spanclass="lineno"> 126</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#l00091">IVFBase.cuh:91</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#l00115">IVFBase.cuh:115</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#l00025">IVFBase.cu:25</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#l00127">IVFBase.cuh:127</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#l00023">FlatIndex.cuh:23</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#l00100">IVFBase.cu:100</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#l00045">IVFBase.cu:45</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#l00027">IVFBase.cuh:27</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#l00112">IVFBase.cuh:112</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#l00082">IVFBase.cuh:82</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#l00094">IVFBase.cuh:94</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#l00138">IVFBase.cu:138</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#l00207">IVFBase.cu:207</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#l00097">IVFBase.cuh:97</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#l00100">IVFBase.cuh:100</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#l00088">IVFBase.cuh:88</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#l00245">IVFBase.cu:245</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#l00195">IVFBase.cu:195</a></div></div>