1 /* Copyright 2021 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 #ifndef TENSORFLOW_C_EXPERIMENTAL_OPS_GEN_MODEL_ARG_TYPE_H_ 16 #define TENSORFLOW_C_EXPERIMENTAL_OPS_GEN_MODEL_ARG_TYPE_H_ 17 18 #include "tensorflow/core/framework/op_def.pb.h" 19 #include "tensorflow/core/platform/types.h" 20 21 namespace tensorflow { 22 namespace generator { 23 24 // Type information of an Op argument (ArgSpec).. 25 // 26 // This represents the type information with OpDef::ArgDef and any type-related 27 // context. 28 class ArgType { 29 public: 30 ArgType() = default; 31 ArgType(const ArgType& other) = default; 32 static ArgType CreateInput(const OpDef::ArgDef& arg_def); 33 static ArgType CreateInputRef(const OpDef::ArgDef& arg_def); 34 static ArgType CreateOutput(const OpDef::ArgDef& arg_def); 35 data_type()36 const tensorflow::DataType data_type() const { return data_type_; } type_attr_name()37 const string type_attr_name() const { return type_attr_name_; } is_read_only()38 const bool is_read_only() const { return kind_ == kInput; } is_list()39 const bool is_list() const { return is_list_; } 40 41 private: 42 enum Kind { kInput = 0, kInputRef, kOutput }; 43 44 explicit ArgType(const OpDef::ArgDef& arg_def, Kind kind); 45 46 Kind kind_; 47 tensorflow::DataType data_type_; 48 string type_attr_name_; 49 bool is_list_; 50 }; 51 52 } // namespace generator 53 } // namespace tensorflow 54 55 #endif // TENSORFLOW_C_EXPERIMENTAL_OPS_GEN_MODEL_ARG_TYPE_H_ 56