Add indicator in GraphOptimizationPassOptions whether not the Graph was generated from a Function.

By having some indicator for if a graph is derived from a function, graph optimization passes can then selectively choose whether not to run. For example, it may be possible to have a function optimization pass that when ran (only on function graphs), an associated graph optimization pass should not run.

PiperOrigin-RevId: 294478764
Change-Id: Ic407e81d9b528ab1b532c05ff157654851812566
This commit is contained in:
Andy Ly 2020-02-11 11:13:10 -08:00 committed by TensorFlower Gardener
parent 15fb2601b0
commit 6719cb8f93
2 changed files with 4 additions and 0 deletions

View File

@ -58,6 +58,9 @@ struct GraphOptimizationPassOptions {
// Null for pre-partitioning passes.
std::unordered_map<string, std::unique_ptr<Graph>>* partition_graphs =
nullptr;
// Indicator of whether or not the graph was derived from a function.
bool is_function_graph = false;
};
// Optimization passes are implemented by inheriting from

View File

@ -702,6 +702,7 @@ Status ProcessFunctionLibraryRuntime::InstantiateMultiDevice(
optimization_options.graph = &graph;
optimization_options.flib_def = &data->lib_def_;
optimization_options.device_set = &device_set_;
optimization_options.is_function_graph = true;
DumpGraph("Before running PRE_PLACEMENT passes", graph.get());
TF_RETURN_IF_ERROR(OptimizationPassRegistry::Global()->RunGrouping(