ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Convert.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. 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
17#include "Convert.h"
18
19namespace circlechef
20{
21
22circlechef::TensorType as_circlechef_type(const circle::TensorType type)
23{
24 switch (type)
25 {
26 case circle::TensorType_FLOAT32:
27 return circlechef::FLOAT32;
28 case circle::TensorType_INT32:
29 return circlechef::INT32;
30 case circle::TensorType_INT64:
31 return circlechef::INT64;
32 case circle::TensorType_UINT8:
33 return circlechef::UINT8;
34 case circle::TensorType_UINT4:
35 return circlechef::UINT4;
36 case circle::TensorType_BOOL:
37 return circlechef::BOOL;
38 case circle::TensorType_INT16:
39 return circlechef::INT16;
40 case circle::TensorType_INT4:
41 return circlechef::INT4;
42 case circle::TensorType_MXFP4:
43 return circlechef::MXFP4;
44 case circle::TensorType_MXINT8:
45 return circlechef::MXINT8;
46 // TODO handle other types
47 // TensorType_FLOAT16
48 // TensorType_STRING
49 // TensorType_COMPLEX64
50 default:
51 throw std::runtime_error{"unsupported tensor type"};
52 }
53}
54
55circlechef::Activation as_circlechef_activation(const circle::ActivationFunctionType type)
56{
57 switch (type)
58 {
59 case circle::ActivationFunctionType_NONE:
60 return circlechef::NONE;
61 case circle::ActivationFunctionType_RELU:
62 return circlechef::RELU;
63 case circle::ActivationFunctionType_RELU6:
64 return circlechef::RELU6;
65 // TODO handle other types
66 // ActivationFunctionType_RELU_N1_TO_1
67 // ActivationFunctionType_TANH
68 // ActivationFunctionType_SIGN_BIT
69 default:
70 throw std::runtime_error{"unsupported activation type"};
71 }
72}
73
74circlechef::Padding as_circlechef_padding(const circle::Padding padding)
75{
76 switch (padding)
77 {
78 case circle::Padding_SAME:
79 return circlechef::SAME;
80 case circle::Padding_VALID:
81 return circlechef::VALID;
82 default:
83 throw std::runtime_error{"unsupported padding"};
84 }
85}
86
87} // namespace circlechef
circlechef::Activation as_circlechef_activation(const circle::ActivationFunctionType type)
Definition Convert.cpp:55
circlechef::TensorType as_circlechef_type(const circle::TensorType type)
Definition Convert.cpp:22
circlechef::Padding as_circlechef_padding(const circle::Padding padding)
Definition Convert.cpp:74