Commit a5ef16db authored by matthijs's avatar matthijs

sync with FB version 2017-08-09

parent 384d05c4
......@@ -20,9 +20,13 @@ namespace faiss {
* RangeSearchResult
***********************************************************************/
RangeSearchResult::RangeSearchResult (size_t nq): nq (nq) {
lims = new size_t [nq + 1];
memset (lims, 0, sizeof(*lims) * (nq + 1));
RangeSearchResult::RangeSearchResult (idx_t nq, bool alloc_lims): nq (nq) {
if (alloc_lims) {
lims = new size_t [nq + 1];
memset (lims, 0, sizeof(*lims) * (nq + 1));
} else {
lims = nullptr;
}
labels = nullptr;
distances = nullptr;
buffer_size = 1024 * 256;
......
......@@ -38,7 +38,7 @@ struct RangeSearchResult {
size_t buffer_size; ///< size of the result buffers used
/// lims must be allocated on input to range_search.
explicit RangeSearchResult (size_t nq);
explicit RangeSearchResult (idx_t nq, bool alloc_lims=true);
/// called when lims contains the nb of elements result entries
/// for each query
......
......@@ -98,7 +98,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
<div class="line"><a name="l00009"></a><span class="lineno"> 9</span>&#160;<span class="preprocessor">#include &lt;cstdio&gt;</span></div>
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;<span class="preprocessor">#include &lt;cstdlib&gt;</span></div>
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span>&#160;</div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;<span class="preprocessor">#include &lt;faiss/IndexFlat.h&gt;</span></div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;<span class="preprocessor">#include &lt;IndexFlat.h&gt;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;</div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;</div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;<span class="keywordtype">int</span> main() {</div>
......
......@@ -99,8 +99,8 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;<span class="preprocessor">#include &lt;cstdlib&gt;</span></div>
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span>&#160;<span class="preprocessor">#include &lt;cassert&gt;</span></div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;</div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;<span class="preprocessor">#include &lt;faiss/IndexFlat.h&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;<span class="preprocessor">#include &lt;faiss/IndexIVF.h&gt;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;<span class="preprocessor">#include &lt;IndexFlat.h&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;<span class="preprocessor">#include &lt;IndexIVF.h&gt;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;</div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;</div>
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160;<span class="keywordtype">int</span> main() {</div>
......
......@@ -98,8 +98,8 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
<div class="line"><a name="l00009"></a><span class="lineno"> 9</span>&#160;<span class="preprocessor">#include &lt;cstdio&gt;</span></div>
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;<span class="preprocessor">#include &lt;cstdlib&gt;</span></div>
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span>&#160;</div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;<span class="preprocessor">#include &lt;faiss/IndexFlat.h&gt;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;<span class="preprocessor">#include &lt;faiss/IndexIVFPQ.h&gt;</span></div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;<span class="preprocessor">#include &lt;IndexFlat.h&gt;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;<span class="preprocessor">#include &lt;IndexIVFPQ.h&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;</div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;</div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;<span class="keywordtype">int</span> main() {</div>
......
This diff is collapsed.
......@@ -554,15 +554,20 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
<div class="line"><a name="l00465"></a><span class="lineno"> 465</span>&#160; <a class="code" href="classfaiss_1_1gpu_1_1IVFPQ.html#a0eedf0295ad73125ee1254173a176674">IVFPQ::isSupportedNoPrecomputedSubDimSize</a>(</div>
<div class="line"><a name="l00466"></a><span class="lineno"> 466</span>&#160; this-&gt;d / subQuantizers_),</div>
<div class="line"><a name="l00467"></a><span class="lineno"> 467</span>&#160; <span class="stringliteral">&quot;Number of dimensions per sub-quantizer (%d) &quot;</span></div>
<div class="line"><a name="l00468"></a><span class="lineno"> 468</span>&#160; <span class="stringliteral">&quot;is unsupported with precomputed codes&quot;</span>,</div>
<div class="line"><a name="l00469"></a><span class="lineno"> 469</span>&#160; this-&gt;d / subQuantizers_);</div>
<div class="line"><a name="l00470"></a><span class="lineno"> 470</span>&#160;</div>
<div class="line"><a name="l00471"></a><span class="lineno"> 471</span>&#160; <span class="comment">// TODO: fully implement METRIC_INNER_PRODUCT</span></div>
<div class="line"><a name="l00472"></a><span class="lineno"> 472</span>&#160; FAISS_THROW_IF_NOT_MSG(this-&gt;<a class="code" href="structfaiss_1_1Index.html#a8e18f641854b2bde83ecff0a2f9a6f4e">metric_type</a> == faiss::METRIC_L2,</div>
<div class="line"><a name="l00473"></a><span class="lineno"> 473</span>&#160; <span class="stringliteral">&quot;METRIC_INNER_PRODUCT is currently unsupported&quot;</span>);</div>
<div class="line"><a name="l00474"></a><span class="lineno"> 474</span>&#160;}</div>
<div class="line"><a name="l00468"></a><span class="lineno"> 468</span>&#160; <span class="stringliteral">&quot;is not currently supported without precomputed codes. &quot;</span></div>
<div class="line"><a name="l00469"></a><span class="lineno"> 469</span>&#160; <span class="stringliteral">&quot;Only 1, 2, 3, 4, 6, 8, 10, 12, 16, 20, 24, 28, 32 dims &quot;</span></div>
<div class="line"><a name="l00470"></a><span class="lineno"> 470</span>&#160; <span class="stringliteral">&quot;per sub-quantizer are currently supported with no &quot;</span></div>
<div class="line"><a name="l00471"></a><span class="lineno"> 471</span>&#160; <span class="stringliteral">&quot;precomputed codes. &quot;</span></div>
<div class="line"><a name="l00472"></a><span class="lineno"> 472</span>&#160; <span class="stringliteral">&quot;Precomputed codes supports any number of dimensions, but &quot;</span></div>
<div class="line"><a name="l00473"></a><span class="lineno"> 473</span>&#160; <span class="stringliteral">&quot;will involve memory overheads.&quot;</span>,</div>
<div class="line"><a name="l00474"></a><span class="lineno"> 474</span>&#160; this-&gt;d / subQuantizers_);</div>
<div class="line"><a name="l00475"></a><span class="lineno"> 475</span>&#160;</div>
<div class="line"><a name="l00476"></a><span class="lineno"> 476</span>&#160;} } <span class="comment">// namespace</span></div>
<div class="line"><a name="l00476"></a><span class="lineno"> 476</span>&#160; <span class="comment">// TODO: fully implement METRIC_INNER_PRODUCT</span></div>
<div class="line"><a name="l00477"></a><span class="lineno"> 477</span>&#160; FAISS_THROW_IF_NOT_MSG(this-&gt;<a class="code" href="structfaiss_1_1Index.html#a8e18f641854b2bde83ecff0a2f9a6f4e">metric_type</a> == faiss::METRIC_L2,</div>
<div class="line"><a name="l00478"></a><span class="lineno"> 478</span>&#160; <span class="stringliteral">&quot;METRIC_INNER_PRODUCT is currently unsupported&quot;</span>);</div>
<div class="line"><a name="l00479"></a><span class="lineno"> 479</span>&#160;}</div>
<div class="line"><a name="l00480"></a><span class="lineno"> 480</span>&#160;</div>
<div class="line"><a name="l00481"></a><span class="lineno"> 481</span>&#160;} } <span class="comment">// namespace</span></div>
<div class="ttc" id="classfaiss_1_1gpu_1_1GpuIndexIVFPQ_html_a5235cf241ef98e6012fd01907ec705d0"><div class="ttname"><a href="classfaiss_1_1gpu_1_1GpuIndexIVFPQ.html#a5235cf241ef98e6012fd01907ec705d0">faiss::gpu::GpuIndexIVFPQ::getListIndices</a></div><div class="ttdeci">std::vector&lt; long &gt; getListIndices(int listId) const </div><div class="ttdef"><b>Definition:</b> <a href="GpuIndexIVFPQ_8cu_source.html#l00408">GpuIndexIVFPQ.cu:408</a></div></div>
<div class="ttc" id="classfaiss_1_1gpu_1_1GpuIndexIVFPQ_html_a42f619bee6ecb268442c7807e75896fe"><div class="ttname"><a href="classfaiss_1_1gpu_1_1GpuIndexIVFPQ.html#a42f619bee6ecb268442c7807e75896fe">faiss::gpu::GpuIndexIVFPQ::searchImpl_</a></div><div class="ttdeci">void searchImpl_(faiss::Index::idx_t n, const float *x, faiss::Index::idx_t k, float *distances, faiss::Index::idx_t *labels) const override</div><div class="ttdoc">Called from GpuIndex for search. </div><div class="ttdef"><b>Definition:</b> <a href="GpuIndexIVFPQ_8cu_source.html#l00349">GpuIndexIVFPQ.cu:349</a></div></div>
<div class="ttc" id="structfaiss_1_1IndexIVFPQ_html_ad99c215aeaf92e995cb97f4044c4d267"><div class="ttname"><a href="structfaiss_1_1IndexIVFPQ.html#ad99c215aeaf92e995cb97f4044c4d267">faiss::IndexIVFPQ::precompute_table</a></div><div class="ttdeci">void precompute_table()</div><div class="ttdoc">build precomputed table </div><div class="ttdef"><b>Definition:</b> <a href="IndexIVFPQ_8cpp_source.html#l00391">IndexIVFPQ.cpp:391</a></div></div>
......
......@@ -840,7 +840,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
<div class="ttc" id="structfaiss_1_1Index_html_a6970683faa021b7a6f1a0865c0d4eccd"><div class="ttname"><a href="structfaiss_1_1Index.html#a6970683faa021b7a6f1a0865c0d4eccd">faiss::Index::ntotal</a></div><div class="ttdeci">idx_t ntotal</div><div class="ttdoc">total nb of indexed vectors </div><div class="ttdef"><b>Definition:</b> <a href="Index_8h_source.html#l00065">Index.h:65</a></div></div>
<div class="ttc" id="structfaiss_1_1Index_html_a5590d847c5c2b958affd2a05e58a6f23"><div class="ttname"><a href="structfaiss_1_1Index.html#a5590d847c5c2b958affd2a05e58a6f23">faiss::Index::verbose</a></div><div class="ttdeci">bool verbose</div><div class="ttdoc">verbosity level </div><div class="ttdef"><b>Definition:</b> <a href="Index_8h_source.html#l00066">Index.h:66</a></div></div>
<div class="ttc" id="structfaiss_1_1IndexIVF_html_a47a3b7665e9d2be41c6d3b2e9144b73f"><div class="ttname"><a href="structfaiss_1_1IndexIVF.html#a47a3b7665e9d2be41c6d3b2e9144b73f">faiss::IndexIVF::reset</a></div><div class="ttdeci">void reset() override</div><div class="ttdoc">removes all elements from the database. </div><div class="ttdef"><b>Definition:</b> <a href="IndexIVF_8cpp_source.html#l00093">IndexIVF.cpp:93</a></div></div>
<div class="ttc" id="structfaiss_1_1RangeSearchPartialResult_html_a954c26beebb561a6c2b0f399c48a9db3"><div class="ttname"><a href="structfaiss_1_1RangeSearchPartialResult.html#a954c26beebb561a6c2b0f399c48a9db3">faiss::RangeSearchPartialResult::new_result</a></div><div class="ttdeci">QueryResult &amp; new_result(idx_t qno)</div><div class="ttdoc">begin a new result </div><div class="ttdef"><b>Definition:</b> <a href="AuxIndexStructures_8cpp_source.html#l00113">AuxIndexStructures.cpp:113</a></div></div>
<div class="ttc" id="structfaiss_1_1RangeSearchPartialResult_html_a954c26beebb561a6c2b0f399c48a9db3"><div class="ttname"><a href="structfaiss_1_1RangeSearchPartialResult.html#a954c26beebb561a6c2b0f399c48a9db3">faiss::RangeSearchPartialResult::new_result</a></div><div class="ttdeci">QueryResult &amp; new_result(idx_t qno)</div><div class="ttdoc">begin a new result </div><div class="ttdef"><b>Definition:</b> <a href="AuxIndexStructures_8cpp_source.html#l00117">AuxIndexStructures.cpp:117</a></div></div>
<div class="ttc" id="structfaiss_1_1IndexIVFFlat_html_a2adc0b0002c32ddc01aec4ab96dd659f"><div class="ttname"><a href="structfaiss_1_1IndexIVFFlat.html#a2adc0b0002c32ddc01aec4ab96dd659f">faiss::IndexIVFFlat::update_vectors</a></div><div class="ttdeci">void update_vectors(int nv, idx_t *idx, const float *v)</div><div class="ttdef"><b>Definition:</b> <a href="IndexIVF_8cpp_source.html#l00487">IndexIVF.cpp:487</a></div></div>
<div class="ttc" id="structfaiss_1_1IndexIVFFlatIPBounds_html_aac063e96413e0e90d87898df8a60088b"><div class="ttname"><a href="structfaiss_1_1IndexIVFFlatIPBounds.html#aac063e96413e0e90d87898df8a60088b">faiss::IndexIVFFlatIPBounds::search</a></div><div class="ttdeci">void search(idx_t n, const float *x, idx_t k, float *distances, idx_t *labels) const override</div><div class="ttdef"><b>Definition:</b> <a href="IndexIVF_8cpp_source.html#l00693">IndexIVF.cpp:693</a></div></div>
<div class="ttc" id="structfaiss_1_1IndexIVFFlatIPBounds_html_a07b988f02cc2f6fc3eb951609bfc0817"><div class="ttname"><a href="structfaiss_1_1IndexIVFFlatIPBounds.html#a07b988f02cc2f6fc3eb951609bfc0817">faiss::IndexIVFFlatIPBounds::part_norms</a></div><div class="ttdeci">std::vector&lt; std::vector&lt; float &gt; &gt; part_norms</div><div class="ttdoc">norm of remainder (dimensions fsize:d) </div><div class="ttdef"><b>Definition:</b> <a href="IndexIVF_8h_source.html#l00213">IndexIVF.h:213</a></div></div>
......
......@@ -584,22 +584,31 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
<div class="line"><a name="l00495"></a><span class="lineno"> 495</span>&#160; <span class="keywordflow">case</span> 16:</div>
<div class="line"><a name="l00496"></a><span class="lineno"> 496</span>&#160; CODE_DISTANCE(16);</div>
<div class="line"><a name="l00497"></a><span class="lineno"> 497</span>&#160; <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00498"></a><span class="lineno"> 498</span>&#160; <span class="keywordflow">case</span> 32:</div>
<div class="line"><a name="l00499"></a><span class="lineno"> 499</span>&#160; CODE_DISTANCE(32);</div>
<div class="line"><a name="l00498"></a><span class="lineno"> 498</span>&#160; <span class="keywordflow">case</span> 20:</div>
<div class="line"><a name="l00499"></a><span class="lineno"> 499</span>&#160; CODE_DISTANCE(20);</div>
<div class="line"><a name="l00500"></a><span class="lineno"> 500</span>&#160; <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00501"></a><span class="lineno"> 501</span>&#160; <span class="comment">// FIXME: larger sizes require too many registers - we need the</span></div>
<div class="line"><a name="l00502"></a><span class="lineno"> 502</span>&#160; <span class="comment">// MM implementation working</span></div>
<div class="line"><a name="l00503"></a><span class="lineno"> 503</span>&#160; <span class="keywordflow">default</span>:</div>
<div class="line"><a name="l00504"></a><span class="lineno"> 504</span>&#160; FAISS_ASSERT(<span class="keyword">false</span>);</div>
<div class="line"><a name="l00505"></a><span class="lineno"> 505</span>&#160; <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00506"></a><span class="lineno"> 506</span>&#160; }</div>
<div class="line"><a name="l00507"></a><span class="lineno"> 507</span>&#160;</div>
<div class="line"><a name="l00508"></a><span class="lineno"> 508</span>&#160;<span class="preprocessor">#undef CODE_DISTANCE</span></div>
<div class="line"><a name="l00509"></a><span class="lineno"> 509</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00510"></a><span class="lineno"> 510</span>&#160; CUDA_TEST_ERROR();</div>
<div class="line"><a name="l00511"></a><span class="lineno"> 511</span>&#160;}</div>
<div class="line"><a name="l00512"></a><span class="lineno"> 512</span>&#160;</div>
<div class="line"><a name="l00513"></a><span class="lineno"> 513</span>&#160;} } <span class="comment">// namespace</span></div>
<div class="line"><a name="l00501"></a><span class="lineno"> 501</span>&#160; <span class="keywordflow">case</span> 24:</div>
<div class="line"><a name="l00502"></a><span class="lineno"> 502</span>&#160; CODE_DISTANCE(24);</div>
<div class="line"><a name="l00503"></a><span class="lineno"> 503</span>&#160; <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00504"></a><span class="lineno"> 504</span>&#160; <span class="keywordflow">case</span> 28:</div>
<div class="line"><a name="l00505"></a><span class="lineno"> 505</span>&#160; CODE_DISTANCE(28);</div>
<div class="line"><a name="l00506"></a><span class="lineno"> 506</span>&#160; <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00507"></a><span class="lineno"> 507</span>&#160; <span class="keywordflow">case</span> 32:</div>
<div class="line"><a name="l00508"></a><span class="lineno"> 508</span>&#160; CODE_DISTANCE(32);</div>
<div class="line"><a name="l00509"></a><span class="lineno"> 509</span>&#160; <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00510"></a><span class="lineno"> 510</span>&#160; <span class="comment">// FIXME: larger sizes require too many registers - we need the</span></div>
<div class="line"><a name="l00511"></a><span class="lineno"> 511</span>&#160; <span class="comment">// MM implementation working</span></div>
<div class="line"><a name="l00512"></a><span class="lineno"> 512</span>&#160; <span class="keywordflow">default</span>:</div>
<div class="line"><a name="l00513"></a><span class="lineno"> 513</span>&#160; FAISS_ASSERT(<span class="keyword">false</span>);</div>
<div class="line"><a name="l00514"></a><span class="lineno"> 514</span>&#160; <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00515"></a><span class="lineno"> 515</span>&#160; }</div>
<div class="line"><a name="l00516"></a><span class="lineno"> 516</span>&#160;</div>
<div class="line"><a name="l00517"></a><span class="lineno"> 517</span>&#160;<span class="preprocessor">#undef CODE_DISTANCE</span></div>
<div class="line"><a name="l00518"></a><span class="lineno"> 518</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00519"></a><span class="lineno"> 519</span>&#160; CUDA_TEST_ERROR();</div>
<div class="line"><a name="l00520"></a><span class="lineno"> 520</span>&#160;}</div>
<div class="line"><a name="l00521"></a><span class="lineno"> 521</span>&#160;</div>
<div class="line"><a name="l00522"></a><span class="lineno"> 522</span>&#160;} } <span class="comment">// namespace</span></div>
<div class="ttc" id="structfaiss_1_1gpu_1_1Converter_html"><div class="ttname"><a href="structfaiss_1_1gpu_1_1Converter.html">faiss::gpu::Converter</a></div><div class="ttdef"><b>Definition:</b> <a href="PQCodeDistances_8cu_source.html#l00027">PQCodeDistances.cu:27</a></div></div>
<div class="ttc" id="classfaiss_1_1gpu_1_1Tensor_html"><div class="ttname"><a href="classfaiss_1_1gpu_1_1Tensor.html">faiss::gpu::Tensor</a></div><div class="ttdoc">Our tensor type. </div><div class="ttdef"><b>Definition:</b> <a href="Tensor_8cuh_source.html#l00030">Tensor.cuh:30</a></div></div>
</div><!-- fragment --></div><!-- contents -->
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -115,11 +115,11 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160; 28, 32, 40, 48, 56, 64, 96</div>
<div class="line"><a name="l00027"></a><span class="lineno"> 27</span>&#160; };</div>
<div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160;</div>
<div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160; std::vector&lt;int&gt; dimSizes{4, 8, 16, 32};</div>
<div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160;</div>
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160; codes = codeSizes[faiss::gpu::randVal(0, codeSizes.size() - 1)];</div>
<div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160;</div>
<div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160; <span class="keywordflow">while</span> (<span class="keyword">true</span>) {</div>
<div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160; <span class="comment">// Above 32 doesn&#39;t work with no precomputed codes</span></div>
<div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160; std::vector&lt;int&gt; dimSizes{4, 8, 10, 12, 16, 20, 24, 28, 32};</div>
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160;</div>
<div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160; <span class="keywordflow">while</span> (<span class="keyword">true</span>) {</div>
<div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160; codes = codeSizes[faiss::gpu::randVal(0, codeSizes.size() - 1)];</div>
<div class="line"><a name="l00034"></a><span class="lineno"> 34</span>&#160; dim = codes * dimSizes[faiss::gpu::randVal(0, dimSizes.size() - 1)];</div>
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160;</div>
<div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160; <span class="comment">// for such a small test, super-low or high dim is more likely to</span></div>
......
......@@ -105,10 +105,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;<span class="preprocessor">#include &lt;sys/time.h&gt;</span></div>
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160;</div>
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;</div>
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160;<span class="preprocessor">#include &lt;faiss/IndexPQ.h&gt;</span></div>
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160;<span class="preprocessor">#include &lt;faiss/IndexIVF.h&gt;</span></div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160;<span class="preprocessor">#include &lt;faiss/IndexFlat.h&gt;</span></div>
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160;<span class="preprocessor">#include &lt;faiss/index_io.h&gt;</span></div>
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160;<span class="preprocessor">#include &lt;IndexPQ.h&gt;</span></div>
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160;<span class="preprocessor">#include &lt;IndexIVF.h&gt;</span></div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160;<span class="preprocessor">#include &lt;IndexFlat.h&gt;</span></div>
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160;<span class="preprocessor">#include &lt;index_io.h&gt;</span></div>
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160;</div>
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span>&#160;<span class="keywordtype">double</span> elapsed ()</div>
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160;{</div>
......
......@@ -105,10 +105,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;<span class="preprocessor">#include &lt;sys/time.h&gt;</span></div>
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160;</div>
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;</div>
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160;<span class="preprocessor">#include &lt;faiss/IndexPQ.h&gt;</span></div>
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160;<span class="preprocessor">#include &lt;faiss/IndexIVFPQ.h&gt;</span></div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160;<span class="preprocessor">#include &lt;faiss/IndexFlat.h&gt;</span></div>
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160;<span class="preprocessor">#include &lt;faiss/index_io.h&gt;</span></div>
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160;<span class="preprocessor">#include &lt;IndexPQ.h&gt;</span></div>
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160;<span class="preprocessor">#include &lt;IndexIVFPQ.h&gt;</span></div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160;<span class="preprocessor">#include &lt;IndexFlat.h&gt;</span></div>
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160;<span class="preprocessor">#include &lt;index_io.h&gt;</span></div>
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160;</div>
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span>&#160;<span class="keywordtype">double</span> elapsed ()</div>
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160;{</div>
......
......@@ -149,7 +149,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
, <a class="el" href="structfaiss_1_1IndexIVFFlat.html#ad2b306f160e153b5cfb572cf1d8ece24">faiss::IndexIVFFlat</a>
</li>
<li>RangeSearchResult()
: <a class="el" href="structfaiss_1_1RangeSearchResult.html#a46e9fa31c3e232249cef508f357d856c">faiss::RangeSearchResult</a>
: <a class="el" href="structfaiss_1_1RangeSearchResult.html#a56dca2b151bcf16f5d488aff321b9501">faiss::RangeSearchResult</a>
</li>
<li>RangeStat
: <a class="el" href="structfaiss_1_1ScalarQuantizer.html#a867ad0000e4ccfd40bbb1e01e7882d06">faiss::ScalarQuantizer</a>
......
......@@ -144,7 +144,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
, <a class="el" href="structfaiss_1_1IndexIVFFlat.html#ad2b306f160e153b5cfb572cf1d8ece24">faiss::IndexIVFFlat</a>
</li>
<li>RangeSearchResult()
: <a class="el" href="structfaiss_1_1RangeSearchResult.html#a46e9fa31c3e232249cef508f357d856c">faiss::RangeSearchResult</a>
: <a class="el" href="structfaiss_1_1RangeSearchResult.html#a56dca2b151bcf16f5d488aff321b9501">faiss::RangeSearchResult</a>
</li>
<li>reclaimMemory()
: <a class="el" href="classfaiss_1_1gpu_1_1GpuIndexIVFFlat.html#adaa727f3e951068501ebf381b001f3bd">faiss::gpu::GpuIndexIVFFlat</a>
......
......@@ -13,7 +13,7 @@ var searchData=
['range_5fsearch_5finner_5fproduct',['range_search_inner_product',['../namespacefaiss.html#ab29d725b808df6f142b80f21aa45e507',1,'faiss']]],
['range_5fsearch_5fl2sqr',['range_search_L2sqr',['../namespacefaiss.html#a1faa7bd079c9b1addf3058ddf882a000',1,'faiss']]],
['rangesearchpartialresult',['RangeSearchPartialResult',['../structfaiss_1_1RangeSearchPartialResult.html',1,'faiss']]],
['rangesearchresult',['RangeSearchResult',['../structfaiss_1_1RangeSearchResult.html#a46e9fa31c3e232249cef508f357d856c',1,'faiss::RangeSearchResult']]],
['rangesearchresult',['RangeSearchResult',['../structfaiss_1_1RangeSearchResult.html#a56dca2b151bcf16f5d488aff321b9501',1,'faiss::RangeSearchResult']]],
['rangesearchresult',['RangeSearchResult',['../structfaiss_1_1RangeSearchResult.html',1,'faiss']]],
['rangestat',['RangeStat',['../structfaiss_1_1ScalarQuantizer.html#a867ad0000e4ccfd40bbb1e01e7882d06',1,'faiss::ScalarQuantizer']]],
['rankingscore2',['RankingScore2',['../structfaiss_1_1RankingScore2.html',1,'faiss']]],
......
......@@ -8,7 +8,7 @@ var searchData=
['range_5fsearch',['range_search',['../structfaiss_1_1Index.html#a236897832a58dbb205e2d662c1929fb1',1,'faiss::Index::range_search()'],['../structfaiss_1_1IndexFlat.html#ac56b7ed90ab65fab9c586a1e56006d12',1,'faiss::IndexFlat::range_search()'],['../structfaiss_1_1IndexIVFFlat.html#ad2b306f160e153b5cfb572cf1d8ece24',1,'faiss::IndexIVFFlat::range_search()']]],
['range_5fsearch_5finner_5fproduct',['range_search_inner_product',['../namespacefaiss.html#ab29d725b808df6f142b80f21aa45e507',1,'faiss']]],
['range_5fsearch_5fl2sqr',['range_search_L2sqr',['../namespacefaiss.html#a1faa7bd079c9b1addf3058ddf882a000',1,'faiss']]],
['rangesearchresult',['RangeSearchResult',['../structfaiss_1_1RangeSearchResult.html#a46e9fa31c3e232249cef508f357d856c',1,'faiss::RangeSearchResult']]],
['rangesearchresult',['RangeSearchResult',['../structfaiss_1_1RangeSearchResult.html#a56dca2b151bcf16f5d488aff321b9501',1,'faiss::RangeSearchResult']]],
['ranklist_5fhandle_5fties',['ranklist_handle_ties',['../namespacefaiss.html#ae0ee1b6fbd3d6da0f1a3550a780ca24c',1,'faiss']]],
['ranklist_5fintersection_5fsize',['ranklist_intersection_size',['../namespacefaiss.html#a8dbc652ba48d41f126b8815004899448',1,'faiss']]],
['read_5findex',['read_index',['../namespacefaiss.html#aa46fe38a858ecfde7e0fc0744939d5ad',1,'faiss']]],
......
......@@ -188,7 +188,7 @@ size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="st
</div><div class="memdoc">
<p>copy elemnts ofs:ofs+n-1 seen as linear data in the buffers to tables dest_ids, dest_dis </p>
<p>Definition at line <a class="el" href="AuxIndexStructures_8cpp_source.html#l00081">81</a> of file <a class="el" href="AuxIndexStructures_8cpp_source.html">AuxIndexStructures.cpp</a>.</p>
<p>Definition at line <a class="el" href="AuxIndexStructures_8cpp_source.html#l00085">85</a> of file <a class="el" href="AuxIndexStructures_8cpp_source.html">AuxIndexStructures.cpp</a>.</p>
</div>
</div>
......
......@@ -100,7 +100,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
<tr class="even"><td class="entry"><a class="el" href="structfaiss_1_1RangeSearchResult.html#aa8ff848474a4cc16c5464cc4ec187824">labels</a></td><td class="entry"><a class="el" href="structfaiss_1_1RangeSearchResult.html">faiss::RangeSearchResult</a></td><td class="entry"></td></tr>
<tr><td class="entry"><a class="el" href="structfaiss_1_1RangeSearchResult.html#aef57f9db99ca470c01bcdce0366cb6ff">lims</a></td><td class="entry"><a class="el" href="structfaiss_1_1RangeSearchResult.html">faiss::RangeSearchResult</a></td><td class="entry"></td></tr>
<tr class="even"><td class="entry"><a class="el" href="structfaiss_1_1RangeSearchResult.html#a29269b98c33af874d379ca4f62408b90">nq</a></td><td class="entry"><a class="el" href="structfaiss_1_1RangeSearchResult.html">faiss::RangeSearchResult</a></td><td class="entry"></td></tr>
<tr><td class="entry"><a class="el" href="structfaiss_1_1RangeSearchResult.html#a46e9fa31c3e232249cef508f357d856c">RangeSearchResult</a>(size_t nq)</td><td class="entry"><a class="el" href="structfaiss_1_1RangeSearchResult.html">faiss::RangeSearchResult</a></td><td class="entry"><span class="mlabel">explicit</span></td></tr>
<tr><td class="entry"><a class="el" href="structfaiss_1_1RangeSearchResult.html#a56dca2b151bcf16f5d488aff321b9501">RangeSearchResult</a>(idx_t nq, bool alloc_lims=true)</td><td class="entry"><a class="el" href="structfaiss_1_1RangeSearchResult.html">faiss::RangeSearchResult</a></td><td class="entry"><span class="mlabel">explicit</span></td></tr>
<tr bgcolor="#f0f0f0" class="even"><td class="entry"><b>~RangeSearchResult</b>() (defined in <a class="el" href="structfaiss_1_1RangeSearchResult.html">faiss::RangeSearchResult</a>)</td><td class="entry"><a class="el" href="structfaiss_1_1RangeSearchResult.html">faiss::RangeSearchResult</a></td><td class="entry"><span class="mlabel">virtual</span></td></tr>
</table></div><!-- contents -->
<!-- start footer part -->
......
......@@ -106,10 +106,10 @@ typedef <a class="el" href="structfaiss_1_1Index.html#a040c6aed1f224f3ea7bf58eeb
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a46e9fa31c3e232249cef508f357d856c"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a46e9fa31c3e232249cef508f357d856c"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structfaiss_1_1RangeSearchResult.html#a46e9fa31c3e232249cef508f357d856c">RangeSearchResult</a> (size_t <a class="el" href="structfaiss_1_1RangeSearchResult.html#a29269b98c33af874d379ca4f62408b90">nq</a>)</td></tr>
<tr class="memdesc:a46e9fa31c3e232249cef508f357d856c"><td class="mdescLeft">&#160;</td><td class="mdescRight">lims must be allocated on input to range_search. <br/></td></tr>
<tr class="separator:a46e9fa31c3e232249cef508f357d856c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a56dca2b151bcf16f5d488aff321b9501"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a56dca2b151bcf16f5d488aff321b9501"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structfaiss_1_1RangeSearchResult.html#a56dca2b151bcf16f5d488aff321b9501">RangeSearchResult</a> (idx_t <a class="el" href="structfaiss_1_1RangeSearchResult.html#a29269b98c33af874d379ca4f62408b90">nq</a>, bool alloc_lims=true)</td></tr>
<tr class="memdesc:a56dca2b151bcf16f5d488aff321b9501"><td class="mdescLeft">&#160;</td><td class="mdescRight">lims must be allocated on input to range_search. <br/></td></tr>
<tr class="separator:a56dca2b151bcf16f5d488aff321b9501"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a34c4ba599c0cec45972af19e1f98f22a"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structfaiss_1_1RangeSearchResult.html#a34c4ba599c0cec45972af19e1f98f22a">do_allocation</a> ()</td></tr>
<tr class="separator:a34c4ba599c0cec45972af19e1f98f22a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
......@@ -163,7 +163,7 @@ size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="st
</div><div class="memdoc">
<p>called when lims contains the nb of elements result entries for each query </p>
<p>Definition at line <a class="el" href="AuxIndexStructures_8cpp_source.html#l00033">33</a> of file <a class="el" href="AuxIndexStructures_8cpp_source.html">AuxIndexStructures.cpp</a>.</p>
<p>Definition at line <a class="el" href="AuxIndexStructures_8cpp_source.html#l00037">37</a> of file <a class="el" href="AuxIndexStructures_8cpp_source.html">AuxIndexStructures.cpp</a>.</p>
</div>
</div>
......
......@@ -105,7 +105,7 @@ static __device__ void&#160;</td><td class="memItemRight" valign="bottom"><b>loa
struct faiss::gpu::LoadCodeDistances&lt; LookupT, LookupVecT &gt;</h3>
<p>Definition at line <a class="el" href="PQScanMultiPassNoPrecomputed_8cu_source.html#l00049">49</a> of file <a class="el" href="PQScanMultiPassNoPrecomputed_8cu_source.html">PQScanMultiPassNoPrecomputed.cu</a>.</p>
<p>Definition at line <a class="el" href="PQScanMultiPassNoPrecomputed_8cu_source.html#l00053">53</a> of file <a class="el" href="PQScanMultiPassNoPrecomputed_8cu_source.html">PQScanMultiPassNoPrecomputed.cu</a>.</p>
</div><hr/>The documentation for this struct was generated from the following file:<ul>
<li>/data/users/matthijs/github_faiss/faiss/gpu/impl/<a class="el" href="PQScanMultiPassNoPrecomputed_8cu_source.html">PQScanMultiPassNoPrecomputed.cu</a></li>
</ul>
......
......@@ -100,9 +100,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span>&#160;</div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;<span class="preprocessor">#include &lt;gtest/gtest.h&gt;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;</div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;<span class="preprocessor">#include &lt;faiss/IndexIVFPQ.h&gt;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;<span class="preprocessor">#include &lt;faiss/IndexFlat.h&gt;</span></div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;<span class="preprocessor">#include &lt;faiss/utils.h&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;<span class="preprocessor">#include &lt;IndexIVFPQ.h&gt;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;<span class="preprocessor">#include &lt;IndexFlat.h&gt;</span></div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;<span class="preprocessor">#include &lt;utils.h&gt;</span></div>
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160;</div>
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;</div>
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160;<span class="comment">// dimension of the vectors to index</span></div>
......
......@@ -102,9 +102,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;</div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;<span class="preprocessor">#include &lt;gtest/gtest.h&gt;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;</div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;<span class="preprocessor">#include &lt;faiss/IndexIVFPQ.h&gt;</span></div>
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160;<span class="preprocessor">#include &lt;faiss/IndexFlat.h&gt;</span></div>
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;<span class="preprocessor">#include &lt;faiss/index_io.h&gt;</span></div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;<span class="preprocessor">#include &lt;IndexIVFPQ.h&gt;</span></div>
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160;<span class="preprocessor">#include &lt;IndexFlat.h&gt;</span></div>
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;<span class="preprocessor">#include &lt;index_io.h&gt;</span></div>
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160;</div>
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160;TEST(IVFPQ, accuracy) {</div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160;</div>
......
......@@ -20,6 +20,7 @@ import pdb
try:
from swigfaiss_gpu import *
except ImportError as e:
if e.args[0] != 'ImportError: No module named swigfaiss_gpu':
# swigfaiss_gpu is there but failed to load: Warn user about it.
sys.stderr.write("Failed to load GPU Faiss: %s\n" % e.args[0])
......@@ -60,7 +61,7 @@ def handle_Clustering():
handle_Clustering()
def handle_ProductQuantizer():
def handle_Quantizer(the_class):
def replacement_train(self, x):
n, d = x.shape
......@@ -81,12 +82,13 @@ def handle_ProductQuantizer():
self.decode_c(swig_ptr(codes), swig_ptr(x), n)
return x
replace_method(ProductQuantizer, 'train', replacement_train)
replace_method(ProductQuantizer, 'compute_codes', replacement_compute_codes)
replace_method(ProductQuantizer, 'decode', replacement_decode)
replace_method(the_class, 'train', replacement_train)
replace_method(the_class, 'compute_codes', replacement_compute_codes)
replace_method(the_class, 'decode', replacement_decode)
handle_ProductQuantizer()
handle_Quantizer(ProductQuantizer)
handle_Quantizer(ScalarQuantizer)
def handle_Index(the_class):
......@@ -100,7 +102,7 @@ def handle_Index(the_class):
def replacement_add_with_ids(self, x, ids):
n, d = x.shape
assert d == self.d
assert ids.shape == (n, )
assert ids.shape == (n, ), 'not same nb of vectors as ids'
self.add_with_ids_c(n, swig_ptr(x), swig_ptr(ids))
def replacement_train(self, x):
......@@ -110,7 +112,6 @@ def handle_Index(the_class):
self.train_c(n, swig_ptr(x))
def replacement_search(self, x, k):
assert x.flags.contiguous
n, d = x.shape
assert d == self.d
distances = np.empty((n, k), dtype=np.float32)
......@@ -144,6 +145,18 @@ def handle_Index(the_class):
assert x.shape == (n, self.d)
self.update_vectors_c(n, swig_ptr(keys), swig_ptr(x))
def replacement_range_search(self, x, thresh):
n, d = x.shape
assert d == self.d
res = RangeSearchResult(n)
self.range_search_c(n, swig_ptr(x), thresh, res)
# get pointers and copy them
lims = rev_swig_ptr(res.lims, n + 1).copy()
nd = int(lims[-1])
D = rev_swig_ptr(res.distances, nd).copy()
I = rev_swig_ptr(res.labels, nd).copy()
return lims, D, I
replace_method(the_class, 'add', replacement_add)
replace_method(the_class, 'add_with_ids', replacement_add_with_ids)
replace_method(the_class, 'train', replacement_train)
......@@ -151,6 +164,7 @@ def handle_Index(the_class):
replace_method(the_class, 'remove_ids', replacement_remove_ids)
replace_method(the_class, 'reconstruct', replacement_reconstruct)
replace_method(the_class, 'reconstruct_n', replacement_reconstruct_n)
replace_method(the_class, 'range_search', replacement_range_search)
replace_method(the_class, 'update_vectors', replacement_update_vectors,
ignore_missing=True)
......
......@@ -465,7 +465,12 @@ GpuIndexIVFPQ::verifySettings_() const {
IVFPQ::isSupportedNoPrecomputedSubDimSize(
this->d / subQuantizers_),
"Number of dimensions per sub-quantizer (%d) "
"is unsupported with precomputed codes",
"is not currently supported without precomputed codes. "
"Only 1, 2, 3, 4, 6, 8, 10, 12, 16, 20, 24, 28, 32 dims "
"per sub-quantizer are currently supported with no "
"precomputed codes. "
"Precomputed codes supports any number of dimensions, but "
"will involve memory overheads.",
this->d / subQuantizers_);
// TODO: fully implement METRIC_INNER_PRODUCT
......
......@@ -495,6 +495,15 @@ runPQCodeDistances(Tensor<float, 3, true>& pqCentroids,
case 16:
CODE_DISTANCE(16);
break;
case 20:
CODE_DISTANCE(20);
break;
case 24:
CODE_DISTANCE(24);
break;
case 28:
CODE_DISTANCE(28);
break;
case 32:
CODE_DISTANCE(32);
break;
......
......@@ -25,6 +25,7 @@
namespace faiss { namespace gpu {
// This must be kept in sync with PQCodeDistances.cu
bool isSupportedNoPrecomputedSubDimSize(int dims) {
switch (dims) {
case 1:
......@@ -36,6 +37,9 @@ bool isSupportedNoPrecomputedSubDimSize(int dims) {
case 10:
case 12:
case 16:
case 20:
case 24:
case 28:
case 32:
return true;
default:
......
......@@ -26,11 +26,11 @@ void pickEncoding(int& codes, int& dim) {
28, 32, 40, 48, 56, 64, 96
};
std::vector<int> dimSizes{4, 8, 16, 32};
codes = codeSizes[faiss::gpu::randVal(0, codeSizes.size() - 1)];
// Above 32 doesn't work with no precomputed codes
std::vector<int> dimSizes{4, 8, 10, 12, 16, 20, 24, 28, 32};
while (true) {
codes = codeSizes[faiss::gpu::randVal(0, codeSizes.size() - 1)];
dim = codes * dimSizes[faiss::gpu::randVal(0, dimSizes.size() - 1)];
// for such a small test, super-low or high dim is more likely to
......
# Copyright (c) 2015-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the CC-by-NC license found in the
# This source code is licensed under the BSD+Patents license found in the
# LICENSE file in the root directory of this source tree.
#! /usr/bin/env python2
......
This diff is collapsed.
This diff is collapsed.
......@@ -15,13 +15,15 @@
// SWIGPYTHON: Python-specific code
// GPU_WRAPPER: also compile interfaces for GPU.
#ifdef GPU_WRAPPER
%module swigfaiss_gpu;
#else
%module swigfaiss;
#endif
#pragma SWIG nowarn=321
#pragma SWIG nowarn=403
typedef unsigned long uint64_t;
typedef uint64_t size_t;
typedef int int32_t ;
......@@ -69,13 +71,11 @@ extern "C" {
#include "IndexFlat.h"
#include "VectorTransform.h"
#include "IndexLSH.h"
#include "IndexPQ.h"
#include "IndexIVF.h"
#include "IndexIVFPQ.h"
#include "IndexScalarQuantizer.h"
#include "MetaIndexes.h"
#include "FaissAssert.h"
......@@ -85,7 +85,6 @@ extern "C" {
#include "Heap.h"
#include "AuxIndexStructures.h"
#include "Clustering.h"
#include "hamming.h"
......@@ -238,7 +237,6 @@ int get_num_gpus()
%include "ProductQuantizer.h"
%include "VectorTransform.h"
%include "IndexFlat.h"
%include "IndexLSH.h"
%include "PolysemousTraining.h"
......@@ -252,11 +250,6 @@ int get_num_gpus()
%include "MetaIndexes.h"
......@@ -583,6 +576,8 @@ PyObject * rev_swig_ptr(ctype *src, size_t size);
REV_SWIG_PTR(float, NPY_FLOAT32);
REV_SWIG_PTR(int, NPY_INT32);
REV_SWIG_PTR(unsigned char, NPY_UINT8);
REV_SWIG_PTR(unsigned long, NPY_UINT64);
REV_SWIG_PTR(long, NPY_INT64);
#endif
......@@ -701,9 +696,6 @@ int * cast_integer_to_int_ptr (long x) {
%include "AuxIndexStructures.h"
%{
// may be useful for lua code launched in background from shell
......@@ -714,3 +706,6 @@ void ignore_SIGTTIN() {
%}
void ignore_SIGTTIN();
// End of file...
......@@ -13,22 +13,24 @@ import unittest
import faiss
def get_dataset(d, nb, nt, nq):
rs = np.random.RandomState(123)
xb = rs.rand(nb, d).astype('float32')
xt = rs.rand(nt, d).astype('float32')
xq = rs.rand(nq, d).astype('float32')
return (xt, xb, xq)
class EvalIVFPQAccuracy(unittest.TestCase):
def get_dataset(self):
def test_IndexIVFPQ(self):
d = 64
nb = 1000
nt = 1500
nq = 200
np.random.seed(123)
xb = np.random.random(size=(nb, d)).astype('float32')
xt = np.random.random(size=(nt, d)).astype('float32')
xq = np.random.random(size=(nq, d)).astype('float32')
return (xt, xb, xq)
def test_IndexIVFPQ(self):
(xt, xb, xq) = self.get_dataset()
(xt, xb, xq) = get_dataset(d, nb, nt, nq)
d = xt.shape[1]
gt_index = faiss.IndexFlatL2(d)
......@@ -54,12 +56,11 @@ class TestMultiIndexQuantizer(unittest.TestCase):
# verify codepath for k = 1 and k > 1
d = 64
nb = 0
nt = 1500
nq = 200
np.random.seed(123)
xt = np.random.random(size=(nt, d)).astype('float32')
xq = np.random.random(size=(nq, d)).astype('float32')
(xt, xb, xq) = get_dataset(d, nb, nt, nq)
miq = faiss.MultiIndexQuantizer(d, 2, 6)
......@@ -81,11 +82,7 @@ class TestScalarQuantizer(unittest.TestCase):
nq = 200
nb = 10000
np.random.seed(123)
xt = np.random.random(size=(nt, d)).astype('float32')
xq = np.random.random(size=(nq, d)).astype('float32')
xb = np.random.random(size=(nb, d)).astype('float32')
(xt, xb, xq) = get_dataset(d, nb, nt, nq)
# common quantizer
quantizer = faiss.IndexFlatL2(d)
......@@ -131,11 +128,7 @@ class TestScalarQuantizer(unittest.TestCase):
nq = 200
nb = 10000
np.random.seed(123)
xt = np.random.random(size=(nt, d)).astype('float32')
xq = np.random.random(size=(nq, d)).astype('float32')
xb = np.random.random(size=(nb, d)).astype('float32')
(xt, xb, xq) = get_dataset(d, nb, nt, nq)
index_gt = faiss.IndexFlatL2(d)
index_gt.add(xb)
......@@ -159,6 +152,34 @@ class TestScalarQuantizer(unittest.TestCase):
self.assertGreaterEqual(nok['QT_4bit'], nok['QT_4bit_uniform'])
class TestRangeSearch(unittest.TestCase):
def test_range_search(self):
d = 4
nt = 100
nq = 10
nb = 50
(xt, xb, xq) = get_dataset(d, nb, nt, nq)
index = faiss.IndexFlatL2(d)
index.add(xb)
Dref, Iref = index.search(xq, 5)
thresh = 0.1 # *squared* distance
lims, D, I = index.range_search(xq, thresh)
for i in range(nq):
Iline = I[lims[i]:lims[i + 1]]
Dline = D[lims[i]:lims[i + 1]]
for j, dis in zip(Iref[i], Dref[i]):
if dis < thresh:
li, = np.where(Iline == j)
self.assertTrue(li.size == 1)
idx = li[0]
self.assertGreaterEqual(1e-4, abs(Dline[idx] - dis))
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment