Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / tests / unit / engines / mkldnn / test_layers.cpp
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 //#include <gtest/gtest.h>
6 //#include "mkldnn_plugin/mkldnn_layers.h"
7 //
8 //using namespace std;
9 //
10 //class MKLDNNLayersTests : public ::testing::Test {
11 //protected:
12 //    virtual void TearDown() override{
13 //    }
14 //
15 //    virtual void SetUp() override{
16 //    }
17 //
18 //};
19 //
20 //TEST_F(MKLDNNLayersTests, canCreateContext) {
21 //    std::vector<float> sd;
22 //    std::vector<float> dd;
23 //    std::vector<size_t> ds;
24 //    unique_ptr<MKLDNNPlugin::Context> dl ( new MKLDNNPlugin::Context({}, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
25 //
26 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(dl.get()));
27 //}
28 //
29 //TEST_F(MKLDNNLayersTests, canCreateConvLayer) {
30 //    std::vector<float> sd;
31 //    std::vector<float> dd;
32 //    std::vector<size_t> ds;
33 //    InferenceEngine::TBlob<float>::Ptr blobPtr(new InferenceEngine::TBlob<float>());
34 //    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context(blobPtr, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
35 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
36 //
37 //    InferenceEngine::ConvolutionLayer convLayer({});
38 //    InferenceEngine::DataPtr dPtr(new InferenceEngine::Data("testData"));
39 //    dPtr->dims = {0, 0, 0, 0};
40 //
41 //    convLayer.insData.push_back(dPtr);
42 //    convLayer.outData.push_back(dPtr);
43 //    unique_ptr<MKLDNNPlugin::Layer> dl ( MKLDNNPlugin::LayerRegistry::CreateLayer(&convLayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())));
44 //
45 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::ConvLayer*>(dl.get()));
46 //}
47 //
48 //TEST_F(MKLDNNLayersTests, canCreateLRNLayer) {
49 //    std::vector<float> sd;
50 //    std::vector<float> dd;
51 //    std::vector<size_t> ds;
52 //    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context({}, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
53 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
54 //
55 //    InferenceEngine::NormLayer normLayer({});
56 //    InferenceEngine::DataPtr dPtr(new InferenceEngine::Data("testData"));
57 //    dPtr->dims = {1, 1, 27, 27};
58 //
59 //    normLayer.insData.push_back(dPtr);
60 //    normLayer.outData.push_back(dPtr);
61 //    unique_ptr<MKLDNNPlugin::Layer> dl ( MKLDNNPlugin::LayerRegistry::CreateLayer(&normLayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())));
62 //
63 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::LRNLayer*>(dl.get()));
64 //}
65 //
66 //TEST_F(MKLDNNLayersTests, canCreatePoolingLayer) {
67 //    std::vector<float> sd;
68 //    std::vector<float> dd;
69 //    std::vector<size_t> ds;
70 //    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context({}, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
71 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
72 //
73 //    InferenceEngine::PoolingLayer poolingLayer({});
74 //    InferenceEngine::DataPtr dPtr(new InferenceEngine::Data("testData"));
75 //    dPtr->dims = {1, 1, 27, 27};
76 //
77 //    poolingLayer.insData.push_back(dPtr);
78 //    poolingLayer.outData.push_back(dPtr);
79 //    unique_ptr<MKLDNNPlugin::Layer> dl ( MKLDNNPlugin::LayerRegistry::CreateLayer(&poolingLayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())));
80 //
81 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::PoolingLayer*>(dl.get()));
82 //}
83 //
84 //TEST_F(MKLDNNLayersTests, canCreateSplitLayer) {
85 //    std::vector<float> sd;
86 //    std::vector<float> dd;
87 //    std::vector<size_t> ds;
88 //    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context({}, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
89 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
90 //
91 //    InferenceEngine::SplitLayer splitLayer({});
92 //    unique_ptr<MKLDNNPlugin::Layer> dl ( MKLDNNPlugin::LayerRegistry::CreateLayer(&splitLayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())));
93 //
94 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::SplitLayer*>(dl.get()));
95 //}
96 //
97 //TEST_F(MKLDNNLayersTests, canCreateConcatLayer) {
98 //    std::vector<float> sd;
99 //    std::vector<float> dd;
100 //    std::vector<size_t> ds;
101 //    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context({}, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
102 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
103 //
104 //    InferenceEngine::ConcatLayer concatLayer({});
105 //    unique_ptr<MKLDNNPlugin::Layer> dl ( MKLDNNPlugin::LayerRegistry::CreateLayer(&concatLayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())));
106 //
107 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::ConcatLayer*>(dl.get()));
108 //}
109 //
110 //TEST_F(MKLDNNLayersTests, canCreateFullyConnectedLayer) {
111 //    std::vector<float> sd;
112 //    std::vector<float> dd;
113 //    std::vector<size_t> ds;
114 //    InferenceEngine::TBlob<float>::Ptr blobPtr(new InferenceEngine::TBlob<float>());
115 //    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context(blobPtr, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
116 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
117 //
118 //    InferenceEngine::FullyConnectedLayer fcLayer({});
119 //    InferenceEngine::DataPtr dPtr(new InferenceEngine::Data("testData"));
120 //    dPtr->dims = {0, 0, 0, 0};
121 //    InferenceEngine::DataPtr dPtr2(new InferenceEngine::Data("testData2"));
122 //    dPtr2->dims = {0, 0};
123 //
124 //    fcLayer.insData.push_back(dPtr);
125 //    fcLayer.outData.push_back(dPtr2);
126 //    unique_ptr<MKLDNNPlugin::Layer> dl ( MKLDNNPlugin::LayerRegistry::CreateLayer(&fcLayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())));
127 //
128 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::FullyConnectedLayer*>(dl.get()));
129 //}
130 //
131 //TEST_F(MKLDNNLayersTests, canCreateSoftMaxLayer) {
132 //    std::vector<float> sd;
133 //    std::vector<float> dd;
134 //    std::vector<size_t> ds;
135 //    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context({}, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
136 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
137 //
138 //    InferenceEngine::SoftMaxLayer softmaxLayer({});
139 //    InferenceEngine::DataPtr dPtr(new InferenceEngine::Data("testData"));
140 //    dPtr->dims = {0, 0, 0, 0};
141 //    InferenceEngine::DataPtr dPtr2(new InferenceEngine::Data("testData2"));
142 //    dPtr2->dims = {0, 0};
143 //
144 //    softmaxLayer.insData.push_back(dPtr);
145 //    softmaxLayer.outData.push_back(dPtr2);
146 //    unique_ptr<MKLDNNPlugin::Layer> dl ( MKLDNNPlugin::LayerRegistry::CreateLayer(&softmaxLayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())));
147 //
148 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::SoftMaxLayer*>(dl.get()));
149 //}
150 //
151 //TEST_F(MKLDNNLayersTests, canCreateReLULayer) {
152 //    std::vector<float> sd;
153 //    std::vector<float> dd;
154 //    std::vector<size_t> ds;
155 //    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context({}, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
156 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
157 //
158 //    InferenceEngine::ReLULayer reLULayer({});
159 //    InferenceEngine::DataPtr dPtr(new InferenceEngine::Data("testData"));
160 //    dPtr->dims = {1, 1, 27, 27};
161 //
162 //    reLULayer.insData.push_back(dPtr);
163 //    reLULayer.outData.push_back(dPtr);
164 //    unique_ptr<MKLDNNPlugin::Layer> dl ( MKLDNNPlugin::LayerRegistry::CreateLayer(&reLULayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())));
165 //
166 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::ReLULayer*>(dl.get()));
167 //}
168 //
169 //TEST_F(MKLDNNLayersTests, canNotCreateCNNLayer) {
170 //    std::vector<float> sd;
171 //    std::vector<float> dd;
172 //    std::vector<size_t> ds;
173 //    unique_ptr<MKLDNNPlugin::Context> ctx ( new MKLDNNPlugin::Context({}, mkldnn::engine(mkldnn::engine::cpu, 0), &sd, &dd, &ds));
174 //    ASSERT_NE(nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get()));
175 //
176 //    InferenceEngine::CNNLayer cnnLayer({});
177 //    EXPECT_THROW(MKLDNNPlugin::LayerRegistry::CreateLayer(&cnnLayer, nullptr, dynamic_cast<MKLDNNPlugin::Context*>(ctx.get())) , InferenceEngine::details::InferenceEngineException);
178 //}
179 //
180 //TEST_F(MKLDNNLayersTests, canNotCreateLayerWithoutContext) {
181 //    InferenceEngine::ConvolutionLayer convLayer({});
182 //    EXPECT_THROW(MKLDNNPlugin::LayerRegistry::CreateLayer(&convLayer, nullptr, nullptr), InferenceEngine::details::InferenceEngineException);
183 //}