• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2019 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_TOOLS_OPTIMIZE_QUANTIZATION_WRAPPER_UTILS_H_
16 #define TENSORFLOW_LITE_TOOLS_OPTIMIZE_QUANTIZATION_WRAPPER_UTILS_H_
17 
18 #include "tensorflow/lite/core/api/error_reporter.h"
19 #include "tensorflow/lite/model.h"
20 #include "tensorflow/lite/schema/schema_generated.h"
21 
22 namespace tflite {
23 namespace optimize {
24 
25 // Load a tflite model from path.
26 TfLiteStatus LoadModel(const string& path, ModelT* model);
27 
28 // Going through the model and add intermediates tensors if the ops have any.
29 // Returns early if the model has already intermediate tensors. This is to
30 // support cases where a model is initialized multiple times.
31 TfLiteStatus AddIntermediateTensorsToFusedOp(
32     flatbuffers::FlatBufferBuilder* builder, ModelT* model);
33 
34 // Write model to a given location.
35 bool WriteFile(const std::string& out_file, const uint8_t* bytes,
36                size_t num_bytes);
37 
38 }  // namespace optimize
39 }  // namespace tflite
40 
41 #endif  // TENSORFLOW_LITE_TOOLS_OPTIMIZE_QUANTIZATION_WRAPPER_UTILS_H_
42