xref: /aosp_15_r20/external/tensorflow/tensorflow/c/experimental/ops/gen/model/op_spec.h (revision b6fb3261f9314811a0f4371741dbb8839866f948)
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_OP_SPEC_H_
16 #define TENSORFLOW_C_EXPERIMENTAL_OPS_GEN_MODEL_OP_SPEC_H_
17 
18 #include <map>
19 #include <vector>
20 
21 #include "tensorflow/c/experimental/ops/gen/model/arg_spec.h"
22 #include "tensorflow/c/experimental/ops/gen/model/attr_spec.h"
23 #include "tensorflow/core/framework/api_def.pb.h"
24 #include "tensorflow/core/framework/op_def.pb.h"
25 #include "tensorflow/core/platform/types.h"
26 
27 namespace tensorflow {
28 namespace generator {
29 
30 // An Op.
31 //
32 // Essentially, this represents an OpDef and any necessary context (e.g ApiDef).
33 class OpSpec {
34  public:
35   static OpSpec Create(const OpDef& op_def, const ApiDef& api_def);
36 
name()37   const string& name() const { return name_; }
summary()38   const string& summary() const { return summary_; }
description()39   const string& description() const { return description_; }
Inputs()40   const std::vector<ArgSpec>& Inputs() const { return input_args_; }
Outputs()41   const std::vector<ArgSpec>& Outputs() const { return output_args_; }
Attributes()42   const std::vector<AttrSpec>& Attributes() const { return argument_attrs_; }
43 
44  private:
45   explicit OpSpec(const OpDef& op_def, const ApiDef& api_def);
46 
47  private:
48   string name_;
49   string summary_;
50   string description_;
51   std::vector<ArgSpec> input_args_;
52   std::vector<ArgSpec> output_args_;
53   std::vector<AttrSpec> argument_attrs_;
54   std::map<string, AttrSpec> type_attrs_;
55 };
56 
57 }  // namespace generator
58 }  // namespace tensorflow
59 
60 #endif  // TENSORFLOW_C_EXPERIMENTAL_OPS_GEN_MODEL_OP_SPEC_H_
61