| 29 | using NodePredicate = std::function<bool(const Node*)>; |
| 30 | |
| 31 | struct Options { |
| 32 | // If not null it maps from nodes in graph to partially-known |
| 33 | // shapes of their outputs, and may be used, e.g., in the constant folding |
| 34 | // pass. The use of shape_map implies that the mapping from node name to the |
| 35 | // vector of partial shapes of its outputs is stable, i.e., no optimization |
| 36 | // pass may replace a node with a different node of the same name that has a |
| 37 | // different number of outputs, or outputs with different known shapes. |
| 38 | // TODO(b/65453533) introduce a unique way to name nodes in a graph. |
| 39 | std::unordered_map<string, std::vector<PartialTensorShape>>* shape_map = |
| 40 | nullptr; |
| 41 | |
| 42 | // If not null then only nodes for which cse_consider_fn returns true will |
| 43 | // be considered for CSE. |
| 44 | NodePredicate cse_consider_fn = nullptr; |
| 45 | |
| 46 | // If not null then only nodes for which cf_consider_fn returns true will be |
| 47 | // considered for CF. |
| 48 | NodePredicate cf_consider_fn = nullptr; |
| 49 | |
| 50 | // If true, multi-device functions will be inlined if |
| 51 | // opts_.do_function_inlining() is true. |
| 52 | bool inline_multi_device_functions = false; |
| 53 | |
| 54 | // If true, functions in implementation selection group will be inlined if |
| 55 | // opts_.do_function_inlining() is true. |
| 56 | bool inline_impl_selection_group_functions = false; |
| 57 | }; |
| 58 | |
| 59 | explicit GraphOptimizer(const OptimizerOptions& opts); |
| 60 | ~GraphOptimizer(); |