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_INT16:
37 return tflchef::INT16;
38 case tflite::TensorType_FLOAT16:
39 return tflchef::FLOAT16;
40 // TODO handle other types
42 // TensorType_COMPLEX64
44 throw std::runtime_error{"unsupported tensor type"};
48 tflchef::Activation as_tflchef_activation(const tflite::ActivationFunctionType type)
52 case tflite::ActivationFunctionType_NONE:
54 case tflite::ActivationFunctionType_RELU:
56 case tflite::ActivationFunctionType_RELU_N1_TO_1:
57 return tflchef::RELU_N1_TO_1;
58 case tflite::ActivationFunctionType_RELU6:
59 return tflchef::RELU6;
60 case tflite::ActivationFunctionType_TANH:
62 case tflite::ActivationFunctionType_SIGN_BIT:
63 return tflchef::SIGN_BIT;
65 throw std::runtime_error{"unsupported activation type"};
69 tflchef::Padding as_tflchef_padding(const tflite::Padding padding)
73 case tflite::Padding_SAME:
75 case tflite::Padding_VALID:
76 return tflchef::VALID;
78 throw std::runtime_error{"unsupported padding"};
82 tflchef::MirrorPadMode as_tflchef_mirrorpadmode(const tflite::MirrorPadMode mode)
86 case tflite::MirrorPadMode_REFLECT:
87 return tflchef::REFLECT;
88 case tflite::MirrorPadMode_SYMMETRIC:
89 return tflchef::SYMMETRIC;
91 throw std::runtime_error{"Unknown mirrorpad mode"};
95 tflchef::DimensionType as_tflchef_sparse_dim_type(const tflite::DimensionType type)
99 case tflite::DimensionType_DENSE:
100 return tflchef::DimensionType::DENSE;
101 case tflite::DimensionType_SPARSE_CSR:
102 return tflchef::DimensionType::SPARSE_CSR;
104 throw std::runtime_error("unsupported sparse dimension type");
108 tflchef::SparseIndexVecType as_tflchef_sparse_idx_vec_type(const tflite::SparseIndexVector type)
112 case tflite::SparseIndexVector_NONE:
113 return tflchef::SparseIndexVecType::SparseIdxVecType_NONE;
114 case tflite::SparseIndexVector_Int32Vector:
115 return tflchef::SparseIndexVecType::INT32VEC;
116 case tflite::SparseIndexVector_Uint16Vector:
117 return tflchef::SparseIndexVecType::UINT16VEC;
118 case tflite::SparseIndexVector_Uint8Vector:
119 return tflchef::SparseIndexVecType::UINT8VEC;
121 throw std::runtime_error("unsupported sparse index vector type");
125 } // namespace tflchef