1 /* Copyright 2018 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_OPTIMIZERS_SHAPE_OPTIMIZER_H_ 17 #define TENSORFLOW_CORE_GRAPPLER_OPTIMIZERS_SHAPE_OPTIMIZER_H_ 18 19 #include <unordered_set> 20 #include "tensorflow/core/grappler/costs/graph_properties.h" 21 #include "tensorflow/core/grappler/optimizers/graph_optimizer.h" 22 #include "tensorflow/core/grappler/utils.h" 23 #include "tensorflow/core/grappler/utils/frame.h" 24 #include "tensorflow/core/protobuf/rewriter_config.pb.h" 25 26 namespace tensorflow { 27 namespace grappler { 28 29 // Optimize TensorFlow subgraphs that operate on shape and shape related 30 // information. 31 class ShapeOptimizer : public GraphOptimizer { 32 public: ShapeOptimizer()33 ShapeOptimizer() {} ShapeOptimizer(RewriterConfig::Toggle opt_level)34 explicit ShapeOptimizer(RewriterConfig::Toggle opt_level) {} 35 ~ShapeOptimizer()36 ~ShapeOptimizer() override {} 37 name()38 string name() const override { return "shape_optimizer"; }; 39 40 Status Optimize(Cluster* cluster, const GrapplerItem& item, 41 GraphDef* optimized_graph) override; 42 43 void Feedback(Cluster* cluster, const GrapplerItem& item, 44 const GraphDef& optimized_graph, double result) override; 45 }; 46 47 } // end namespace grappler 48 } // end namespace tensorflow 49 50 #endif // TENSORFLOW_CORE_GRAPPLER_OPTIMIZERS_SHAPE_OPTIMIZER_H_ 51