Publishing R5 content (#72)
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / kernel_selector / common / common_types.h
1 // Copyright (c) 2016-2018 Intel Corporation
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 #pragma once
16
17 #include <cstddef>
18 #include <cstdint>
19
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         BORDER,
62         TILE,
63         SELECT,
64         BROADCAST,
65         GEMM,
66         INDEX_SELECT
67     };
68
69     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
70     // Datatype
71     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
72     enum class Datatype
73     {
74         UNSUPPORTED,
75         INT8,
76         UINT8,
77         INT16,
78         UINT16,
79         INT32,
80         UINT32,
81         INT64,
82         F16,
83         F32,
84     };
85
86     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
87     // WeightsType
88     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
89     enum class WeightsType
90     {
91         UNSUPPORTED,
92         F16,
93         F32,
94         INT8,
95     };
96
97     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
98     // NonLinearActivation
99     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
100     enum class ActivationFunction
101     {
102         LOGISTIC,
103         HYPERBOLIC_TAN,
104         RELU,
105         RELU_NEGATIVE_SLOPE,
106         CLAMP,
107         SOFTRELU,
108         ABS,
109         SQUARE,
110         SQRT,
111         LINEAR,
112         ELU,
113         RELU_GRAD,
114         RELU_NEGATIVE_SLOPE_GRAD,
115         SIN,
116         ASIN,
117         SINH,
118         COS,
119         ACOS,
120         COSH,
121         LOG,
122                 LOG2,
123         EXP,
124         NONE,
125         NONE_GRAD
126     };
127
128     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
129     // PoolType
130     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
131     enum class PoolType
132     {
133         MAX,
134         AVG,
135         MAX_WITH_ARGMAX,
136         BILINEAR
137     };
138
139     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
140     // PoolRemainder
141     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
142     enum class PoolRemainder
143     {
144         FLOOR,
145         CEIL
146     };
147
148     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
149     // LRNMode
150     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
151     enum class LRNMode
152     {
153         ACROSS_CHANNEL,
154         WITHIN_CHANNEL
155     };
156
157     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
158     // LookUpTableAxis
159     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
160     enum class LookUpTableAxis
161     {
162         BATCH,
163         FEATURE,
164         X,
165         Y,
166         XYF
167     };
168
169         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
170         // EmbedAxis
171         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
172         enum class EmbedAxis
173         {
174                 BATCH,
175                 FEATURE,
176                 X,
177                 Y,
178                 XYF
179         };
180
181         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
182         // ArgMaxMinDim
183         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
184         enum class ArgMaxMinAxis
185         {
186                 BATCH,
187                 FEATURE,
188                 X,
189                 Y,
190                 XYF
191         };
192
193         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
194         // ArgMaxMinOut
195         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
196         enum class ArgMaxMinOut
197         {
198                 MAX,
199                 MIN
200         };
201
202     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
203     // NormalizeMode
204     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
205     enum class NormalizeMode
206     {
207         ACROSS_SPATIAL,
208         WITHIN_SPATIAL
209     };
210
211     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
212     // MVNMode
213     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
214     enum class MVNMode
215     {
216         ACROSS_CHANNELS,
217         WITHIN_CHANNELS
218     };
219
220     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
221     // LRNMode
222     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
223     enum class KernelDividerMode
224     {
225         DONT_CARE,
226         FIXED,
227         DYNAMIC,
228         DYNAMIC_WITH_PADDING
229     };
230
231     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
232     // EltwiseMode
233     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
234     enum class EltwiseMode
235     {
236         ADD,
237         SUB,
238         MUL,
239         DIV,
240         MIN,
241         MAX,
242         POW,
243         MODULU,
244         SQRT,
245         RSQRT,
246         ASSIGN
247     };
248
249     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
250     // EltwiseInputMode
251     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
252     enum class EltwiseInputMode
253     {
254         SCALAR,
255         INPUT_BUFFER,
256         UNORDERED_ACCESS_INPUT_BUFFER,
257         INTERMEDIATE_RESULTS_INDEX,
258         OUTPUT_BUFFER
259     };
260
261     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
262     // SoftmaxDim
263     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
264     enum class SoftmaxDim
265     {
266         X,
267         Y,
268         FEATURE,
269     };
270
271     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
272     // ReorderMode
273     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
274     enum class ReorderMode
275     {
276         xyzw, // Do nothing
277         xywz,
278         xwyz,
279         wxyz,
280         xzyw,
281         zyxw,
282         yxzw,
283     };
284
285     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
286     // MeanSubsructMode
287     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
288     enum class MeanSubtractMode
289     {
290         NONE,
291         INSIDE_PARAMS, // the index is feature id (modulu size) 
292         IN_BUFFER,
293     };
294
295     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
296     // MeanOp
297     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
298     enum class MeanOp
299     {
300         NONE,
301         SUB,
302         MUL, 
303         DIV,
304     };
305
306     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
307     // ConcatAxis
308     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
309     enum class ConcatAxis
310     {
311         X,
312         Y,
313         FEATURE,
314         BATCH,
315     };
316
317     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
318     // TileAxis
319     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
320     enum class TileAxis
321     {
322         X,
323         Y,
324         FEATURE,
325         BATCH,
326     };
327
328     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
329     // SampleType
330     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
331     enum class SampleType
332     {
333         NEAREST,
334         BILINEAR,
335     };
336
337     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
338     // BorderType
339     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
340     enum class BorderType
341     {
342         CONSTANT,
343         EDGE,
344         MIRROR,
345         MIRROR_101,
346     };
347
348     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
349     // IndexSelectAxis
350     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
351     enum class IndexSelectAxis
352     {
353         BATCH,
354         FEATURE,
355         X,
356         Y
357     };
358
359     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
360     // NonLinearParams
361     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
362     struct NonLinearParams
363     {
364         float m = 1.f;
365         float n = 0.f;
366
367         NonLinearParams() = default;
368         NonLinearParams(const float m, const float n) : m(m), n(n) {}
369     };
370
371     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
372     // Size
373     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
374     template <typename T>
375     struct Size {
376         T x = 0;
377         T y = 0;
378
379         Size() = default;
380         Size(T x, T y) : x(x), y(y) {}
381     };
382
383     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
384     // DimTensor
385     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
386     template <typename T = std::uint32_t>
387     struct DimTensor {
388         T b = 0;
389         T f = 0;
390         T y = 0;
391         T x = 0;
392
393         DimTensor() = default;
394         DimTensor(T b, T f, T y, T x) : b(b), f(f), y(y), x(x) {}
395     };
396
397     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
398     // AutoTunerMode
399     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
400     enum class TuningMode
401     {
402         TUNING_DISABLED,        // Tuning is disabled.
403         TUNING_USE_CACHE,       // Tuning using the cached data (no on-line tuning for non-existing data).
404         TUNING_TUNE_AND_CACHE   // Tuning using the cached data if exist, tune and update cache otherwise.attention_params
405     };
406
407     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
408     // Aliases:
409     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
410     using uSize  = Size<std::uint32_t>;
411     using stSize = Size<std::size_t>;
412 }