Imported Upstream version 1.12.0
[platform/core/ml/nnfw.git] / compiler / luci / export / src / CircleExporterUtils.h
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 #ifndef __CIRCLE_EXPORTER_UTILS_H__
18 #define __CIRCLE_EXPORTER_UTILS_H__
19
20 #include "SerializedData.h"
21
22 #include <luci/IR/CircleNodes.h>
23 #include <luci/Service/ShapeDescription.h>
24
25 #include <loco.h>
26
27 #include <mio/circle/schema_generated.h>
28
29 namespace luci
30 {
31
32 circle::ActivationFunctionType to_circle_actfunc(luci::FusedActFunc func);
33 circle::TensorType to_circle_tensortype(loco::DataType type);
34 circle::MirrorPadMode to_circle_mirrorpadmode(luci::MirrorPadMode mode);
35 circle::FullyConnectedOptionsWeightsFormat
36 to_circle_weightsformat(luci::CircleFullyConnected::WeightsFormat format);
37 circle::DimensionType to_circle_dimensiontype(luci::DimensionType type);
38 flatbuffers::Offset<void> to_circle_sparse_index_vector(flatbuffers::FlatBufferBuilder &fb,
39                                                         const SparseIndexVector &sparse_idx_vec);
40 circle::SparseIndexVector to_circle_sparse_index_vector_type(luci::SparseIndexVectorType type);
41
42 } // namespace luci
43
44 namespace luci
45 {
46
47 circle::Padding getOpPadding(const loco::Padding2D *pad, const loco::Stride<2> *stride,
48                              const ShapeDescription &ifm, const ShapeDescription &ofm);
49 circle::Padding getOpPadding(const luci::Padding pad);
50
51 using CircleTensorIndex = int32_t;
52
53 void set_tensor_index(loco::Node *node, const CircleTensorIndex &tensor_id);
54 CircleTensorIndex get_tensor_index(loco::Node *node);
55
56 } // namespace luci
57
58 #endif // __CIRCLE_EXPORTER_UTILS_H__