• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1syntax = "proto3";
2
3package tensorflow;
4
5option cc_enable_arenas = true;
6option java_outer_classname = "RewriterConfigProtos";
7option java_multiple_files = true;
8option java_package = "org.tensorflow.framework";
9
10option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf";
11
12import "tensorflow/core/framework/attr_value.proto";
13import "tensorflow/core/protobuf/verifier_config.proto";
14
15message AutoParallelOptions {
16  bool enable = 1;
17  int32 num_replicas = 2;
18}
19
20message ScopedAllocatorOptions {
21  // If present, only perform optimization for these ops.
22  repeated string enable_op = 1;
23}
24
25message RewriterConfig {
26  // Graph rewriting is experimental and subject to change, not covered by any
27  // API stability guarantees.
28
29  // Configuration options for the meta-optimizer. Unless otherwise noted, these
30  // configuration options do not apply to explicitly triggered optimization
31  // passes in the optimizers field.
32
33  enum Toggle {
34    DEFAULT = 0;
35    ON = 1;
36    OFF = 2;
37    // Enable some aggressive optimizations that use assumptions that TF graphs
38    // may break. For example, assume the shape of a placeholder matches its
39    // actual feed.
40    AGGRESSIVE = 3;
41  }
42
43  // Enum controlling the number of times to run optimizers. The default is to
44  // run them twice.
45  enum NumIterationsType {
46    DEFAULT_NUM_ITERS = 0;
47    ONE = 1;
48    TWO = 2;
49  }
50
51  // Optimize tensor layouts (default is ON)
52  // e.g. This will try to use NCHW layout on GPU which is faster.
53  Toggle layout_optimizer = 1;
54  // Fold constants (default is ON)
55  // Statically infer the value of tensors when possible, and materialize the
56  // result using constants.
57  Toggle constant_folding = 3;
58  // Shape optimizations (default is ON)
59  // Simplify computations made on shapes.
60  Toggle shape_optimization = 13;
61  // Remapping (default is ON)
62  // Remap subgraphs onto more efficient implementations.
63  Toggle remapping = 14;
64  // Arithmetic optimizations (default is ON)
65  // e.g. Simplify arithmetic ops; merge ops with same value (like constants).
66  Toggle arithmetic_optimization = 7;
67  // Control dependency optimizations (default is ON).
68  // Remove redundant control dependencies, which may enable other optimization.
69  Toggle dependency_optimization = 8;
70  // Loop optimizations (default is ON).
71  Toggle loop_optimization = 9;
72  // Function optimizations (default is ON).
73  Toggle function_optimization = 10;
74  // Strips debug-related nodes from the graph (off by default).
75  Toggle debug_stripper = 11;
76  // If true, don't remove unnecessary ops from the graph
77  bool disable_model_pruning = 2;
78  // Try to allocate some independent Op outputs contiguously in order to
79  // merge or eliminate downstream Ops (off by default).
80  Toggle scoped_allocator_optimization = 15;
81  // Force small ops onto the CPU (default is OFF).
82  Toggle pin_to_host_optimization = 18;
83  // Enable the swap of kernel implementations based on the device placement
84  // (default is ON).
85  Toggle implementation_selector = 22;
86  // Optimize data types (default is OFF).
87  // e.g., This will try to use float16 on GPU which is faster.
88  // Note that this can change the numerical stability of the graph and may
89  // require the use of loss scaling to maintain model convergence.
90  Toggle auto_mixed_precision = 23;
91  // Disable the entire meta optimizer (off by default).
92  bool disable_meta_optimizer = 19;
93
94  // Controls how many times we run the optimizers in meta optimizer (default
95  // is once).
96  NumIterationsType meta_optimizer_iterations = 12;
97
98  // The minimum number of nodes in a graph to optimizer. For smaller graphs,
99  // optimization is skipped.
100  // 0 means the system picks an appropriate number.
101  // < 0 means do not skip optimization.
102  int32 min_graph_nodes = 17;
103
104  enum MemOptType {
105    // The default setting (SCHEDULING and SWAPPING HEURISTICS only)
106    DEFAULT_MEM_OPT = 0;
107    // Disabled in the meta-optimizer.
108    NO_MEM_OPT = 1;
109    // Driven by manual op-level annotations.
110    MANUAL = 2;
111
112    // Driven by heuristics. The behavior of these heuristics is subject to
113    // change. Currently includes an experimental recomputation and swapping
114    // heuristics. Manual annotations are respected, but additional nodes are
115    // selected automatically.
116
117    // Swapping heuristic will move a tensor from the GPU to the CPU and move
118    // it back when needed to reduce peak memory usage.
119    SWAPPING_HEURISTICS = 4;
120    // Recomputation heuristics will recompute ops (such as Relu activation)
121    // during backprop instead of storing them, reducing peak memory usage.
122    RECOMPUTATION_HEURISTICS = 5;
123    // Scheduling will split big ops such as AddN and try to enforce a schedule
124    // of the new computations that decreases peak memory usage.
125    SCHEDULING_HEURISTICS = 6;
126    // Use any combination of swapping and recomputation heuristics.
127    HEURISTICS = 3;
128  }
129  // Configures memory optimization passes through the meta-optimizer. Has no
130  // effect on manually requested memory optimization passes in the optimizers
131  // field.
132  MemOptType memory_optimization = 4;
133  // A node name scope for node names which are valid outputs of recompuations.
134  // Inputs to nodes that match this scope may be recomputed (subject either to
135  // manual annotation of those input nodes or to manual annotation and
136  // heuristics depending on memory_optimization), but the nodes themselves will
137  // not be recomputed. This matches any sub-scopes as well, meaning the scope
138  // can appear not just as a top-level scope. For example, if the value is
139  // "gradients/", the default, it will match node name "gradients/foo",
140  // "foo/gradients/bar", but not "foo_gradients/"
141  string memory_optimizer_target_node_name_scope = 6;
142  // Maximum number of milliseconds to spend optimizing a single graph before
143  // timing out. If equal to 0 the system picks a default (currently 5 minutes).
144  // If less than 0 the optimizer will never time out.
145  int64 meta_optimizer_timeout_ms = 20;
146
147  // Configures AutoParallel optimization passes either through the
148  // meta-optimizer or when manually specified through the optimizers field.
149  AutoParallelOptions auto_parallel = 5;
150
151  // If true, any optimization pass failing will cause the MetaOptimizer to
152  // stop with an error. By default - or when set to false, failing passes are
153  // skipped silently.
154  bool fail_on_optimizer_errors = 21;
155
156  ScopedAllocatorOptions scoped_allocator_opts = 16;
157
158  // If non-empty, will use this as an alternative way to specify a list of
159  // optimizations to turn on and the order of the optimizations (replacing the
160  // meta-optimizer).
161  //
162  // Of the RewriterConfig options, only the AutoParallel configuration options
163  // (the auto_parallel field) apply to manually requested optimization passes
164  // ("autoparallel"). Memory optimization passes ("memory") invoked here are
165  // not configurable (in contrast to memory optimization passes through the
166  // meta-optimizer) and act only on manual op annotations.
167  //
168  // Custom optimizers (see custom_optimizers) that are not part of this
169  // schedule will be run after - in the order that they were specified.
170  repeated string optimizers = 100;
171
172  // Message to describe custom graph optimizer and its parameters
173  message CustomGraphOptimizer {
174    string name = 1;
175    map<string, AttrValue> parameter_map = 2;
176  }
177
178  // list of CustomGraphOptimizers to apply.
179  repeated CustomGraphOptimizer custom_optimizers = 200;
180
181  // VerifierConfig specifying the verifiers to be run after every optimizer.
182  VerifierConfig inter_optimizer_verifier_config = 300;
183
184  // VerifierConfig specifying the verifiers to be run at the end, after all
185  // optimizers have run.
186  VerifierConfig post_optimization_verifier_config = 301;
187}
188