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
19#include <stdexcept>
20
21circle::Padding as_circle_padding(const circlechef::Padding &value)
22{
23 switch (value)
24 {
25 case circlechef::SAME:
26 return circle::Padding_SAME;
27 case circlechef::VALID:
28 return circle::Padding_VALID;
29 default:
30 break;
31 }
32
33 throw std::runtime_error{"Unknown padding value"};
34}
35
36circle::ActivationFunctionType as_circle_activation(const circlechef::Activation &value)
37{
38 switch (value)
39 {
40 case circlechef::NONE:
41 return circle::ActivationFunctionType_NONE;
42 case circlechef::RELU:
43 return circle::ActivationFunctionType_RELU;
44 case circlechef::RELU6:
45 return circle::ActivationFunctionType_RELU6;
46 default:
47 break;
48 }
49
50 throw std::runtime_error{"Unknown activation"};
51}
52
53circle::TensorType as_circle_tensortype(const circlechef::TensorType &value)
54{
55 switch (value)
56 {
57 case circlechef::FLOAT32:
58 return circle::TensorType_FLOAT32;
59 case circlechef::INT64:
60 return circle::TensorType_INT64;
61 case circlechef::INT32:
62 return circle::TensorType_INT32;
63 case circlechef::INT16:
64 return circle::TensorType_INT16;
65 case circlechef::INT4:
66 return circle::TensorType_INT4;
67 case circlechef::UINT8:
68 return circle::TensorType_UINT8;
69 case circlechef::UINT4:
70 return circle::TensorType_UINT4;
71 case circlechef::STRING:
72 return circle::TensorType_STRING;
73 case circlechef::BOOL:
74 return circle::TensorType_BOOL;
75 case circlechef::MXFP4:
76 return circle::TensorType_MXFP4;
77 case circlechef::MXINT8:
78 return circle::TensorType_MXINT8;
79 default:
80 break;
81 }
82
83 throw std::runtime_error{"Unknown tensor type"};
84}
circle::TensorType as_circle_tensortype(const circlechef::TensorType &value)
Definition Convert.cpp:53
circle::ActivationFunctionType as_circle_activation(const circlechef::Activation &value)
Definition Convert.cpp:36
circle::Padding as_circle_padding(const circlechef::Padding &value)
Definition Convert.cpp:21