2 * Copyright (c) 2020 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.
17 #ifndef __CIRCLE_MODEL_H__
18 #define __CIRCLE_MODEL_H__
20 #include <mio/tflite/schema_generated.h>
21 #include <mio/circle/schema_generated.h>
29 namespace tflite2circle
32 using FlatBufBuilder = std::unique_ptr<flatbuffers::FlatBufferBuilder>;
34 struct OperatorCodeLink
36 using TFL = flatbuffers::Offset<::tflite::OperatorCode>;
37 using CIR = flatbuffers::Offset<::circle::OperatorCode>;
42 using TFL = flatbuffers::Offset<::tflite::SubGraph>;
43 using CIR = flatbuffers::Offset<::circle::SubGraph>;
48 using TFL = flatbuffers::Offset<::tflite::Buffer>;
49 using CIR = flatbuffers::Offset<::circle::Buffer>;
52 struct MetaDataBufferLink
58 template <typename T> class Offset
61 using TFLFlatBufVec = flatbuffers::Vector<typename T::TFL>;
62 using CIRFlatBufVecOffset = flatbuffers::Offset<flatbuffers::Vector<typename T::CIR>>;
65 Offset(void) = delete;
66 Offset(FlatBufBuilder &fb, const TFLFlatBufVec *tflite_flatbuffer_vec);
69 CIRFlatBufVecOffset offset(void) const { return _circle_flatbuffer_vec_offset; }
72 CIRFlatBufVecOffset _circle_flatbuffer_vec_offset;
78 using Description = flatbuffers::Offset<flatbuffers::String>;
81 CircleModel(void) = delete;
82 CircleModel(FlatBufBuilder &fb, TFLModel &tfl_model);
85 void model_build(void) const;
86 const char *base(void) const;
87 size_t size(void) const;
91 Description _description;
93 std::unique_ptr<Offset<OperatorCodeLink>> _operator_codes_offset;
94 std::unique_ptr<Offset<SubGraphLink>> _subGraphs_offset;
95 std::unique_ptr<Offset<BufferLink>> _buffers_offset;
96 std::unique_ptr<Offset<MetaDataBufferLink>> _metadata_buffer_offset;
99 } // namespace tflite2circle
101 #endif // __CIRCLE_MODEL_H__