• 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 
16 #ifndef TENSORFLOW_CORE_GRAPPLER_GRAPPLER_ITEM_BUILDER_H_
17 #define TENSORFLOW_CORE_GRAPPLER_GRAPPLER_ITEM_BUILDER_H_
18 
19 #include <memory>
20 #include <set>
21 #include <string>
22 #include "tensorflow/core/framework/attr_value.pb.h"
23 #include "tensorflow/core/grappler/grappler_item.h"
24 
25 namespace tensorflow {
26 
27 class MetaGraphDef;
28 
29 namespace grappler {
30 
31 struct ItemConfig {
ItemConfigItemConfig32   ItemConfig() {}
33 
34   // If true, ignore all user specified node placement.
35   bool ignore_user_placement = true;
36   // If true, ignore all user specified colocation attributes.
37   bool ignore_colocation = true;
38   // Dimension to use if a placeholder node has an _output_shapes attribute with
39   // a dimension of -1.
40   int placeholder_unknown_output_shape_dim = -1;
41   // If true, does L1 optimizations.
42   bool apply_optimizations = false;
43   // If true, erases all "_noinline" attributes from user-defined functions.
44   // Has no effect if "inline_functions" is disabled.
45   bool erase_noinline_attributes = false;
46   // If non-empty, override the directory of asset paths.
47   string assets_directory_override;
48   // If true, runs ModelPruner on the graph.
49   bool prune_graph = false;
50   // Override feed nodes list.
51   std::set<string> feed_nodes;
52   // Override fetch nodes list.
53   std::set<string> fetch_nodes;
54 };
55 
56 // Factory method for creating a GrapplerItem from a MetaGraphDef.
57 // Returns nullptr if the given meta_graph cannot be converted.
58 std::unique_ptr<GrapplerItem> GrapplerItemFromMetaGraphDef(
59     const string& id, const MetaGraphDef& meta_graph, const ItemConfig& cfg);
60 
61 // Factory method for creating a GrapplerItem from a file
62 // containing a MetaGraphDef in either binary or text format.
63 // Returns nullptr if the given meta_graph cannot be converted.
64 std::unique_ptr<GrapplerItem> GrapplerItemFromMetaGraphDefFile(
65     const string& id, const string& meta_graph_file, const ItemConfig& cfg);
66 
67 }  // end namespace grappler
68 }  // end namespace tensorflow
69 
70 #endif  // TENSORFLOW_CORE_GRAPPLER_GRAPPLER_ITEM_BUILDER_H_
71