diff options
author | 2016-09-16 16:36:10 -0800 | |
---|---|---|
committer | 2016-09-16 17:47:44 -0700 | |
commit | 72f2a1d132b5b5750d02f32ac5c8d3134af6abd0 (patch) | |
tree | 8a5d05dde0dc01f88331919fb734e3b7fa544f0c | |
parent | cae1546ffa38dc8780347319641478e5c7e13dba (diff) |
graph_constructor: Remove dead code.
Optimizations such as constant-folding and common-subexpression-elimination
are applied directly on a Graph* (for example, by GraphOptimizer in
tensorflow/core/common_runtime/graph_optimizer.h).
I could not find any usage of the GraphConstructorOptions removed in this
change. Would like to keep this file focused on conversion from GraphDef to
Graph and leave operations on the in-memory representation elsewhere.
Change: 133447199
-rw-r--r-- | tensorflow/core/graph/graph_constructor.cc | 39 | ||||
-rw-r--r-- | tensorflow/core/graph/graph_constructor.h | 18 |
2 files changed, 2 insertions, 55 deletions
diff --git a/tensorflow/core/graph/graph_constructor.cc b/tensorflow/core/graph/graph_constructor.cc index 0d2d37ca5c..18b7860fce 100644 --- a/tensorflow/core/graph/graph_constructor.cc +++ b/tensorflow/core/graph/graph_constructor.cc @@ -24,7 +24,6 @@ limitations under the License. #include "tensorflow/core/framework/versions.h" #include "tensorflow/core/graph/algorithm.h" #include "tensorflow/core/graph/graph.h" -#include "tensorflow/core/graph/optimizer_cse.h" #include "tensorflow/core/graph/tensor_id.h" #include "tensorflow/core/lib/core/errors.h" #include "tensorflow/core/lib/gtl/inlined_vector.h" @@ -337,17 +336,6 @@ void GraphConstructor::Convert() { if (status_->ok()) { FixupSourceAndSinkEdges(g_); - - if (opts_.optimizer_do_cse) { - if (!back_edges.empty()) { - VLOG(1) << "Not doing CSE. We need to figure out how to handle " - << "loops in the CSE phase."; - } else { - VLOG(1) << "Starting CSE: graph of " << CountNodes(g_) << " nodes"; - OptimizeCSE(g_, opts_.cse_consider_function); - VLOG(1) << "Finished CSE: graph of " << CountNodes(g_) << " nodes"; - } - } } } @@ -365,19 +353,6 @@ bool GraphConstructor::TypeValidateEdge(const Edge* edge) { return true; } -static void SetDoCSE(const OptimizerOptions& optimizer_opt, bool force, - GraphConstructorOptions* graph_opt) { - graph_opt->optimizer_do_cse = - force || optimizer_opt.do_common_subexpression_elimination(); -} - -static void SetDoConstantFolding(const OptimizerOptions& optimizer_opt, - bool force, - GraphConstructorOptions* graph_opt) { - graph_opt->optimizer_do_constant_folding = - force || optimizer_opt.do_constant_folding(); -} - } // namespace // ---------------------------------------------------------------------------- @@ -386,20 +361,6 @@ static void SetDoConstantFolding(const OptimizerOptions& optimizer_opt, GraphConstructorOptions::GraphConstructorOptions() {} -GraphConstructorOptions::GraphConstructorOptions(const OptimizerOptions& opts) { - // Set the individually specified options first. - SetDoCSE(opts, false, this); - SetDoConstantFolding(opts, false, this); - - // Set options that the level signifies - if (opts.opt_level() == OptimizerOptions::L0) { - // No optimizations performed. - } else if (opts.opt_level() == OptimizerOptions::L1) { - SetDoCSE(opts, true, this); - SetDoConstantFolding(opts, true, this); - } -} - // ---------------------------------------------------------------------------- // ConvertGraphDefToGraph // ---------------------------------------------------------------------------- diff --git a/tensorflow/core/graph/graph_constructor.h b/tensorflow/core/graph/graph_constructor.h index f85bcee018..e605cb4523 100644 --- a/tensorflow/core/graph/graph_constructor.h +++ b/tensorflow/core/graph/graph_constructor.h @@ -19,11 +19,12 @@ limitations under the License. #include "tensorflow/core/framework/graph.pb.h" #include "tensorflow/core/graph/graph.h" #include "tensorflow/core/lib/core/status.h" -#include "tensorflow/core/protobuf/config.pb.h" namespace tensorflow { // Options specific to constant folding optimizations. +// +// TODO(ashankar,vrv): This should move to where constant folding is done. struct ConstantFoldingOptions { // If "consider" is not a nullptr, then only constant fold a node "n" if // consider(n) returns true. @@ -34,7 +35,6 @@ struct ConstantFoldingOptions { // error, in which case *g is left in an incomplete state. struct GraphConstructorOptions { GraphConstructorOptions(); - explicit GraphConstructorOptions(const OptimizerOptions& opts); // If true, allows internal ops in the GraphDef. bool allow_internal_ops = false; @@ -45,20 +45,6 @@ struct GraphConstructorOptions { // // TODO(zhifengc): if possible, consider removing this option. bool expect_device_spec = false; - - // If true, perform common subexpression elimination on the graph. - // TODO(jeff): Turn this default to true? - bool optimizer_do_cse = false; - - // If "optimizer_do_cse" is true and "cse_consider_function" is - // not nullptr, then only consider nodes for CSE for which - // "cse_consider_function(node)" returns true. - std::function<bool(const Node*)> cse_consider_function = nullptr; - - // If true, perform constant folding on the graph. - bool optimizer_do_constant_folding = false; - - ConstantFoldingOptions constant_folding_opts; }; extern Status ConvertGraphDefToGraph(const GraphConstructorOptions& opts, const GraphDef& gdef, Graph* g); |