Commit 3a0cc24d authored by 蔡宇东's avatar 蔡宇东
Browse files

#331 update exception handle when search fail

parent 9a467fb1
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -132,13 +132,8 @@ GPUIVF::search_impl(int64_t n, const float* data, int64_t k, float* distances, i
        auto search_cfg = std::dynamic_pointer_cast<IVFCfg>(cfg);
        device_index->nprobe = search_cfg->nprobe;
        //assert(device_index->getNumProbes() == search_cfg->nprobe);

        try {
        ResScope rs(res_, gpu_id_);
        device_index->search(n, (float*)data, k, distances, labels);
        } catch (faiss::FaissException& e) {
            KNOWHERE_THROW_MSG(e.what());
        }
    } else {
        KNOWHERE_THROW_MSG("Not a GpuIndexIVF type.");
    }
+43 −36
Original line number Diff line number Diff line
@@ -119,6 +119,7 @@ IVF::Search(const DatasetPtr& dataset, const Config& config) {

    GETTENSOR(dataset)

    try {
        auto elems = rows * search_cfg->k;
        auto res_ids = (int64_t *) malloc(sizeof(int64_t) * elems);
        auto res_dis = (float *) malloc(sizeof(float) * elems);
@@ -155,6 +156,12 @@ IVF::Search(const DatasetPtr& dataset, const Config& config) {
        //    std::vector<ArrayPtr> array{ids, dists};

        return std::make_shared<Dataset>((void *) res_ids, (void *) res_dis);

    } catch (faiss::FaissException& e) {
        KNOWHERE_THROW_MSG(e.what());
    } catch (std::exception& e) {
        KNOWHERE_THROW_MSG(e.what());
    }
}

void