• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 #ifndef TENSORFLOW_LITE_TOCO_TFLITE_TYPES_H_
16 #define TENSORFLOW_LITE_TOCO_TFLITE_TYPES_H_
17 
18 #include "tensorflow/lite/schema/schema_generated.h"
19 #include "tensorflow/lite/toco/model.h"
20 
21 namespace toco {
22 
23 namespace tflite {
24 
25 struct DataType {
26   static ::tflite::TensorType Serialize(ArrayDataType array_data_type);
27   static ArrayDataType Deserialize(int tensor_type);
28 };
29 
30 struct DataBuffer {
31   using FlatBufferOffset = flatbuffers::Offset<flatbuffers::Vector<uint8_t>>;
32 
33   // Build the flatbuffer representation of a toco's Array and return the
34   // corresponding offset into the flatbuffer. Note that data from the array
35   // will be copied into the flatbuffer.
36   static FlatBufferOffset Serialize(const Array& array,
37                                     flatbuffers::FlatBufferBuilder* builder);
38   // Copy data from the given tensor into toco's Array.
39   static void Deserialize(const ::tflite::Tensor& tensor,
40                           const ::tflite::Buffer& buffer, Array* array);
41 };
42 
43 struct Padding {
44   static ::tflite::Padding Serialize(PaddingType padding_type);
45   static PaddingType Deserialize(int padding);
46 };
47 
48 struct ActivationFunction {
49   static ::tflite::ActivationFunctionType Serialize(
50       FusedActivationFunctionType faf_type);
51   static FusedActivationFunctionType Deserialize(int activation_function);
52 };
53 
54 }  // namespace tflite
55 
56 }  // namespace toco
57 
58 #endif  // TENSORFLOW_LITE_TOCO_TFLITE_TYPES_H_
59