| 1 | package AI::TensorFlow::Libtensorflow::OperationDescription; | ||
| 2 | # ABSTRACT: Operation being built | ||
| 3 | $AI::TensorFlow::Libtensorflow::OperationDescription::VERSION = '0.0.7'; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | use namespace::autoclean; | ||
| 7 | use AI::TensorFlow::Libtensorflow::Lib qw(arg); | ||
| 8 | use AI::TensorFlow::Libtensorflow::Lib::FFIType::Variant::PackableArrayRef; | ||
| 9 | |||
| 10 | my $ffi = AI::TensorFlow::Libtensorflow::Lib->ffi; | ||
| 11 | $ffi->mangler(AI::TensorFlow::Libtensorflow::Lib->mangler_default); | ||
| 12 | $ffi->load_custom_type('AI::TensorFlow::Libtensorflow::Lib::FFIType::TFPtrSizeScalarRef' | ||
| 13 | => 'tf_attr_string_buffer' | ||
| 14 | ); | ||
| 15 | $ffi->load_custom_type('AI::TensorFlow::Libtensorflow::Lib::FFIType::TFPtrPtrLenSizeArrayRefScalar' | ||
| 16 | => 'tf_attr_string_list' | ||
| 17 | ); | ||
| 18 | $ffi->load_custom_type(PackableArrayRef('Int64ArrayRef', pack_type => 'q') | ||
| 19 | => 'tf_attr_int_list' | ||
| 20 | ); | ||
| 21 | $ffi->load_custom_type(PackableArrayRef('Float32ArrayRef', pack_type => 'f') | ||
| 22 | => 'tf_attr_float_list' | ||
| 23 | ); | ||
| 24 | $ffi->load_custom_type(PackableArrayRef('BoolArrayRef', pack_type => 'C') | ||
| 25 | => 'tf_attr_bool_list', | ||
| 26 | ); | ||
| 27 | |||
| 28 | $ffi->attach( [ 'NewOperation' => 'New' ] => [ | ||
| 29 | arg 'TF_Graph' => 'graph', | ||
| 30 | arg 'string' => 'op_type', | ||
| 31 | arg 'string' => 'oper_name', | ||
| 32 | ] => 'TF_OperationDescription' => sub { | ||
| 33 | my ($xs, $class, @rest) = @_; | ||
| 34 | $xs->(@rest); | ||
| 35 | }); | ||
| 36 | |||
| 37 | $ffi->attach( [ 'NewOperationLocked' => 'NewLocked' ] => [ | ||
| 38 | arg 'TF_Graph' => 'graph', | ||
| 39 | arg 'string' => 'op_type', | ||
| 40 | arg 'string' => 'oper_name', | ||
| 41 | ] => 'TF_OperationDescription' ); | ||
| 42 | |||
| 43 | $ffi->attach( 'SetDevice' => [ | ||
| 44 | arg 'TF_OperationDescription' => 'desc', | ||
| 45 | arg 'string' => 'device', | ||
| 46 | ] => 'void'); | ||
| 47 | |||
| 48 | $ffi->attach( 'AddInput' => [ | ||
| 49 | arg 'TF_OperationDescription' => 'desc', | ||
| 50 | arg 'TF_Output' => 'input', | ||
| 51 | ] => 'void'); | ||
| 52 | |||
| 53 | $ffi->attach( AddInputList => [ | ||
| 54 | arg 'TF_OperationDescription' => 'desc', | ||
| 55 | arg 'TF_Output_struct_array' => 'inputs', | ||
| 56 | arg 'int' => 'num_inputs', | ||
| 57 | ] => 'void' => sub { | ||
| 58 | my $xs = shift; | ||
| 59 | $_[1] = AI::TensorFlow::Libtensorflow::Output->_as_array( @{ $_[1] } ); | ||
| 60 | $_[2] = $_[1]->count; | ||
| 61 | $xs->(@_); | ||
| 62 | }); | ||
| 63 | |||
| 64 | $ffi->attach( AddControlInput => [ | ||
| 65 | arg 'TF_OperationDescription' => 'desc', | ||
| 66 | arg 'TF_Operation' => 'input', | ||
| 67 | ] => 'void'); | ||
| 68 | |||
| 69 | $ffi->attach( ColocateWith => [ | ||
| 70 | arg 'TF_OperationDescription' => 'desc', | ||
| 71 | arg 'TF_Operation' => 'op', | ||
| 72 | ] => 'void'); | ||
| 73 | |||
| 74 | $ffi->attach( SetAttrString => [ | ||
| 75 | arg 'TF_OperationDescription' => 'desc', | ||
| 76 | arg 'string' => 'attr_name', | ||
| 77 | arg tf_attr_string_buffer => [qw(value length)], | ||
| 78 | ] => 'void'); | ||
| 79 | |||
| 80 | $ffi->attach(SetAttrStringList => [ | ||
| 81 | arg 'TF_OperationDescription' => 'desc', | ||
| 82 | arg 'string' => 'attr_name', | ||
| 83 | arg 'tf_attr_string_list' => [qw(values lengths num_values)], | ||
| 84 | ] => 'void'); | ||
| 85 | |||
| 86 | $ffi->attach( SetAttrInt => [ | ||
| 87 | arg 'TF_OperationDescription' => 'desc', | ||
| 88 | arg 'string' => 'attr_name', | ||
| 89 | arg int64_t => 'value', | ||
| 90 | ] => 'void'); | ||
| 91 | |||
| 92 | $ffi->attach( SetAttrIntList => [ | ||
| 93 | arg 'TF_OperationDescription' => 'desc', | ||
| 94 | arg 'string' => 'attr_name', | ||
| 95 | arg 'tf_attr_int_list' => [qw(values num_values)], | ||
| 96 | ] => 'void'); | ||
| 97 | |||
| 98 | $ffi->attach( SetAttrFloat => [ | ||
| 99 | arg 'TF_OperationDescription' => 'desc', | ||
| 100 | arg 'string' => 'attr_name', | ||
| 101 | arg 'float' => 'value', | ||
| 102 | ] => 'void'); | ||
| 103 | |||
| 104 | $ffi->attach(SetAttrFloatList => [ | ||
| 105 | arg 'TF_OperationDescription' => 'desc', | ||
| 106 | arg 'string' => 'attr_name', | ||
| 107 | arg 'tf_attr_float_list' => [qw(values num_values)], | ||
| 108 | ] => 'void'); | ||
| 109 | |||
| 110 | $ffi->attach( SetAttrBool => [ | ||
| 111 | arg 'TF_OperationDescription' => 'desc', | ||
| 112 | arg 'string' => 'attr_name', | ||
| 113 | arg 'unsigned char' => 'value', | ||
| 114 | ] => 'void'); | ||
| 115 | |||
| 116 | $ffi->attach( SetAttrBoolList => [ | ||
| 117 | arg 'TF_OperationDescription' => 'desc', | ||
| 118 | arg 'string' => 'attr_name', | ||
| 119 | arg 'tf_attr_bool_list' => [qw(values num_values)], | ||
| 120 | ] => 'void'); | ||
| 121 | |||
| 122 | $ffi->attach(SetAttrType => [ | ||
| 123 | arg 'TF_OperationDescription' => 'desc', | ||
| 124 | arg 'string' => 'attr_name', | ||
| 125 | arg 'TF_DataType' => 'value', | ||
| 126 | ] => 'void'); | ||
| 127 | |||
| 128 | $ffi->attach( SetAttrTypeList => [ | ||
| 129 | arg 'TF_OperationDescription' => 'desc', | ||
| 130 | arg 'string' => 'attr_name', | ||
| 131 | |||
| 132 | # TODO | ||
| 133 | arg 'opaque' => 'values', | ||
| 134 | #arg 'TF_DataType*' => 'values', | ||
| 135 | arg 'int' => 'num_values', | ||
| 136 | ]); | ||
| 137 | |||
| 138 | $ffi->attach( SetAttrPlaceholder => [ | ||
| 139 | arg 'TF_OperationDescription' => 'desc', | ||
| 140 | arg 'string' => 'attr_name', | ||
| 141 | arg 'string' => 'placeholder', | ||
| 142 | ] => 'void'); | ||
| 143 | |||
| 144 | $ffi->attach( SetAttrFuncName => [ | ||
| 145 | arg 'TF_OperationDescription' => 'desc', | ||
| 146 | arg 'string' => 'attr_name', | ||
| 147 | arg 'tf_attr_string_buffer' => [qw(value length)], | ||
| 148 | ] => 'void'); | ||
| 149 | |||
| 150 | $ffi->attach( SetAttrShape => [ | ||
| 151 | arg 'TF_OperationDescription' => 'desc', | ||
| 152 | arg 'string' => 'attr_name', | ||
| 153 | arg 'tf_dims_buffer' => [qw(dims num_dims)], | ||
| 154 | ] => 'void'); | ||
| 155 | |||
| 156 | $ffi->attach( SetAttrShapeList => [ | ||
| 157 | arg 'TF_OperationDescription' => 'desc', | ||
| 158 | arg 'string' => 'attr_name', | ||
| 159 | # TODO | ||
| 160 | arg 'opaque' => 'const int64_t* const* dims', | ||
| 161 | arg 'opaque' => 'const int* num_dims', | ||
| 162 | arg 'int' => 'num_shapes', | ||
| 163 | ]); | ||
| 164 | |||
| 165 | $ffi->attach(SetAttrTensorShapeProto => [ | ||
| 166 | arg 'TF_OperationDescription' => 'desc', | ||
| 167 | arg 'string' => 'attr_name', | ||
| 168 | arg 'tf_tensor_shape_proto_buffer' => [qw(proto proto_len)], | ||
| 169 | arg 'TF_Status' => 'status', | ||
| 170 | ] => 'void'); | ||
| 171 | |||
| 172 | $ffi->attach( SetAttrTensorShapeProtoList => [ | ||
| 173 | # TODO | ||
| 174 | ] => 'void'); | ||
| 175 | |||
| 176 | $ffi->attach( SetAttrTensor => [ | ||
| 177 | arg 'TF_OperationDescription' => 'desc', | ||
| 178 | arg 'string' => 'attr_name', | ||
| 179 | arg 'TF_Tensor' => 'value', | ||
| 180 | arg 'TF_Status' => 'status', | ||
| 181 | ] => 'void'); | ||
| 182 | |||
| 183 | $ffi->attach( SetAttrTensorList => [ | ||
| 184 | # TODO | ||
| 185 | ] => 'void'); | ||
| 186 | |||
| 187 | $ffi->attach(SetAttrValueProto => [ | ||
| 188 | arg 'TF_OperationDescription' => 'desc', | ||
| 189 | arg 'string' => 'attr_name', | ||
| 190 | arg 'tf_attr_value_proto_buffer' => [qw(proto proto_len)], | ||
| 191 | arg 'TF_Status' => 'status', | ||
| 192 | ] => 'void'); | ||
| 193 | |||
| 194 | $ffi->attach(FinishOperation => [ | ||
| 195 | arg 'TF_OperationDescription' => 'desc', | ||
| 196 | arg 'TF_Status' => 'status', | ||
| 197 | ] => 'TF_Operation'); | ||
| 198 | |||
| 199 | $ffi->attach(FinishOperationLocked => [ | ||
| 200 | arg 'TF_OperationDescription' => 'desc', | ||
| 201 | arg 'TF_Status' => 'status', | ||
| 202 | ] => 'TF_Operation'); | ||
| 203 | |||
| 204 | 1; | ||
| 205 | |||
| 206 | __END__ |