Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / src / inference_engine / builders / ie_softmax_layer.cpp
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #include <builders/ie_softmax_layer.hpp>
6 #include <ie_cnn_layer_builder.h>
7
8 #include <string>
9
10 using namespace InferenceEngine;
11
12 Builder::SoftMaxLayer::SoftMaxLayer(const std::string& name): LayerDecorator("SoftMax", name) {
13     getLayer()->getOutputPorts().resize(1);
14     getLayer()->getInputPorts().resize(1);
15     setAxis(1);
16 }
17
18 Builder::SoftMaxLayer::SoftMaxLayer(const Layer::Ptr& layer): LayerDecorator(layer) {
19     checkType("SoftMax");
20 }
21
22 Builder::SoftMaxLayer::SoftMaxLayer(const Layer::CPtr& layer): LayerDecorator(layer) {
23     checkType("SoftMax");
24 }
25
26 Builder::SoftMaxLayer& Builder::SoftMaxLayer::setName(const std::string& name) {
27     getLayer()->setName(name);
28     return *this;
29 }
30
31 const Port& Builder::SoftMaxLayer::getPort() const {
32     return getLayer()->getOutputPorts()[0];
33 }
34
35 Builder::SoftMaxLayer& Builder::SoftMaxLayer::setPort(const Port &port) {
36     getLayer()->getOutputPorts()[0] = port;
37     getLayer()->getInputPorts()[0] = port;
38     return *this;
39 }
40
41 size_t Builder::SoftMaxLayer::getAxis() const {
42     return getLayer()->getParameters().at("axis");
43 }
44
45 Builder::SoftMaxLayer& Builder::SoftMaxLayer::setAxis(size_t axis) {
46     getLayer()->getParameters()["axis"] = axis;
47     return *this;
48 }
49
50 REG_CONVERTER_FOR(SoftMax, [](const CNNLayerPtr& cnnLayer, Builder::Layer& layer) {
51     layer.getParameters()["axis"] = static_cast<size_t>(cnnLayer->GetParamAsUInt("axis", 1));
52 });