-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: #3351 Reviewed By: junjieqi Differential Revision: D56732720
- Loading branch information
1 parent
c92b480
commit f0aa03f
Showing
5 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <faiss/Clustering.h> | ||
#include <faiss/IndexFlat.h> | ||
#include <faiss/impl/AuxIndexStructures.h> | ||
#include <faiss/impl/FaissException.h> | ||
#include <faiss/utils/random.h> | ||
|
||
TEST(TestCallback, timeout) { | ||
int n = 1000000; | ||
int k = 100; | ||
int d = 128; | ||
int niter = 10; | ||
int seed = 42; | ||
|
||
std::vector<float> vecs(n * d); | ||
faiss::float_rand(vecs.data(), vecs.size(), seed); | ||
|
||
auto index(new faiss::IndexFlat(d)); | ||
|
||
faiss::ClusteringParameters cp; | ||
cp.niter = niter; | ||
cp.verbose = false; | ||
|
||
faiss::Clustering kmeans(d, k, cp); | ||
|
||
auto tc(new faiss::TimeoutCallback()); | ||
faiss::InterruptCallback::instance.reset(tc); | ||
tc->set_timeout(0.010); | ||
EXPECT_THROW(kmeans.train(n, vecs.data(), *index), faiss::FaissException); | ||
delete index; | ||
} |