• 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 #include "tensorflow/c/experimental/op_handler/wrapper_operation.h"
16 
17 namespace tensorflow {
WrapperOperation(AbstractOperation * parent_op,AbstractOperationKind kind)18 WrapperOperation::WrapperOperation(AbstractOperation* parent_op,
19                                    AbstractOperationKind kind)
20     : AbstractOperation(kind), parent_op_(parent_op) {
21   // TODO(b/172003047): Consider making AbstractOperation RefCounted.
22   // parent_op_->Ref();
23 }
Release()24 void WrapperOperation::Release() {
25   parent_op_->Release();
26   // TODO(b/172003047): Consider making AbstractOperation RefCounted.
27   delete this;
28 }
29 
Reset(const char * op,const char * raw_device_name)30 Status WrapperOperation::Reset(const char* op, const char* raw_device_name) {
31   return parent_op_->Reset(op, raw_device_name);
32 }
Name() const33 const string& WrapperOperation::Name() const { return parent_op_->Name(); }
DeviceName() const34 const string& WrapperOperation::DeviceName() const {
35   return parent_op_->DeviceName();
36 }
SetDeviceName(const char * name)37 Status WrapperOperation::SetDeviceName(const char* name) {
38   return parent_op_->SetDeviceName(name);
39 }
AddInput(AbstractTensorHandle * input)40 Status WrapperOperation::AddInput(AbstractTensorHandle* input) {
41   return parent_op_->AddInput(input);
42 }
AddInputList(absl::Span<AbstractTensorHandle * const> inputs)43 Status WrapperOperation::AddInputList(
44     absl::Span<AbstractTensorHandle* const> inputs) {
45   return parent_op_->AddInputList(inputs);
46 }
SetAttrString(const char * attr_name,const char * data,size_t length)47 Status WrapperOperation::SetAttrString(const char* attr_name, const char* data,
48                                        size_t length) {
49   return parent_op_->SetAttrString(attr_name, data, length);
50 }
SetAttrInt(const char * attr_name,int64_t value)51 Status WrapperOperation::SetAttrInt(const char* attr_name, int64_t value) {
52   return parent_op_->SetAttrInt(attr_name, value);
53 }
SetAttrFloat(const char * attr_name,float value)54 Status WrapperOperation::SetAttrFloat(const char* attr_name, float value) {
55   return parent_op_->SetAttrFloat(attr_name, value);
56 }
SetAttrBool(const char * attr_name,bool value)57 Status WrapperOperation::SetAttrBool(const char* attr_name, bool value) {
58   return parent_op_->SetAttrBool(attr_name, value);
59 }
SetAttrType(const char * attr_name,DataType value)60 Status WrapperOperation::SetAttrType(const char* attr_name, DataType value) {
61   return parent_op_->SetAttrType(attr_name, value);
62 }
SetAttrShape(const char * attr_name,const int64_t * dims,const int num_dims)63 Status WrapperOperation::SetAttrShape(const char* attr_name,
64                                       const int64_t* dims, const int num_dims) {
65   return parent_op_->SetAttrShape(attr_name, dims, num_dims);
66 }
SetAttrFunction(const char * attr_name,const AbstractOperation * value)67 Status WrapperOperation::SetAttrFunction(const char* attr_name,
68                                          const AbstractOperation* value) {
69   return parent_op_->SetAttrFunction(attr_name, value);
70 }
SetAttrFunctionName(const char * attr_name,const char * value,size_t length)71 Status WrapperOperation::SetAttrFunctionName(const char* attr_name,
72                                              const char* value, size_t length) {
73   return parent_op_->SetAttrFunctionName(attr_name, value, length);
74 }
SetAttrTensor(const char * attr_name,AbstractTensorInterface * tensor)75 Status WrapperOperation::SetAttrTensor(const char* attr_name,
76                                        AbstractTensorInterface* tensor) {
77   return parent_op_->SetAttrTensor(attr_name, tensor);
78 }
SetAttrStringList(const char * attr_name,const void * const * values,const size_t * lengths,int num_values)79 Status WrapperOperation::SetAttrStringList(const char* attr_name,
80                                            const void* const* values,
81                                            const size_t* lengths,
82                                            int num_values) {
83   return parent_op_->SetAttrStringList(attr_name, values, lengths, num_values);
84 }
SetAttrFloatList(const char * attr_name,const float * values,int num_values)85 Status WrapperOperation::SetAttrFloatList(const char* attr_name,
86                                           const float* values, int num_values) {
87   return parent_op_->SetAttrFloatList(attr_name, values, num_values);
88 }
SetAttrIntList(const char * attr_name,const int64_t * values,int num_values)89 Status WrapperOperation::SetAttrIntList(const char* attr_name,
90                                         const int64_t* values, int num_values) {
91   return parent_op_->SetAttrIntList(attr_name, values, num_values);
92 }
SetAttrTypeList(const char * attr_name,const DataType * values,int num_values)93 Status WrapperOperation::SetAttrTypeList(const char* attr_name,
94                                          const DataType* values,
95                                          int num_values) {
96   return parent_op_->SetAttrTypeList(attr_name, values, num_values);
97 }
SetAttrBoolList(const char * attr_name,const unsigned char * values,int num_values)98 Status WrapperOperation::SetAttrBoolList(const char* attr_name,
99                                          const unsigned char* values,
100                                          int num_values) {
101   return parent_op_->SetAttrBoolList(attr_name, values, num_values);
102 }
SetAttrShapeList(const char * attr_name,const int64_t ** dims,const int * num_dims,int num_values)103 Status WrapperOperation::SetAttrShapeList(const char* attr_name,
104                                           const int64_t** dims,
105                                           const int* num_dims, int num_values) {
106   return parent_op_->SetAttrShapeList(attr_name, dims, num_dims, num_values);
107 }
SetAttrFunctionList(const char * attr_name,absl::Span<const AbstractOperation * > values)108 Status WrapperOperation::SetAttrFunctionList(
109     const char* attr_name, absl::Span<const AbstractOperation*> values) {
110   return parent_op_->SetAttrFunctionList(attr_name, values);
111 }
GetBackingOperation()112 AbstractOperation* WrapperOperation::GetBackingOperation() {
113   return parent_op_;
114 }
Execute(absl::Span<AbstractTensorHandle * > retvals,int * num_retvals)115 Status WrapperOperation::Execute(absl::Span<AbstractTensorHandle*> retvals,
116                                  int* num_retvals) {
117   return parent_op_->Execute(retvals, num_retvals);
118 }
119 
120 }  // namespace tensorflow
121