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_CONTRIB_LITE_TOCO_TOCO_TOOLING_H_ |
16 | #define TENSORFLOW_CONTRIB_LITE_TOCO_TOCO_TOOLING_H_ |
17 | |
18 | #include <memory> |
19 | #include <string> |
20 | |
21 | #include "tensorflow/contrib/lite/toco/model.h" |
22 | #include "tensorflow/contrib/lite/toco/model_flags.pb.h" |
23 | #include "tensorflow/contrib/lite/toco/toco_flags.pb.h" |
24 | |
25 | namespace toco { |
26 | |
27 | // Imports the input file into a Model object. |
28 | std::unique_ptr<Model> Import(const TocoFlags& toco_flags, |
29 | const ModelFlags& model_flags, |
30 | const string& input_file_contents); |
31 | |
32 | // Transforms a Model. The resulting Model is ready to be passed |
33 | // to Export with the exact same toco_flags. |
34 | void Transform(const TocoFlags& toco_flags, Model* model); |
35 | |
36 | // Exports the Model, which must be of the 'lowered' form returned by |
37 | // Transform, to a file of the format given by |
38 | // toco_flags.output_format(). |
39 | void Export(const TocoFlags& toco_flags, const Model& model, |
40 | bool allow_custom_ops, string* output_file_contents); |
41 | |
42 | // This if for backward-compatibility with internal tools. |
43 | inline void Export(const TocoFlags& toco_flags, const Model& model, |
44 | string* output_file_contents) { |
45 | Export(toco_flags, model, true, output_file_contents); |
46 | } |
47 | |
48 | } // namespace toco |
49 | |
50 | #endif // TENSORFLOW_CONTRIB_LITE_TOCO_TOCO_TOOLING_H_ |
51 | |