Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / src / gna_plugin / dnn_traits.hpp
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 // dnn_traits.hpp : c++ trait approach to  define dnn objects
5 //
6
7 #pragma once
8
9 #include "dnn.h"
10
11 template<intel_dnn_operation_t layer>
12 struct DnnTrait {};
13
14 template<>
15 struct DnnTrait<kDnnDiagonalOp> {
16     using Type = intel_affine_t;
17     static Type *getLayer(intel_dnn_component_t &component) {
18         return &component.op.affine;
19     }
20 };
21
22 template<>
23 struct DnnTrait<kDnnPiecewiselinearOp> {
24     using Type = intel_piecewiselinear_t;
25     static Type *getLayer(intel_dnn_component_t &component) {
26         return &component.op.pwl;
27     }
28 };
29
30 template<>
31 struct DnnTrait<kDnnAffineOp> {
32     using Type = intel_affine_t;
33     static Type *getLayer(intel_dnn_component_t &component) {
34         return &component.op.affine;
35     }
36 };
37
38 template<>
39 struct DnnTrait<kDnnConvolutional1dOp> {
40     using Type = intel_convolutionalD_t;
41     static Type *getLayer(intel_dnn_component_t &component) {
42         return &component.op.conv1D;
43     }
44 };
45
46 template<>
47 struct DnnTrait<kDnnMaxPoolOp> {
48     using Type = intel_maxpool_t;
49     static Type *getLayer(intel_dnn_component_t &component) {
50         return &component.op.maxpool;
51     }
52 };
53
54 template<>
55 struct DnnTrait<kDnnRecurrentOp> {
56     using Type = intel_recurrent_t;
57     static Type *getLayer(intel_dnn_component_t &component) {
58         return &component.op.recurrent;
59     }
60 };
61
62 template<>
63 struct DnnTrait<kDnnInterleaveOp> {
64     using Type = intel_interleave_t;
65     static Type *getLayer(intel_dnn_component_t &component) {
66         return &component.op.interleave;
67     }
68 };
69
70 template<>
71 struct DnnTrait<kDnnDeinterleaveOp> {
72     using Type = intel_deinterleave_t;
73     static Type *getLayer(intel_dnn_component_t &component) {
74         return &component.op.deinterleave;
75     }
76 };
77
78 template<>
79 struct DnnTrait<kDnnCopyOp> {
80     using Type = intel_copy_t;
81     static Type *getLayer(intel_dnn_component_t &component) {
82         return &component.op.copy;
83     }
84 };
85
86 template<>
87 struct DnnTrait<kDnnNullOp> {
88     using Type = void;
89     static Type *getLayer(intel_dnn_component_t &component) {
90         return nullptr;
91     }
92 };