summaryrefslogtreecommitdiff
path: root/inference-engine/tests/unit/engines/mkldnn/test_layers.cpp
blob: 7db41747cabcdb941d924080e718eb8efe0a0b62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// Copyright (C) 2018 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

//#include <gtest/gtest.h>
//#include "mkldnn_plugin/mkldnn_layers.h"
//
//using namespace std;
//
//class MKLDNNLayersTests : public ::testing::Test {
//protected:
//    virtual void TearDown() override{
//    }
//
//    virtual void SetUp() override{
//    }
//
//};
//
//TEST_F(MKLDNNLayersTests, canCreateContext) {
//    std::vector<float> sd;
//    std::vector<float> dd;
//    std::vector<size_t> ds;
//    unique_ptr<MKLDNNPlugin::Context> dl ( new MKLDNNPlugin::Context({}, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
//
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(dl.get()));
//}
//
//TEST_F(MKLDNNLayersTests, canCreateConvLayer) {
//    std::vector<float> sd;
//    std::vector<float> dd;
//    std::vector<size_t> ds;
//    InferenceEngine::TBlob<float>::Ptr blobPtr(new InferenceEngine::TBlob<float>());
//    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context(blobPtr, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
//
//    InferenceEngine::ConvolutionLayer convLayer({});
//    InferenceEngine::DataPtr dPtr(new InferenceEngine::Data("testData"));
//    dPtr->dims = {0, 0, 0, 0};
//
//    convLayer.insData.push_back(dPtr);
//    convLayer.outData.push_back(dPtr);
//    unique_ptr<MKLDNNPlugin::Layer> dl ( MKLDNNPlugin::LayerRegistry::CreateLayer(&convLayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())));
//
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::ConvLayer*>(dl.get()));
//}
//
//TEST_F(MKLDNNLayersTests, canCreateLRNLayer) {
//    std::vector<float> sd;
//    std::vector<float> dd;
//    std::vector<size_t> ds;
//    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context({}, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
//
//    InferenceEngine::NormLayer normLayer({});
//    InferenceEngine::DataPtr dPtr(new InferenceEngine::Data("testData"));
//    dPtr->dims = {1, 1, 27, 27};
//
//    normLayer.insData.push_back(dPtr);
//    normLayer.outData.push_back(dPtr);
//    unique_ptr<MKLDNNPlugin::Layer> dl ( MKLDNNPlugin::LayerRegistry::CreateLayer(&normLayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())));
//
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::LRNLayer*>(dl.get()));
//}
//
//TEST_F(MKLDNNLayersTests, canCreatePoolingLayer) {
//    std::vector<float> sd;
//    std::vector<float> dd;
//    std::vector<size_t> ds;
//    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context({}, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
//
//    InferenceEngine::PoolingLayer poolingLayer({});
//    InferenceEngine::DataPtr dPtr(new InferenceEngine::Data("testData"));
//    dPtr->dims = {1, 1, 27, 27};
//
//    poolingLayer.insData.push_back(dPtr);
//    poolingLayer.outData.push_back(dPtr);
//    unique_ptr<MKLDNNPlugin::Layer> dl ( MKLDNNPlugin::LayerRegistry::CreateLayer(&poolingLayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())));
//
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::PoolingLayer*>(dl.get()));
//}
//
//TEST_F(MKLDNNLayersTests, canCreateSplitLayer) {
//    std::vector<float> sd;
//    std::vector<float> dd;
//    std::vector<size_t> ds;
//    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context({}, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
//
//    InferenceEngine::SplitLayer splitLayer({});
//    unique_ptr<MKLDNNPlugin::Layer> dl ( MKLDNNPlugin::LayerRegistry::CreateLayer(&splitLayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())));
//
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::SplitLayer*>(dl.get()));
//}
//
//TEST_F(MKLDNNLayersTests, canCreateConcatLayer) {
//    std::vector<float> sd;
//    std::vector<float> dd;
//    std::vector<size_t> ds;
//    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context({}, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
//
//    InferenceEngine::ConcatLayer concatLayer({});
//    unique_ptr<MKLDNNPlugin::Layer> dl ( MKLDNNPlugin::LayerRegistry::CreateLayer(&concatLayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())));
//
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::ConcatLayer*>(dl.get()));
//}
//
//TEST_F(MKLDNNLayersTests, canCreateFullyConnectedLayer) {
//    std::vector<float> sd;
//    std::vector<float> dd;
//    std::vector<size_t> ds;
//    InferenceEngine::TBlob<float>::Ptr blobPtr(new InferenceEngine::TBlob<float>());
//    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context(blobPtr, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
//
//    InferenceEngine::FullyConnectedLayer fcLayer({});
//    InferenceEngine::DataPtr dPtr(new InferenceEngine::Data("testData"));
//    dPtr->dims = {0, 0, 0, 0};
//    InferenceEngine::DataPtr dPtr2(new InferenceEngine::Data("testData2"));
//    dPtr2->dims = {0, 0};
//
//    fcLayer.insData.push_back(dPtr);
//    fcLayer.outData.push_back(dPtr2);
//    unique_ptr<MKLDNNPlugin::Layer> dl ( MKLDNNPlugin::LayerRegistry::CreateLayer(&fcLayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())));
//
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::FullyConnectedLayer*>(dl.get()));
//}
//
//TEST_F(MKLDNNLayersTests, canCreateSoftMaxLayer) {
//    std::vector<float> sd;
//    std::vector<float> dd;
//    std::vector<size_t> ds;
//    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context({}, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
//
//    InferenceEngine::SoftMaxLayer softmaxLayer({});
//    InferenceEngine::DataPtr dPtr(new InferenceEngine::Data("testData"));
//    dPtr->dims = {0, 0, 0, 0};
//    InferenceEngine::DataPtr dPtr2(new InferenceEngine::Data("testData2"));
//    dPtr2->dims = {0, 0};
//
//    softmaxLayer.insData.push_back(dPtr);
//    softmaxLayer.outData.push_back(dPtr2);
//    unique_ptr<MKLDNNPlugin::Layer> dl ( MKLDNNPlugin::LayerRegistry::CreateLayer(&softmaxLayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())));
//
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::SoftMaxLayer*>(dl.get()));
//}
//
//TEST_F(MKLDNNLayersTests, canCreateReLULayer) {
//    std::vector<float> sd;
//    std::vector<float> dd;
//    std::vector<size_t> ds;
//    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context({}, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
//
//    InferenceEngine::ReLULayer reLULayer({});
//    InferenceEngine::DataPtr dPtr(new InferenceEngine::Data("testData"));
//    dPtr->dims = {1, 1, 27, 27};
//
//    reLULayer.insData.push_back(dPtr);
//    reLULayer.outData.push_back(dPtr);
//    unique_ptr<MKLDNNPlugin::Layer> dl ( MKLDNNPlugin::LayerRegistry::CreateLayer(&reLULayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())));
//
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::ReLULayer*>(dl.get()));
//}
//
//TEST_F(MKLDNNLayersTests, canNotCreateCNNLayer) {
//    std::vector<float> sd;
//    std::vector<float> dd;
//    std::vector<size_t> ds;
//    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context({}, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
//    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
//
//    InferenceEngine::CNNLayer cnnLayer({});
//    EXPECT_THROW(MKLDNNPlugin::LayerRegistry::CreateLayer(&cnnLayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())) , InferenceEngine::details::InferenceEngineException);
//}
//
//TEST_F(MKLDNNLayersTests, canNotCreateLayerWithoutContext) {
//    InferenceEngine::ConvolutionLayer convLayer({});
//    EXPECT_THROW(MKLDNNPlugin::LayerRegistry::CreateLayer(&convLayer, nullptr, nullptr), InferenceEngine::details::InferenceEngineException);
//}