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_FRAMEWORK_NODE_PROPERTIES_H_ 17 #define TENSORFLOW_CORE_FRAMEWORK_NODE_PROPERTIES_H_ 18 19 #include "tensorflow/core/framework/node_def.pb.h" 20 #include "tensorflow/core/framework/op_def.pb.h" 21 #include "tensorflow/core/framework/types.h" 22 #include "tensorflow/core/lib/core/status.h" 23 24 namespace tensorflow { 25 26 class OpRegistryInterface; 27 28 struct NodeProperties { 29 public: NodePropertiesNodeProperties30 NodeProperties(const OpDef* op_def, NodeDef node_def, 31 const DataTypeSlice inputs, const DataTypeSlice outputs) 32 : NodeProperties(op_def, std::move(node_def), 33 DataTypeVector(inputs.begin(), inputs.end()), 34 DataTypeVector(outputs.begin(), outputs.end())) {} 35 NodePropertiesNodeProperties36 NodeProperties(const OpDef* _op_def, NodeDef&& _node_def, 37 DataTypeVector inputs, DataTypeVector outputs) 38 : op_def(_op_def), 39 node_def(std::move(_node_def)), 40 input_types(std::move(inputs)), 41 input_types_slice(input_types), 42 output_types(std::move(outputs)), 43 output_types_slice(output_types) {} 44 45 // Resets the 'props' shared pointer to point to a new NodeProperties created 46 // from the given NodeDef. 'op_registry' is used to look up the OpDef 47 // corresponding to node_def.op(). Returns an error if OpDef lookup or 48 // creation failed. 49 static Status CreateFromNodeDef(NodeDef node_def, 50 const OpRegistryInterface* op_registry, 51 std::shared_ptr<const NodeProperties>* props); 52 53 const OpDef* op_def; // not owned. 54 NodeDef node_def; 55 DataTypeVector input_types; 56 DataTypeSlice input_types_slice; 57 DataTypeVector output_types; 58 DataTypeSlice output_types_slice; 59 }; 60 61 } // namespace tensorflow 62 63 #endif // TENSORFLOW_CORE_FRAMEWORK_NODE_PROPERTIES_H_ 64