mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-06 02:42:53 +08:00
MS372 dev clone index and get index deviceId
Former-commit-id: adc85e54cc20c644f9d39df823c8b1b539ec7a19
This commit is contained in:
parent
a1d37d6c4f
commit
b3cc7de2c0
@ -8,6 +8,7 @@
|
||||
#include "knowhere/index/vector_index/idmap.h"
|
||||
#include "knowhere/index/vector_index/gpu_ivf.h"
|
||||
#include "knowhere/common/exception.h"
|
||||
#include "knowhere/index/vector_index/cloner.h"
|
||||
|
||||
#include "vec_impl.h"
|
||||
#include "data_transfer.h"
|
||||
@ -152,6 +153,22 @@ VecIndexPtr VecIndexImpl::CopyToCpu(const Config &cfg) {
|
||||
return std::make_shared<VecIndexImpl>(cpu_index, type);
|
||||
}
|
||||
|
||||
VecIndexPtr VecIndexImpl::Clone() {
|
||||
auto clone_index = std::make_shared<VecIndexImpl>(index_->Clone(), type);
|
||||
clone_index->dim = dim;
|
||||
return clone_index;
|
||||
}
|
||||
|
||||
int64_t VecIndexImpl::GetDeviceId() {
|
||||
if (auto device_idx = std::dynamic_pointer_cast<GPUIndex>(index_)){
|
||||
return device_idx->GetGpuDevice();
|
||||
}
|
||||
else {
|
||||
return -1; // -1 == cpu
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
float *BFIndex::GetRawVectors() {
|
||||
auto raw_index = std::dynamic_pointer_cast<IDMAP>(index_);
|
||||
if (raw_index) { return raw_index->GetRawVectors(); }
|
||||
|
||||
@ -33,6 +33,8 @@ class VecIndexImpl : public VecIndex {
|
||||
server::KnowhereError Add(const long &nb, const float *xb, const long *ids, const Config &cfg) override;
|
||||
zilliz::knowhere::BinarySet Serialize() override;
|
||||
server::KnowhereError Load(const zilliz::knowhere::BinarySet &index_binary) override;
|
||||
VecIndexPtr Clone() override;
|
||||
int64_t GetDeviceId() override;
|
||||
server::KnowhereError Search(const long &nq, const float *xq, float *dist, long *ids, const Config &cfg) override;
|
||||
|
||||
protected:
|
||||
|
||||
@ -63,6 +63,10 @@ class VecIndex {
|
||||
|
||||
virtual VecIndexPtr CopyToCpu(const Config &cfg = Config()) = 0;
|
||||
|
||||
virtual VecIndexPtr Clone() = 0;
|
||||
|
||||
virtual int64_t GetDeviceId() = 0;
|
||||
|
||||
virtual IndexType GetType() = 0;
|
||||
|
||||
virtual int64_t Dimension() = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user