1 /* 2 * Copyright (C) 2018 The Android Open Source Project 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 17 #include "lang_id/common/embedding-network-params.h" 18 19 #include "lang_id/common/lite_base/logging.h" 20 21 namespace libtextclassifier3 { 22 ParseQuantizationType(const string & s)23QuantizationType ParseQuantizationType(const string &s) { 24 if (s == "NONE") { 25 return QuantizationType::NONE; 26 } 27 if (s == "UINT8") { 28 return QuantizationType::UINT8; 29 } 30 if (s == "UINT4") { 31 return QuantizationType::UINT4; 32 } 33 if (s == "FLOAT16") { 34 return QuantizationType::FLOAT16; 35 } 36 SAFTM_LOG(FATAL) << "Unsupported quantization type: " << s; 37 38 // Execution should never reach this point; just to keep the compiler happy. 39 // TODO(salcianu): implement SAFTM_LOG(FATAL) in a way that doesn't require 40 // this trick. 41 return QuantizationType::NONE; 42 } 43 44 } // namespace nlp_saft 45