milvus/core/unittest/scheduler/test_optimizer.cpp
groot a08b51c2b6
merge json to master to get docker image (#1500)
* General proto api for NNS libraries

Signed-off-by: groot <yihua.mo@zilliz.com>

* refactor confadapter

Signed-off-by: Nicky <nicky.xj.lin@gmail.com>

* fix unittest failures

Signed-off-by: groot <yihua.mo@zilliz.com>

* update test_add

Signed-off-by: zhenwu <zw@zilliz.com>

* update knowhere

Signed-off-by: Nicky <nicky.xj.lin@gmail.com>

* update test cases

Signed-off-by: Xiaohai Xu <xiaohaix@student.unimelb.edu.au>

* Update cases

* C++ sdk for json parameters

Signed-off-by: groot <yihua.mo@zilliz.com>

* update unittest

Signed-off-by: Nicky <nicky.xj.lin@gmail.com>

* fix unittest failures

Signed-off-by: groot <yihua.mo@zilliz.com>

* fix case

Signed-off-by: del-zhenwu <zw@zilliz.com>

* modify test_index.py

Signed-off-by: shengjh <jianghong.sheng@zilliz.com>

* update

Signed-off-by: Nicky <nicky.xj.lin@gmail.com>

* update sptag

Signed-off-by: Nicky <nicky.xj.lin@gmail.com>

* update...

Signed-off-by: Nicky <nicky.xj.lin@gmail.com>

* Build Pass

Signed-off-by: xiaojun.lin <xiaojun.lin@zilliz.com>

* knowhere/wrapper ut pass

Signed-off-by: xiaojun.lin <xiaojun.lin@zilliz.com>

* update util

Signed-off-by: Xiaohai Xu <xiaohaix@student.unimelb.edu.au>

* fix wal case

Signed-off-by: del-zhenwu <zw@zilliz.com>

* modify test_search_vectors

Signed-off-by: shengjh <jianghong.sheng@zilliz.com>

* update ci

Signed-off-by: del-zhenwu <zw@zilliz.com>

* update util

Signed-off-by: Xiaohai Xu <xiaohaix@student.unimelb.edu.au>

* modify test_search_vectoes

Signed-off-by: shengjh <jianghong.sheng@zilliz.com>

* add hnsw in http module & modify index apis

Signed-off-by: Yhz <yinghao.zou@zilliz.com>

* modify search in http module

Signed-off-by: Yhz <yinghao.zou@zilliz.com>

* fix build error

Signed-off-by: groot <yihua.mo@zilliz.com>

* fix typo in test_index and test_search

Signed-off-by: shengjh <jianghong.sheng@zilliz.com>

* update...

Signed-off-by: Nicky <nicky.xj.lin@gmail.com>

* index apis in http module done

Signed-off-by: Yhz <yinghao.zou@zilliz.com>

* fix build index bug

Signed-off-by: groot <yihua.mo@zilliz.com>

* search apis unittest pass

Signed-off-by: Yhz <yinghao.zou@zilliz.com>

* web test pass

Signed-off-by: Yhz <yinghao.zou@zilliz.com>

* update confadapter

Signed-off-by: Nicky <nicky.xj.lin@gmail.com>

* update util

Signed-off-by: Xiaohai Xu <xiaohaix@student.unimelb.edu.au>

* code format

Signed-off-by: groot <yihua.mo@zilliz.com>

* code format

Signed-off-by: groot <yihua.mo@zilliz.com>

* fix vectors results bug (fix #1476)

Signed-off-by: Yhz <yinghao.zou@zilliz.com>

* clang format

Signed-off-by: Yhz <yinghao.zou@zilliz.com>

* update test

Signed-off-by: shengjh <jianghong.sheng@zilliz.com>

* fix unittest

Signed-off-by: groot <yihua.mo@zilliz.com>

* add test_config

Signed-off-by: Xiaohai Xu <xiaohaix@student.unimelb.edu.au>

* add log

Signed-off-by: groot <yihua.mo@zilliz.com>

* fix a build error

Signed-off-by: groot <yihua.mo@zilliz.com>

* add invalid param search test

Signed-off-by: shengjh <jianghong.sheng@zilliz.com>

* fix range check

Signed-off-by: Nicky <nicky.xj.lin@gmail.com>

* cpmpact/flush case passed

Signed-off-by: del-zhenwu <zhenxiang.li@zilliz.com>

* fix unittest failures

Signed-off-by: groot <yihua.mo@zilliz.com>

* fix unittest failures

Signed-off-by: groot <yihua.mo@zilliz.com>

* fix unittest failures

Signed-off-by: groot <yihua.mo@zilliz.com>

* validate json parameters in request

Signed-off-by: groot <yihua.mo@zilliz.com>

* add unittest cases

Signed-off-by: groot <yihua.mo@zilliz.com>

* update test index/search

Signed-off-by: shengjh <jianghong.sheng@zilliz.com>

* update test_config

Signed-off-by: sahuang <xiaohaix@student.unimelb.edu.au>

* fix

Signed-off-by: shengjh <jianghong.sheng@zilliz.com>

* support nsg and ivf-nlist

Signed-off-by: Nicky <nicky.xj.lin@gmail.com>

* update

Signed-off-by: xiaojun.lin <xiaojun.lin@zilliz.com>

* fix validation bug

Signed-off-by: groot <yihua.mo@zilliz.com>

* fix python test bug

Signed-off-by: groot <yihua.mo@zilliz.com>

* fix python test bug

Signed-off-by: groot <yihua.mo@zilliz.com>

* fix python test bug

Signed-off-by: groot <yihua.mo@zilliz.com>

* fix python test bug

Signed-off-by: groot <yihua.mo@zilliz.com>

* code format

Signed-off-by: groot <yihua.mo@zilliz.com>

* fix python test failure

Signed-off-by: groot <yihua.mo@zilliz.com>

* remove rnsg cases

Signed-off-by: zhenwu <zw@zilliz.com>

* fix python test failure

Signed-off-by: groot <yihua.mo@zilliz.com>

* Update changelog

Signed-off-by: JinHai-CN <hai.jin@zilliz.com>

* Fix typo

Signed-off-by: JinHai-CN <hai.jin@zilliz.com>

* add pq to test_index && multithread test

Signed-off-by: shengjh <jianghong.sheng@zilliz.com>

* add pq to test_search

Signed-off-by: shengjh <jianghong.sheng@zilliz.com>

* Fix format

Signed-off-by: JinHai-CN <hai.jin@zilliz.com>

* Update CHANGELOG

Signed-off-by: JinHai-CN <hai.jin@zilliz.com>

* Fix compiling error

Signed-off-by: JinHai-CN <hai.jin@zilliz.com>

* Fix compiling error

Signed-off-by: JinHai-CN <hai.jin@zilliz.com>

* fix config bug

Signed-off-by: groot <yihua.mo@zilliz.com>

* code format

Signed-off-by: groot <yihua.mo@zilliz.com>

* fix config test

Signed-off-by: xiaojun.lin <xiaojun.lin@zilliz.com>

* Update CHANGELOG.md

Signed-off-by: JinHai-CN <hai.jin@zilliz.com>

* Update CHANGELOG.md

Signed-off-by: JinHai-CN <hai.jin@zilliz.com>

* disable config test case

Signed-off-by: zhenwu <zw@zilliz.com>

Co-authored-by: Nicky <nicky.xj.lin@gmail.com>
Co-authored-by: zhenwu <zw@zilliz.com>
Co-authored-by: Xiaohai Xu <xiaohaix@student.unimelb.edu.au>
Co-authored-by: shengjh <jianghong.sheng@zilliz.com>
Co-authored-by: xiaojun.lin <xiaojun.lin@zilliz.com>
Co-authored-by: Yhz <yinghao.zou@zilliz.com>
Co-authored-by: del-zhenwu <zhenxiang.li@zilliz.com>
Co-authored-by: JinHai-CN <hai.jin@zilliz.com>
2020-03-07 15:23:34 +08:00

98 lines
4.2 KiB
C++

// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License.
#include <fiu-local.h>
#include <fiu-control.h>
#include <gtest/gtest.h>
#include "scheduler/task/BuildIndexTask.h"
#include "scheduler/task/SearchTask.h"
#include "scheduler/optimizer/FaissIVFFlatPass.h"
#include "scheduler/SchedInst.h"
#include "scheduler/resource/CpuResource.h"
#include "scheduler/optimizer/BuildIndexPass.h"
#include "scheduler/optimizer/FaissFlatPass.h"
#include "scheduler/optimizer/FaissIVFPQPass.h"
#include "scheduler/optimizer/FaissIVFSQ8HPass.h"
#include "scheduler/optimizer/FaissIVFSQ8Pass.h"
#include "scheduler/optimizer/FallbackPass.h"
namespace milvus {
namespace scheduler {
#ifdef MILVUS_GPU_VERSION
TEST(OptimizerTest, TEST_OPTIMIZER) {
BuildIndexPass build_index_pass;
fiu_init(0);
fiu_enable("BuildIndexPass.Init.get_config_fail", 1, NULL, 0);
ASSERT_ANY_THROW(build_index_pass.Init(););
fiu_disable("BuildIndexPass.Init.get_config_fail");
auto build_index_task = std::make_shared<XBuildIndexTask>(nullptr, nullptr);
fiu_enable("BuildIndexPass.Run.empty_gpu_ids", 1, NULL, 0);
ASSERT_FALSE(build_index_pass.Run(build_index_task));
fiu_disable("BuildIndexPass.Run.empty_gpu_ids");
FaissFlatPass faiss_flat_pass;
fiu_enable("check_config_gpu_search_threshold_fail", 1, NULL, 0);
fiu_enable("get_gpu_config_search_resources.disable_gpu_resource_fail", 1, NULL, 0);
ASSERT_ANY_THROW(faiss_flat_pass.Init(););
fiu_disable("get_gpu_config_search_resources.disable_gpu_resource_fail");
fiu_disable("check_config_gpu_search_threshold_fail");
FaissIVFFlatPass faiss_ivf_flat_pass;
fiu_enable("check_config_gpu_search_threshold_fail", 1, NULL, 0);
fiu_enable("get_gpu_config_search_resources.disable_gpu_resource_fail", 1, NULL, 0);
ASSERT_ANY_THROW(faiss_ivf_flat_pass.Init(););
fiu_disable("get_gpu_config_search_resources.disable_gpu_resource_fail");
fiu_disable("check_config_gpu_search_threshold_fail");
FaissIVFPQPass faiss_ivf_pq_pass;
fiu_enable("check_config_gpu_search_threshold_fail", 1, NULL, 0);
fiu_enable("get_gpu_config_search_resources.disable_gpu_resource_fail", 1, NULL, 0);
ASSERT_ANY_THROW(faiss_ivf_pq_pass.Init(););
fiu_disable("get_gpu_config_search_resources.disable_gpu_resource_fail");
fiu_disable("check_config_gpu_search_threshold_fail");
auto file = std::make_shared<TableFileSchema>();
file->engine_type_ = (int)engine::EngineType::FAISS_IVFFLAT;
file->index_params_ = "{ \"nlist\": 100 }";
file->dimension_ = 64;
auto search_task = std::make_shared<XSearchTask>(nullptr, file, nullptr);
ASSERT_FALSE(faiss_ivf_pq_pass.Run(search_task));
FaissIVFSQ8HPass faiss_ivf_q8h_pass;
fiu_enable("check_config_gpu_search_threshold_fail", 1, NULL, 0);
faiss_ivf_q8h_pass.Init();
fiu_disable("check_config_gpu_search_threshold_fail");
auto search_task2 = std::make_shared<XSearchTask>(nullptr, file, nullptr);
ASSERT_FALSE(faiss_ivf_q8h_pass.Run(build_index_task));
ASSERT_FALSE(faiss_ivf_q8h_pass.Run(search_task2));
FaissIVFSQ8Pass faiss_ivf_q8_pass;
fiu_enable("check_config_gpu_search_threshold_fail", 1, NULL, 0);
fiu_enable("get_gpu_config_search_resources.disable_gpu_resource_fail", 1, NULL, 0);
ASSERT_ANY_THROW(faiss_ivf_q8_pass.Init(););
fiu_disable("get_gpu_config_search_resources.disable_gpu_resource_fail");
fiu_disable("check_config_gpu_search_threshold_fail");
FallbackPass fall_back_pass;
fall_back_pass.Init();
auto task = std::make_shared<XBuildIndexTask>(nullptr, nullptr);
ResMgrInst::GetInstance()->Add(std::make_shared<CpuResource>("name1", 1, true));
fall_back_pass.Run(task);
}
#endif
} // namespace scheduler
} // namespace milvus