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_EAGER_ABSTRACT_OP_ATTRS_H_ 16 #define TENSORFLOW_C_EAGER_ABSTRACT_OP_ATTRS_H_ 17 18 #include "tensorflow/core/framework/attr_value.pb.h" 19 #include "tensorflow/core/platform/status.h" 20 21 namespace tensorflow { 22 23 // Attributes of an op. 24 class AbstractOpAttrs { 25 protected: 26 enum AbstractOpAttrsKind { kEager, kTfrt }; AbstractOpAttrs(AbstractOpAttrsKind kind)27 explicit AbstractOpAttrs(AbstractOpAttrsKind kind) : kind_(kind) {} 28 29 public: 30 // Returns which subclass is this instance of. getKind()31 AbstractOpAttrsKind getKind() const { return kind_; } 32 virtual ~AbstractOpAttrs() = default; 33 34 // Returns the AbstractFunction as a FunctionDef. 35 virtual void GetNameAttrList( 36 tensorflow::NameAttrList* name_and_attrs) const = 0; 37 38 virtual bool GetInt(absl::string_view, int64_t* result) const = 0; 39 virtual bool GetFloat(absl::string_view attr_name, float* result) const = 0; 40 virtual bool GetBool(absl::string_view attr_name, bool* result) const = 0; 41 virtual bool GetType(absl::string_view attr_name, DataType* result) const = 0; 42 43 private: 44 const AbstractOpAttrsKind kind_; 45 }; 46 47 } // namespace tensorflow 48 49 #endif // TENSORFLOW_C_EAGER_ABSTRACT_OP_ATTRS_H_ 50