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