mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
train func add catch excetpion (#2096)
* train func add catch excetpion Signed-off-by: shana0325 <645842705@qq.com> * Fix lint error Signed-off-by: JinHai-CN <hai.jin@zilliz.com> Co-authored-by: JinHai-CN <hai.jin@zilliz.com>
This commit is contained in:
parent
d22f3c2c5f
commit
53133aafac
@ -76,17 +76,21 @@ IndexHNSW::Load(const BinarySet& index_binary) {
|
||||
|
||||
void
|
||||
IndexHNSW::Train(const DatasetPtr& dataset_ptr, const Config& config) {
|
||||
GETTENSOR(dataset_ptr)
|
||||
try {
|
||||
GETTENSOR(dataset_ptr)
|
||||
|
||||
hnswlib::SpaceInterface<float>* space;
|
||||
if (config[Metric::TYPE] == Metric::L2) {
|
||||
space = new hnswlib::L2Space(dim);
|
||||
} else if (config[Metric::TYPE] == Metric::IP) {
|
||||
space = new hnswlib::InnerProductSpace(dim);
|
||||
normalize = true;
|
||||
hnswlib::SpaceInterface<float>* space;
|
||||
if (config[Metric::TYPE] == Metric::L2) {
|
||||
space = new hnswlib::L2Space(dim);
|
||||
} else if (config[Metric::TYPE] == Metric::IP) {
|
||||
space = new hnswlib::InnerProductSpace(dim);
|
||||
normalize = true;
|
||||
}
|
||||
index_ = std::make_shared<hnswlib::HierarchicalNSW<float>>(space, rows, config[IndexParams::M].get<int64_t>(),
|
||||
config[IndexParams::efConstruction].get<int64_t>());
|
||||
} catch (std::exception& e) {
|
||||
KNOWHERE_THROW_MSG(e.what());
|
||||
}
|
||||
index_ = std::make_shared<hnswlib::HierarchicalNSW<float>>(space, rows, config[IndexParams::M].get<int64_t>(),
|
||||
config[IndexParams::efConstruction].get<int64_t>());
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user