Publishing R3
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / kernel_selector / common / common_types.h
1 /*
2 // Copyright (c) 2016 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 #pragma once
18 #include <cstddef>
19 #include <stdint.h>
20
21 namespace kernel_selector
22 {
23     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
24     // KernelType
25     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
26     enum class KernelType
27     {
28         UNKNOWN,
29                 ARG_MAX_MIN,
30         AVERAGE_UNPOOLING,
31         BATCH_NORM_GRAD,
32         LOOKUP_TABLE,
33         CONVOLUTION,
34         DECONVOLUTION,
35         LRN,
36         NORMALIZE,
37         POOLING,
38         ROI_POOLING,
39         FULLY_CONNECTED,
40         ACTIVATION,
41         SOFT_MAX,
42         ELTWISE,
43         TABLE_LOOKUP,
44         REORDER,
45         RESHAPE,
46         PERMUTE,
47         CONCATENATION,
48         UPSAMPLING,
49         REGION_YOLO,
50         REORG_YOLO,
51         MAX_UNPOOLING,
52         CONVOLUTION_GRAD_WEIGHTS,
53         SCALE_GRAD_WEIGHTS,
54         MVN,
55         FULLY_CONNECTED_GRAD_INPUT,
56         FULLY_CONNECTED_GRAD_WEIGHTS,
57         LSTM_GEMM,
58         LSTM_ELT,
59         EMBED,
60         SOFT_MAX_LOSS_GRAD
61     };
62
63     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
64     // Datatype
65     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
66     enum class Datatype
67     {
68         UNSUPPORTED,
69         INT8,
70         UINT8,
71         INT16,
72         UINT16,
73         INT32,
74         UINT32,
75         F16,
76         F32,
77     };
78
79     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
80     // WeightsType
81     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
82     enum class WeightsType
83     {
84         UNSUPPORTED,
85         F16,
86         F32,
87         INT8,
88     };
89
90     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
91     // NonLinearActivation
92     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
93     enum class ActivationFunction
94     {
95         LOGISTIC,
96         HYPERBOLIC_TAN,
97         RELU,
98         RELU_NEGATIVE_SLOPE,
99         CLAMP,
100         SOFTRELU,
101         ABS,
102         SQUARE,
103         SQRT,
104         LINEAR,
105         ELU,
106         RELU_GRAD,
107         RELU_NEGATIVE_SLOPE_GRAD,
108         NONE,
109         NONE_GRAD
110     };
111
112     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
113     // PoolType
114     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
115     enum class PoolType
116     {
117         MAX,
118         AVG,
119         MAX_WITH_ARGMAX
120     };
121
122     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
123     // PoolRemainder
124     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
125     enum class PoolRemainder
126     {
127         FLOOR,
128         CEIL
129     };
130
131     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
132     // LRNMode
133     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
134     enum class LRNMode
135     {
136         ACROSS_CHANNEL,
137         WITHIN_CHANNEL
138     };
139
140     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
141     // LookUpTableAxis
142     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
143     enum class LookUpTableAxis
144     {
145         BATCH,
146         FEATURE,
147         X,
148         Y,
149         XYF
150     };
151
152         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
153         // EmbedAxis
154         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
155         enum class EmbedAxis
156         {
157                 BATCH,
158                 FEATURE,
159                 X,
160                 Y,
161                 XYF
162         };
163
164         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
165         // ArgMaxMinDim
166         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
167         enum class ArgMaxMinAxis
168         {
169                 BATCH,
170                 FEATURE,
171                 X,
172                 Y,
173                 XYF
174         };
175
176         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
177         // ArgMaxMinOut
178         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
179         enum class ArgMaxMinOut
180         {
181                 MAX,
182                 MIN
183         };
184
185     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
186     // NormalizeMode
187     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
188     enum class NormalizeMode
189     {
190         ACROSS_SPATIAL,
191         WITHIN_SPATIAL
192     };
193
194     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
195     // MVNMode
196     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
197     enum class MVNMode
198     {
199         ACROSS_CHANNELS,
200         WITHIN_CHANNELS
201     };
202
203     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
204     // LRNMode
205     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
206     enum class KernelDividerMode
207     {
208         DONT_CARE,
209         FIXED,
210         DYNAMIC,
211         DYNAMIC_WITH_PADDING
212     };
213
214     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
215     // EltwiseMode
216     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
217     enum class EltwiseMode
218     {
219         ADD,
220         SUB,
221         MUL,
222         DIV,
223         MIN,
224         MAX,
225         POW,
226         MODULU,
227         SQRT,
228         RSQRT,
229         ASSIGN
230     };
231
232     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
233     // EltwiseInputMode
234     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
235     enum class EltwiseInputMode
236     {
237         SCALAR,
238         INPUT_BUFFER,
239         UNORDERED_ACCESS_INPUT_BUFFER,
240         INTERMEDIATE_RESULTS_INDEX,
241         OUTPUT_BUFFER
242     };
243
244     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
245     // SoftmaxDim
246     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
247     enum class SoftmaxDim
248     {
249         X,
250         Y,
251         FEATURE,
252     };
253
254     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
255     // ReorderMode
256     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
257     enum class ReorderMode
258     {
259         xyzw, // Do nothing
260         xywz,
261         xwyz,
262         wxyz,
263         xzyw,
264         zyxw,
265         yxzw,
266     };
267
268     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
269     // MeanSubsructMode
270     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
271     enum class MeanSubtractMode
272     {
273         NONE,
274         INSIDE_PARAMS, // the index is feature id (modulu size) 
275         IN_BUFFER,
276     };
277
278     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
279     // MeanOp
280     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
281     enum class MeanOp
282     {
283         NONE,
284         SUB,
285         MUL, 
286         DIV,
287     };
288
289     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
290     // ConcatAxis
291     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
292     enum class ConcatAxis
293     {
294         X,
295         Y,
296         FEATURE,
297         BATCH,
298     };
299
300     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
301     // SampleType
302     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
303     enum class SampleType
304     {
305         NEAREST,
306         BILINEAR,
307     };
308
309     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
310     // NonLinearParams
311     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
312     struct NonLinearParams
313     {
314         float m = 1.f;
315         float n = 0.f;
316
317         NonLinearParams() = default;
318         NonLinearParams(const NonLinearParams&) = default;
319         NonLinearParams& operator=(const NonLinearParams&) = default;
320         NonLinearParams(float m, float n) : m(m), n(n) {}
321     };
322
323     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
324     // Size
325     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
326     template <typename T>
327     struct Size {
328         T x = 0;
329         T y = 0;
330
331         Size() = default;
332         Size(const Size&) = default;
333         Size& operator=(const Size&) = default;
334         Size(T x, T y) : x(x), y(y) {}
335     };
336
337     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
338     // AutoTunerMode
339     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
340     enum class TuningMode
341     {
342         TUNING_DISABLED,        // Tuning is disabled.
343         TUNING_USE_CACHE,       // Tuning using the cached data (no on-line tuning for non-existing data).
344         TUNING_TUNE_AND_CACHE   // Tuning using the cached data if exist, tune and update cache otherwise.
345     };
346
347     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
348     // typedefs
349     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
350     typedef Size<uint32_t> uSize;
351     typedef Size<size_t>   stSize;
352  
353 }