ONE - On-device Neural Engine
Loading...
Searching...
No Matches
CircleExporterUtils.h
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#ifndef __CIRCLE_EXPORTER_UTILS_H__
18#define __CIRCLE_EXPORTER_UTILS_H__
19
20#include "SerializedData.h"
21
22#include <luci/IR/CircleNodes.h>
24
25#include <loco.h>
26
27#include <mio/circle/schema_generated.h>
28
29// limitation of current flatbuffers file size
30inline constexpr uint64_t FLATBUFFERS_SIZE_MAX = 2147483648UL; // 2GB
31
32namespace luci
33{
34
35circle::ActivationFunctionType to_circle_actfunc(luci::FusedActFunc func);
36circle::TensorType to_circle_tensortype(loco::DataType type);
37circle::MirrorPadMode to_circle_mirrorpadmode(luci::MirrorPadMode mode);
38circle::RoPEMode to_circle_rope(luci::RoPEMode mode);
39circle::FullyConnectedOptionsWeightsFormat
41circle::DimensionType to_circle_dimensiontype(luci::DimensionType type);
43 const SparseIndexVector &sparse_idx_vec);
45
46circle::BuiltinOperator circle_builtin_operator(const luci::CircleNode *node);
47circle::BuiltinOptions circle_builtin_options(const luci::CircleNode *node);
48std::string circle_custom_code(const luci::CircleNode *node);
51
52} // namespace luci
53
54namespace luci
55{
56
57circle::Padding getOpPadding(const loco::Padding2D *pad, const loco::Stride<2> *stride,
58 const ShapeDescription &ifm, const ShapeDescription &ofm);
59circle::Padding getOpPadding(const luci::Padding pad);
60
61using CircleTensorIndex = int32_t;
62
63void set_tensor_index(loco::Node *node, const CircleTensorIndex &tensor_id);
66
67// check if Flatbuffer builder can no longer hold the given amount of the data
68inline bool check_size_limit(const flatbuffers::FlatBufferBuilder &fb, const uint64_t data_size)
69{
70 return FLATBUFFERS_SIZE_MAX < data_size + fb.GetSize();
71}
72
73} // namespace luci
74
75#endif // __CIRCLE_EXPORTER_UTILS_H__
Helper class to hold data needed in creation of a FlatBuffer. To serialize data, you typically call o...
uoffset_t GetSize() const
The current size of the serialized buffer, counting from the end.
Logical unit of computation.
Definition Node.h:54
Stride configuration for N-dimensional spatial operations.
Definition Stride.h:28
constexpr uint64_t FLATBUFFERS_SIZE_MAX
DataType
"scalar" value type
Definition DataType.h:27
flatbuffers::Offset< void > to_circle_sparse_index_vector(flatbuffers::FlatBufferBuilder &fb, const SparseIndexVector &sparse_idx_vec)
circle::BuiltinOptions circle_builtin_options(const luci::CircleNode *node)
bool check_size_limit(const flatbuffers::FlatBufferBuilder &fb, const uint64_t data_size)
void set_tensor_index(loco::Node *node, const CircleTensorIndex &tensor_id)
flatbuffers::Offset< flatbuffers::Vector< uint8_t > > circle_custom_options(flatbuffers::FlatBufferBuilder &fb, const luci::CircleNode *node)
circle::Padding getOpPadding(const loco::Padding2D *pad, const loco::Stride< 2 > *stride, const ShapeDescription &ifm, const ShapeDescription &ofm)
circle::DimensionType to_circle_dimensiontype(luci::DimensionType type)
circle::FullyConnectedOptionsWeightsFormat to_circle_weightsformat(luci::CircleFullyConnected::WeightsFormat format)
circle::SparseIndexVector to_circle_sparse_index_vector_type(luci::SparseIndexVectorType type)
circle::RoPEMode to_circle_rope(luci::RoPEMode mode)
circle::ActivationFunctionType to_circle_actfunc(luci::FusedActFunc func)
int32_t CircleTensorIndex
circle::TensorType to_circle_tensortype(loco::DataType type)
SparseIndexVectorType
void clear_tensor_index(loco::Node *node)
CircleTensorIndex get_tensor_index(loco::Node *node)
circle::BuiltinOperator circle_builtin_operator(const luci::CircleNode *node)
circle::MirrorPadMode to_circle_mirrorpadmode(luci::MirrorPadMode mode)
std::string circle_custom_code(const luci::CircleNode *node)