1/**
2 * Copyright 2021 Alibaba, Inc. and its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15
16 * \author Haichao.chc
17 * \date Jun 2021
18 * \brief Helper class for transforming types
19 */
20
21#include "index_helper.h"
22
23namespace proxima {
24namespace be {
25namespace index {
26
27FeatureTypes IndexHelper::GetProximaFeatureType(DataTypes data_type) {
28 switch (data_type) {
29 case DataTypes::VECTOR_BINARY32:
30 return FeatureTypes::FT_BINARY32;
31 case DataTypes::VECTOR_BINARY64:
32 return FeatureTypes::FT_BINARY64;
33 case DataTypes::VECTOR_FP16:
34 return FeatureTypes::FT_FP16;
35 case DataTypes::VECTOR_FP32:
36 return FeatureTypes::FT_FP32;
37 case DataTypes::VECTOR_FP64:
38 return FeatureTypes::FT_FP64;
39 case DataTypes::VECTOR_INT4:
40 return FeatureTypes::FT_INT4;
41 case DataTypes::VECTOR_INT8:
42 return FeatureTypes::FT_INT8;
43 case DataTypes::VECTOR_INT16:
44 return FeatureTypes::FT_INT16;
45 default:
46 return FeatureTypes::FT_UNDEFINED;
47 }
48}
49
50QuantizeTypes IndexHelper::GetQuantizeType(const std::string &quantize_type) {
51 if (quantize_type == "DT_VECTOR_FP16") {
52 return QuantizeTypes::VECTOR_FP16;
53 } else if (quantize_type == "DT_VECTOR_INT8") {
54 return QuantizeTypes::VECTOR_INT8;
55 } else if (quantize_type == "DT_VECTOR_INT4") {
56 return QuantizeTypes::VECTOR_INT4;
57 } else {
58 return QuantizeTypes::UNDEFINED;
59 }
60}
61
62} // end namespace index
63} // namespace be
64} // end namespace proxima
65