1 /* Copyright 2020 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_TPU_GRAPH_REWRITE_NODEDEF_BUILDER_H_ 17 #define TENSORFLOW_CORE_TPU_GRAPH_REWRITE_NODEDEF_BUILDER_H_ 18 19 #include <string> 20 21 #include "tensorflow/core/framework/node_def_builder.h" 22 #include "tensorflow/core/graph/graph.h" 23 #include "tensorflow/core/lib/core/status.h" 24 25 namespace tensorflow { 26 27 // Convenience builder to build NodeDefs without specifying the inputs. This is 28 // similar to NodeDefBuilder except inputs are not specified. 29 // TODO(jpienaar): Clean up NodeDefBuilder and remove this class. 30 class IncompleteNodeDefBuilder { 31 public: 32 IncompleteNodeDefBuilder(const string& name, const string& op, 33 const NodeDebugInfo& debug); 34 35 IncompleteNodeDefBuilder& AddAttr(const string& attr, const DataType& type); 36 IncompleteNodeDefBuilder& AddAttr(const string& attr, int val); 37 38 IncompleteNodeDefBuilder& Device(const string& device); 39 40 Status Build(Graph* graph, Node** n); 41 42 static IncompleteNodeDefBuilder Identity(const string& name, 43 const DataType& type, 44 const NodeDebugInfo& debug); 45 static IncompleteNodeDefBuilder Merge(const string& name, 46 const DataType& type, 47 const NodeDebugInfo& debug, int n); 48 static IncompleteNodeDefBuilder Switch(const string& name, 49 const DataType& type, 50 const NodeDebugInfo& debug); 51 52 private: 53 NodeDef nodedef_; 54 }; 55 56 } // namespace tensorflow 57 58 #endif // TENSORFLOW_CORE_TPU_GRAPH_REWRITE_NODEDEF_BUILDER_H_ 59