9 #include "BinaryFlatIndex.cuh"
10 #include "BinaryDistance.cuh"
11 #include "../utils/DeviceUtils.h"
12 #include "../GpuResources.h"
14 namespace faiss {
namespace gpu {
16 BinaryFlatIndex::BinaryFlatIndex(GpuResources* res,
24 FAISS_ASSERT(dim % 8 == 0);
32 int BinaryFlatIndex::getDim()
const {
38 rawData_.reserve(numVecs * (dim_ / 8) *
sizeof(
unsigned int), stream);
53 runBinaryDistance(vectors_,
64 cudaStream_t stream) {
69 rawData_.append((
char*) data,
70 (
size_t) (dim_ / 8) * numVecs *
sizeof(
unsigned char),
77 (
unsigned char*) rawData_.data(), {(int) num_, (dim_ / 8)}, space_);
78 vectors_ = std::move(vectors);
void reset()
Free all storage.
cudaStream_t getDefaultStreamCurrentDevice()
Calls getDefaultStream with the current device.
__host__ __device__ IndexT getSize(int i) const
int getSize() const
Returns the number of vectors we contain.
void reserve(size_t numVecs, cudaStream_t stream)
Reserve storage that can contain at least this many vectors.
Tensor< unsigned char, 2, true > & getVectorsRef()
Returns a reference to our vectors currently in use.
void add(const unsigned char *data, int numVecs, cudaStream_t stream)