C++ API Reference for Intel® Data Analytics Acceleration Library 2019 Update 4

layer_forward.h
1 /* file: layer_forward.h */
2 /*******************************************************************************
3 * Copyright 2014-2019 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 /*
17 //++
18 // Implementation of neural network layer.
19 //--
20 */
21 
22 #ifndef __LAYER_FORWARD_H__
23 #define __LAYER_FORWARD_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "data_management/data/tensor.h"
27 #include "services/daal_defines.h"
28 #include "algorithms/neural_networks/layers/layer_forward_types.h"
29 #include "layer_forward_container_base.h"
30 
31 namespace daal
32 {
33 namespace algorithms
34 {
38 namespace neural_networks
39 {
43 namespace layers
44 {
48 namespace forward
49 {
50 namespace interface1
51 {
60 class LayerIface : public daal::algorithms::Analysis<batch>
61 {
62 public:
63  typedef algorithms::neural_networks::layers::forward::Input InputType;
64  typedef algorithms::neural_networks::layers::Parameter ParameterType;
65  typedef algorithms::neural_networks::layers::forward::Result ResultType;
66 
67  virtual ~LayerIface() {};
68 
73  virtual forward::ResultPtr getLayerResult() = 0;
74 
79  virtual InputType *getLayerInput() = 0;
80 
85  virtual ParameterType *getLayerParameter() = 0;
86 
92  daal::algorithms::neural_networks::layers::forward::LayerIfacePtr clone() const
93  {
94  return LayerIfacePtr(cloneImpl());
95  }
96 
100  virtual services::Status allocateResult() = 0;
101 
105  virtual services::Status allocateInput() = 0;
106 
110  virtual services::Status initializeInput() = 0;
120  virtual services::Status addInput(forward::ResultPtr result, size_t resultIndex, size_t inputIndex) = 0;
121 
126  virtual layers::forward::LayerIfacePtr getLayerForPrediction() const = 0;
127 
128 protected:
129  virtual LayerIface *cloneImpl() const = 0;
130 };
131 
132 typedef services::SharedPtr<LayerIface> LayerIfacePtr;
143 class LayerIfaceImpl : public LayerIface
144 {
145 public:
146  typedef LayerIface super;
147 
148  typedef super::InputType InputType;
149  typedef super::ParameterType ParameterType;
150  typedef super::ResultType ResultType;
151 
152  virtual ~LayerIfaceImpl() {};
153 
157  virtual services::Status allocateInput() DAAL_C11_OVERRIDE
158  {
159  this->_ac->setArguments(this->_in, this->_res, this->_par);
160  LayerContainerIfaceImpl *ac = dynamic_cast<LayerContainerIfaceImpl *>(_ac);
161  return ac->allocateInput();
162  }
163 
167  virtual services::Status initializeInput() DAAL_C11_OVERRIDE
168  {
169  this->_ac->setArguments(this->_in, this->_res, this->_par);
170  setParameter();
171  LayerContainerIfaceImpl *ac = dynamic_cast<LayerContainerIfaceImpl *>(_ac);
172  return ac->initializeInput();
173  }
174 
178  virtual services::Status addInput(forward::ResultPtr result, size_t resultIndex, size_t inputIndex) DAAL_C11_OVERRIDE
179  {
180  return getLayerInput()->addData(result->getValue(resultIndex), inputIndex);
181  }
182 
187  virtual layers::forward::LayerIfacePtr getLayerForPrediction() const DAAL_C11_OVERRIDE
188  {
189  return this->clone();
190  }
191 
192 protected:
193  virtual void setParameter() DAAL_C11_OVERRIDE
194  {
195  if(this->getLayerParameter())
196  {
197  this->getLayerParameter()->weightsInitializer->getParameter()->layer = services::SharedPtr<LayerIface>(this, services::EmptyDeleter());
198  this->getLayerParameter()->biasesInitializer->getParameter()->layer = services::SharedPtr<LayerIface>(this, services::EmptyDeleter());
199  }
200  }
201 };
202 
203 typedef services::SharedPtr<LayerIfaceImpl> LayerIfaceImplPtr;
205 } // namespace interface1
206 using interface1::LayerIface;
207 using interface1::LayerIfacePtr;
208 using interface1::LayerIfaceImpl;
209 using interface1::LayerIfaceImplPtr;
210 
211 } // namespace forward
212 } // namespace layers
213 } // namespace neural_networks
214 } // namespace algorithms
215 } // namespace daal
216 #endif
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::getLayerForPrediction
virtual layers::forward::LayerIfacePtr getLayerForPrediction() const =0
daal::algorithms::neural_networks::layers::forward::interface1::LayerIfaceImpl::initializeInput
virtual services::Status initializeInput() DAAL_C11_OVERRIDE
Definition: layer_forward.h:167
daal
Definition: algorithm_base_common.h:31
daal::algorithms::neural_networks::layers::forward::interface1::LayerIfaceImpl::addInput
virtual services::Status addInput(forward::ResultPtr result, size_t resultIndex, size_t inputIndex) DAAL_C11_OVERRIDE
Definition: layer_forward.h:178
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::getLayerResult
virtual forward::ResultPtr getLayerResult()=0
daal::algorithms::neural_networks::layers::forward::interface1::LayerContainerIfaceImpl::initializeInput
virtual services::Status initializeInput()
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface
Abstract class which defines interface for the layer.
Definition: layer_forward.h:60
daal::algorithms::neural_networks::layers::forward::interface1::LayerIfaceImpl::allocateInput
virtual services::Status allocateInput() DAAL_C11_OVERRIDE
Definition: layer_forward.h:157
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::addInput
virtual services::Status addInput(forward::ResultPtr result, size_t resultIndex, size_t inputIndex)=0
daal_defines.h
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::getLayerParameter
virtual ParameterType * getLayerParameter()=0
daal::algorithms::neural_networks::layers::forward::interface1::LayerIfaceImpl::getLayerForPrediction
virtual layers::forward::LayerIfacePtr getLayerForPrediction() const DAAL_C11_OVERRIDE
Definition: layer_forward.h:187
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::getLayerInput
virtual InputType * getLayerInput()=0
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::initializeInput
virtual services::Status initializeInput()=0
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::allocateInput
virtual services::Status allocateInput()=0
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::clone
daal::algorithms::neural_networks::layers::forward::LayerIfacePtr clone() const
Definition: layer_forward.h:92
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::allocateResult
virtual services::Status allocateResult()=0
daal::algorithms::neural_networks::layers::forward::interface1::LayerContainerIfaceImpl
Provides methods of base container for forward layers. This class is associated with the daal::algori...
Definition: layer_forward_container_base.h:60
daal::algorithms::neural_networks::layers::forward::interface1::LayerContainerIfaceImpl::allocateInput
virtual services::Status allocateInput()
daal::algorithms::neural_networks::layers::forward::interface1::LayerIfaceImpl
Implements the abstract interface LayerIface. LayerIfaceImpl is, in turn, the base class for the clas...
Definition: layer_forward.h:143

For more complete information about compiler optimizations, see our Optimization Notice.