• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef TENSORFLOW_C_EXPERIMENTAL_OP_HANDLER_WRAPPER_OPERATION_H_
16 #define TENSORFLOW_C_EXPERIMENTAL_OP_HANDLER_WRAPPER_OPERATION_H_
17 
18 #include "tensorflow/c/eager/abstract_operation.h"
19 
20 namespace tensorflow {
21 
22 // Forwards all of the AbstractOperation's methods to its wrapped operation.
23 //
24 // Useful as a base class to default to forwarding while adding some
25 // customization.
26 class WrapperOperation : public AbstractOperation {
27  public:
28   explicit WrapperOperation(AbstractOperation*, AbstractOperationKind kind);
29   void Release() override;
30   Status Reset(const char* op, const char* raw_device_name) override;
31   const string& Name() const override;
32   const string& DeviceName() const override;
33   Status SetDeviceName(const char* name) override;
34   Status AddInput(AbstractTensorHandle* input) override;
35   Status AddInputList(absl::Span<AbstractTensorHandle* const> inputs) override;
36   Status Execute(absl::Span<AbstractTensorHandle*> retvals,
37                  int* num_retvals) override;
38   Status SetAttrString(const char* attr_name, const char* data,
39                        size_t length) override;
40   Status SetAttrInt(const char* attr_name, int64_t value) override;
41   Status SetAttrFloat(const char* attr_name, float value) override;
42   Status SetAttrBool(const char* attr_name, bool value) override;
43   Status SetAttrType(const char* attr_name, DataType value) override;
44   Status SetAttrShape(const char* attr_name, const int64_t* dims,
45                       const int num_dims) override;
46   Status SetAttrFunction(const char* attr_name,
47                          const AbstractOperation* value) override;
48   Status SetAttrFunctionName(const char* attr_name, const char* value,
49                              size_t length) override;
50   Status SetAttrTensor(const char* attr_name,
51                        AbstractTensorInterface* tensor) override;
52   Status SetAttrStringList(const char* attr_name, const void* const* values,
53                            const size_t* lengths, int num_values) override;
54   Status SetAttrFloatList(const char* attr_name, const float* values,
55                           int num_values) override;
56   Status SetAttrIntList(const char* attr_name, const int64_t* values,
57                         int num_values) override;
58   Status SetAttrTypeList(const char* attr_name, const DataType* values,
59                          int num_values) override;
60   Status SetAttrBoolList(const char* attr_name, const unsigned char* values,
61                          int num_values) override;
62   Status SetAttrShapeList(const char* attr_name, const int64_t** dims,
63                           const int* num_dims, int num_values) override;
64   Status SetAttrFunctionList(
65       const char* attr_name,
66       absl::Span<const AbstractOperation*> values) override;
67   AbstractOperation* GetBackingOperation();
68 
69  private:
70   AbstractOperation* parent_op_;
71 };
72 
73 }  // namespace tensorflow
74 #endif  // TENSORFLOW_C_EXPERIMENTAL_OP_HANDLER_WRAPPER_OPERATION_H_
75