C++ API Reference for Intel® Data Analytics Acceleration Library 2020 Update 1

layer_forward.h
1 /* file: layer_forward.h */
2 /*******************************************************************************
3 * Copyright 2014-2020 Intel Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *******************************************************************************/
17 
18 /*
19 //++
20 // Implementation of neural network layer.
21 //--
22 */
23 
24 #ifndef __LAYER_FORWARD_H__
25 #define __LAYER_FORWARD_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "data_management/data/tensor.h"
29 #include "services/daal_defines.h"
30 #include "algorithms/neural_networks/layers/layer_forward_types.h"
31 #include "layer_forward_container_base.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
40 namespace neural_networks
41 {
45 namespace layers
46 {
50 namespace forward
51 {
52 namespace interface1
53 {
63 class LayerIface : public daal::algorithms::Analysis<batch>
64 {
65 public:
66  typedef algorithms::neural_networks::layers::forward::Input InputType;
67  typedef algorithms::neural_networks::layers::Parameter ParameterType;
68  typedef algorithms::neural_networks::layers::forward::Result ResultType;
69 
70  /*
71  * \DAAL_DEPRECATED
72  */
73  virtual ~LayerIface() {};
74 
80  virtual forward::ResultPtr getLayerResult() = 0;
81 
87  virtual InputType *getLayerInput() = 0;
88 
94  virtual ParameterType *getLayerParameter() = 0;
95 
102  daal::algorithms::neural_networks::layers::forward::LayerIfacePtr clone() const
103  {
104  return LayerIfacePtr(cloneImpl());
105  }
106 
111  virtual services::Status allocateResult() = 0;
112 
117  DAAL_DEPRECATED_VIRTUAL virtual services::Status allocateInput() = 0;
118 
123  DAAL_DEPRECATED_VIRTUAL virtual services::Status initializeInput() = 0;
134  virtual services::Status addInput(forward::ResultPtr result, size_t resultIndex, size_t inputIndex) = 0;
135 
141  DAAL_DEPRECATED_VIRTUAL virtual layers::forward::LayerIfacePtr getLayerForPrediction() const = 0;
142 
143 protected:
144  /*
145  * \DAAL_DEPRECATED
146  */
147  virtual LayerIface *cloneImpl() const = 0;
148 };
149 
150 typedef services::SharedPtr<LayerIface> LayerIfacePtr;
162 class LayerIfaceImpl : public LayerIface
163 {
164 public:
165  typedef LayerIface super;
166 
167  typedef super::InputType InputType;
168  typedef super::ParameterType ParameterType;
169  typedef super::ResultType ResultType;
170 
171  /*
172  * \DAAL_DEPRECATED
173  */
174  virtual ~LayerIfaceImpl() {};
175 
180  DAAL_DEPRECATED_VIRTUAL virtual services::Status allocateInput() DAAL_C11_OVERRIDE
181  {
182  this->_ac->setArguments(this->_in, this->_res, this->_par);
183  LayerContainerIfaceImpl *ac = dynamic_cast<LayerContainerIfaceImpl *>(_ac);
184  return ac->allocateInput();
185  }
186 
191  DAAL_DEPRECATED_VIRTUAL virtual services::Status initializeInput() DAAL_C11_OVERRIDE
192  {
193  this->_ac->setArguments(this->_in, this->_res, this->_par);
194  setParameter();
195  LayerContainerIfaceImpl *ac = dynamic_cast<LayerContainerIfaceImpl *>(_ac);
196  return ac->initializeInput();
197  }
198 
203  DAAL_DEPRECATED_VIRTUAL virtual services::Status addInput(forward::ResultPtr result, size_t resultIndex, size_t inputIndex) DAAL_C11_OVERRIDE
204  {
205  return getLayerInput()->addData(result->getValue(resultIndex), inputIndex);
206  }
207 
213  DAAL_DEPRECATED_VIRTUAL virtual layers::forward::LayerIfacePtr getLayerForPrediction() const DAAL_C11_OVERRIDE
214  {
215  return this->clone();
216  }
217 
218 protected:
219  /*
220  * \DAAL_DEPRECATED
221  */
222  DAAL_DEPRECATED_VIRTUAL virtual void setParameter() DAAL_C11_OVERRIDE
223  {
224  if(this->getLayerParameter())
225  {
226  this->getLayerParameter()->weightsInitializer->getParameter()->layer = services::SharedPtr<LayerIface>(this, services::EmptyDeleter());
227  this->getLayerParameter()->biasesInitializer->getParameter()->layer = services::SharedPtr<LayerIface>(this, services::EmptyDeleter());
228  }
229  }
230 };
231 
232 typedef services::SharedPtr<LayerIfaceImpl> LayerIfaceImplPtr;
234 } // namespace interface1
235 using interface1::LayerIface;
236 using interface1::LayerIfacePtr;
237 using interface1::LayerIfaceImpl;
238 using interface1::LayerIfaceImplPtr;
239 
240 } // namespace forward
241 } // namespace layers
242 } // namespace neural_networks
243 } // namespace algorithms
244 } // namespace daal
245 #endif
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::getLayerParameter
virtual ParameterType * getLayerParameter()=0
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::getLayerResult
virtual forward::ResultPtr getLayerResult()=0
daal::algorithms::neural_networks::layers::forward::interface1::LayerIfaceImpl::addInput
virtual DAAL_DEPRECATED_VIRTUAL services::Status addInput(forward::ResultPtr result, size_t resultIndex, size_t inputIndex) DAAL_C11_OVERRIDE
Definition: layer_forward.h:203
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:63
daal::algorithms::neural_networks::layers::forward::interface1::LayerIfaceImpl::initializeInput
virtual DAAL_DEPRECATED_VIRTUAL services::Status initializeInput() DAAL_C11_OVERRIDE
Definition: layer_forward.h:191
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::allocateResult
virtual services::Status allocateResult()=0
daal_defines.h
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::getLayerInput
virtual InputType * getLayerInput()=0
daal::algorithms::neural_networks::layers::forward::interface1::LayerIfaceImpl::getLayerForPrediction
virtual DAAL_DEPRECATED_VIRTUAL layers::forward::LayerIfacePtr getLayerForPrediction() const DAAL_C11_OVERRIDE
Definition: layer_forward.h:213
daal::algorithms::neural_networks::layers::forward::interface1::LayerContainerIfaceImpl::initializeInput
virtual DAAL_DEPRECATED_VIRTUAL services::Status initializeInput()
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface
Abstract class which defines interface for the layer.
Definition: layer_forward.h:63
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::allocateInput
virtual DAAL_DEPRECATED_VIRTUAL services::Status allocateInput()=0
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::addInput
virtual services::Status addInput(forward::ResultPtr result, size_t resultIndex, size_t inputIndex)=0
daal::algorithms::neural_networks::layers::forward::interface1::LayerIfaceImpl::allocateInput
virtual DAAL_DEPRECATED_VIRTUAL services::Status allocateInput() DAAL_C11_OVERRIDE
Definition: layer_forward.h:180
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::initializeInput
virtual DAAL_DEPRECATED_VIRTUAL services::Status initializeInput()=0
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::getLayerForPrediction
virtual DAAL_DEPRECATED_VIRTUAL layers::forward::LayerIfacePtr getLayerForPrediction() const =0
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:162
daal::algorithms::neural_networks::layers::forward::interface1::LayerIface::clone
daal::algorithms::neural_networks::layers::forward::LayerIfacePtr clone() const
Definition: layer_forward.h:102
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70
daal::algorithms::neural_networks::layers::forward::interface1::LayerContainerIfaceImpl::allocateInput
virtual DAAL_DEPRECATED_VIRTUAL services::Status allocateInput()

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