2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 tflchef::TensorType as_tflchef_type(const tflite::TensorType type)
26 case tflite::TensorType_FLOAT32:
27 return tflchef::FLOAT32;
28 case tflite::TensorType_INT32:
29 return tflchef::INT32;
30 case tflite::TensorType_INT64:
31 return tflchef::INT64;
32 case tflite::TensorType_UINT8:
33 return tflchef::UINT8;
34 case tflite::TensorType_BOOL:
36 case tflite::TensorType_INT8:
38 case tflite::TensorType_INT16:
39 return tflchef::INT16;
40 case tflite::TensorType_FLOAT16:
41 return tflchef::FLOAT16;
42 // TODO handle other types
44 // TensorType_COMPLEX64
46 throw std::runtime_error{"unsupported tensor type"};
50 tflchef::Activation as_tflchef_activation(const tflite::ActivationFunctionType type)
54 case tflite::ActivationFunctionType_NONE:
56 case tflite::ActivationFunctionType_RELU:
58 case tflite::ActivationFunctionType_RELU_N1_TO_1:
59 return tflchef::RELU_N1_TO_1;
60 case tflite::ActivationFunctionType_RELU6:
61 return tflchef::RELU6;
62 case tflite::ActivationFunctionType_TANH:
64 case tflite::ActivationFunctionType_SIGN_BIT:
65 return tflchef::SIGN_BIT;
67 throw std::runtime_error{"unsupported activation type"};
71 tflchef::Padding as_tflchef_padding(const tflite::Padding padding)
75 case tflite::Padding_SAME:
77 case tflite::Padding_VALID:
78 return tflchef::VALID;
80 throw std::runtime_error{"unsupported padding"};
84 tflchef::MirrorPadMode as_tflchef_mirrorpadmode(const tflite::MirrorPadMode mode)
88 case tflite::MirrorPadMode_REFLECT:
89 return tflchef::REFLECT;
90 case tflite::MirrorPadMode_SYMMETRIC:
91 return tflchef::SYMMETRIC;
93 throw std::runtime_error{"Unknown mirrorpad mode"};
97 tflchef::DimensionType as_tflchef_sparse_dim_type(const tflite::DimensionType type)
101 case tflite::DimensionType_DENSE:
102 return tflchef::DimensionType::DENSE;
103 case tflite::DimensionType_SPARSE_CSR:
104 return tflchef::DimensionType::SPARSE_CSR;
106 throw std::runtime_error("unsupported sparse dimension type");
110 tflchef::SparseIndexVecType as_tflchef_sparse_idx_vec_type(const tflite::SparseIndexVector type)
114 case tflite::SparseIndexVector_NONE:
115 return tflchef::SparseIndexVecType::SparseIdxVecType_NONE;
116 case tflite::SparseIndexVector_Int32Vector:
117 return tflchef::SparseIndexVecType::INT32VEC;
118 case tflite::SparseIndexVector_Uint16Vector:
119 return tflchef::SparseIndexVecType::UINT16VEC;
120 case tflite::SparseIndexVector_Uint8Vector:
121 return tflchef::SparseIndexVecType::UINT8VEC;
123 throw std::runtime_error("unsupported sparse index vector type");
127 } // namespace tflchef