1 /* Copyright 2017 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_CONTRIB_LITE_BUILTIN_OP_DATA_H_
16 #define TENSORFLOW_CONTRIB_LITE_BUILTIN_OP_DATA_H_
17 
18 #include <stdint.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif  // __cplusplus
23 
24 // TODO(aselle): Consider using "if this then that" for testing.
25 
26 // Possible padding types (for convolutions)
27 typedef enum {
28   kTfLitePaddingUnknown = 0,
29   kTfLitePaddingSame,
30   kTfLitePaddingValid,
31 } TfLitePadding;
32 
33 typedef struct {
34   int width;
35   int height;
36 } TfLitePaddingValues;
37 
38 // Possible fused activation functions.
39 // TODO(aselle): rename to TfLiteActivation
40 typedef enum {
41   kTfLiteActNone = 0,
42   kTfLiteActRelu,
43   kTfLiteActRelu1,
44   kTfLiteActRelu6,
45   kTfLiteActTanh,
46   kTfLiteActSignBit,
47   kTfLiteActSigmoid,
48 } TfLiteFusedActivation;
49 
50 typedef struct {
51   TfLitePadding padding;
52   int stride_width;
53   int stride_height;
54   TfLiteFusedActivation activation;
55 } TfLiteConvParams;
56 
57 typedef struct {
58   TfLitePadding padding;
59   int stride_width;
60   int stride_height;
61   int filter_width;
62   int filter_height;
63   TfLiteFusedActivation activation;
64   struct {
65     TfLitePaddingValues padding;
66   } computed;
67 } TfLitePoolParams;
68 
69 typedef struct {
70   TfLitePadding padding;
71   int stride_width;
72   int stride_height;
73   int depth_multiplier;
74   TfLiteFusedActivation activation;
75 } TfLiteDepthwiseConvParams;
76 
77 typedef struct {
78   int rank;
79   TfLiteFusedActivation activation;
80 } TfLiteSVDFParams;
81 
82 typedef struct {
83   TfLiteFusedActivation activation;
84 } TfLiteRNNParams;
85 
86 typedef struct {
87   bool time_major;
88   TfLiteFusedActivation activation;
89 } TfLiteSequenceRNNParams;
90 
91 typedef struct {
92   TfLiteFusedActivation activation;
93 } TfLiteFullyConnectedParams;
94 
95 typedef enum {
96   kTfLiteLshProjectionUnknown = 0,
97   kTfLiteLshProjectionSparse = 1,
98   kTfLiteLshProjectionDense = 2,
99 } TfLiteLSHProjectionType;
100 
101 typedef struct {
102   TfLiteLSHProjectionType type;
103 } TfLiteLSHProjectionParams;
104 
105 typedef struct {
106   float beta;
107 } TfLiteSoftmaxParams;
108 
109 typedef struct {
110   int axis;
111   TfLiteFusedActivation activation;
112 } TfLiteConcatenationParams;
113 
114 typedef struct {
115   TfLiteFusedActivation activation;
116 } TfLiteAddParams;
117 
118 typedef struct {
119 } TfLiteSpaceToBatchNDParams;
120 
121 typedef struct {
122 } TfLiteBatchToSpaceNDParams;
123 
124 typedef struct {
125   TfLiteFusedActivation activation;
126 } TfLiteMulParams;
127 
128 typedef struct {
129   TfLiteFusedActivation activation;
130 } TfLiteSubParams;
131 
132 typedef struct {
133   TfLiteFusedActivation activation;
134 } TfLiteDivParams;
135 
136 typedef struct {
137   TfLiteFusedActivation activation;
138 } TfLiteL2NormParams;
139 
140 typedef struct {
141   int radius;
142   float bias;
143   float alpha;
144   float beta;
145 } TfLiteLocalResponseNormParams;
146 
147 typedef struct {
148   TfLiteFusedActivation activation;
149   float cell_clip;
150   float proj_clip;
151 } TfLiteLSTMParams;
152 
153 typedef struct {
154   bool align_corners;
155 } TfLiteResizeBilinearParams;
156 
157 typedef struct {
158 } TfLitePadParams;
159 
160 typedef struct {
161   // TODO(ahentz): We can't have dynamic data in this struct, at least not yet.
162   // For now we will fix the maximum possible number of dimensions.
163   int shape[8];
164   int num_dimensions;
165 } TfLiteReshapeParams;
166 
167 typedef struct {
168   int ngram_size;
169   int max_skip_size;
170   bool include_all_ngrams;
171 } TfLiteSkipGramParams;
172 
173 typedef struct {
174   int block_size;
175 } TfLiteSpaceToDepthParams;
176 
177 typedef enum {
178   kTfLiteCombinerTypeSum = 0,
179   kTfLiteCombinerTypeMean = 1,
180   kTfLiteCombinerTypeSqrtn = 2,
181 } TfLiteCombinerType;
182 
183 typedef struct {
184   TfLiteCombinerType combiner;
185 } TfLiteEmbeddingLookupSparseParams;
186 
187 typedef struct {
188   int axis;
189 } TfLiteGatherParams;
190 
191 typedef struct {
192 } TfLiteTransposeParams;
193 
194 typedef struct {
195   bool keep_dims;
196 } TfLiteMeanParams;
197 
198 typedef struct {
199   int num_splits;
200 } TfLiteSplitParams;
201 
202 typedef struct {
203   // TODO(ahentz): We can't have dynamic data in this struct, at least not yet.
204   // For now we will fix the maximum possible number of dimensions.
205   int squeeze_dims[8];
206   int num_squeeze_dims;
207 } TfLiteSqueezeParams;
208 
209 typedef struct {
210   int begin_mask;
211   int end_mask;
212   int ellipsis_mask;
213   int new_axis_mask;
214   int shrink_axis_mask;
215 } TfLiteStridedSliceParams;
216 
217 #ifdef __cplusplus
218 }  // extern "C"
219 #endif  // __cplusplus
220 
221 #endif  // TENSORFLOW_CONTRIB_LITE_BUILTIN_OP_DATA_H_
222