Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / tests / unit / builders / elu_layer_test.cpp
1 // Copyright (C) 2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #include <gtest/gtest.h>
6 #include <string.h>
7 #include <ie_builders.hpp>
8 #include <builders/ie_elu_layer.hpp>
9
10 #include "builder_test.hpp"
11
12 using namespace testing;
13 using namespace InferenceEngine;
14
15 class ELULayerBuilderTest : public BuilderTestCommon {};
16
17 TEST_F(ELULayerBuilderTest, getExistsLayerFromNetworkBuilder) {
18     Builder::Network net("network");
19     Builder::ELULayer eluLayer("ELU_layer");
20     eluLayer.setAlpha(100);
21     size_t ind = net.addLayer(eluLayer);
22     Builder::ELULayer layerFromNet(net.getLayer(ind));
23     ASSERT_EQ(eluLayer.getAlpha(), layerFromNet.getAlpha());
24 }
25
26 TEST_F(ELULayerBuilderTest, cannotCreateLayerWithWrongShapes) {
27     Builder::Network net("network");
28     Builder::Layer::Ptr fakeELULayerPtr = std::make_shared<Builder::Layer>("ELU", "ELU layer");
29     fakeELULayerPtr->getInputPorts().push_back(Port({1, 1, 1, 1}));
30     fakeELULayerPtr->getOutputPorts().push_back(Port({1, 1, 1, 2}));
31     Builder::ELULayer eluLayer(fakeELULayerPtr);
32     eluLayer.setAlpha(100);
33     ASSERT_THROW(net.addLayer(eluLayer), InferenceEngine::details::InferenceEngineException);
34 }
35
36 TEST_F(ELULayerBuilderTest, cannotCreateLayerWithWrongAlpha) {
37     Builder::Network net("network");
38     Builder::ELULayer eluLayer("ELU_layer");
39     eluLayer.setAlpha(-100);
40     ASSERT_THROW(net.addLayer(eluLayer), InferenceEngine::details::InferenceEngineException);
41 }