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_CC_TOOLS_FREEZE_SAVED_MODEL_H_
16 #define TENSORFLOW_CC_TOOLS_FREEZE_SAVED_MODEL_H_
17 
18 #include <unordered_set>
19 
20 #include "tensorflow/cc/saved_model/loader.h"
21 #include "tensorflow/core/framework/graph.pb.h"
22 #include "tensorflow/core/lib/core/status.h"
23 
24 namespace tensorflow {
25 
26 // Returns a frozen GraphDef, input tensors, and output tensors from the loaded
27 // SavedModelBundle.
28 // `inputs` and `outputs` consist of the union of all inputs and outputs in the
29 // SignatureDefs in the SavedModelBundle.
30 // FreezeSavedModel sets `frozen_graph_def` to a GraphDef of all nodes needed by
31 // `outputs`. All variables in the supplied SavedModelBundle are converted to
32 // constants, set to the value of the variables, by running the restored Session
33 // in the SavedModelBundle.
34 // WARNING: Only the variable checkpoints will be reflected in the frozen
35 // graph_def. All saved_model assets will be ignored.
36 Status FreezeSavedModel(const SavedModelBundle& saved_model_bundle,
37                         GraphDef* frozen_graph_def,
38                         std::unordered_set<string>* inputs,
39                         std::unordered_set<string>* outputs);
40 
41 }  // namespace tensorflow
42 
43 #endif  // TENSORFLOW_CC_TOOLS_FREEZE_SAVED_MODEL_H_
44