C++ API Reference for Intel® Data Analytics Acceleration Library 2018 Update 3

dropout_layer_forward.h
1 /* file: dropout_layer_forward.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 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 the interface for the forward dropout layer in the batch processing mode
19 //--
20 */
21 
22 #ifndef __DROPOUT_LAYER_FORWARD_H__
23 #define __DROPOUT_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.h"
29 #include "algorithms/neural_networks/layers/dropout/dropout_layer_types.h"
30 #include "algorithms/neural_networks/layers/dropout/dropout_layer_forward_types.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace neural_networks
37 {
38 namespace layers
39 {
40 namespace dropout
41 {
42 namespace forward
43 {
44 namespace interface1
45 {
61 template<typename algorithmFPType, Method method, CpuType cpu>
62 class DAAL_EXPORT BatchContainer : public layers::forward::LayerContainerIfaceImpl
63 {
64 public:
70  BatchContainer(daal::services::Environment::env *daalEnv);
72  ~BatchContainer();
78  services::Status compute() DAAL_C11_OVERRIDE;
79  services::Status setupCompute() DAAL_C11_OVERRIDE;
80  services::Status resetCompute() DAAL_C11_OVERRIDE;
81 };
82 
101 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
102 class Batch : public layers::forward::LayerIfaceImpl
103 {
104 public:
105  typedef layers::forward::LayerIfaceImpl super;
106 
107  typedef algorithms::neural_networks::layers::dropout::forward::Input InputType;
108  typedef algorithms::neural_networks::layers::dropout::Parameter ParameterType;
109  typedef algorithms::neural_networks::layers::dropout::forward::Result ResultType;
110 
111  ParameterType &parameter;
112  InputType input;
115  Batch() : parameter(_defaultParameter)
116  {
117  initialize();
118  };
119 
125  Batch(ParameterType& parameter) : parameter(parameter), _defaultParameter(parameter)
126  {
127  initialize();
128  }
129 
136  Batch(const Batch<algorithmFPType, method> &other) : super(other),
137  _defaultParameter(other.parameter), parameter(_defaultParameter), input(other.input)
138  {
139  initialize();
140  }
141 
146  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
147 
152  virtual InputType *getLayerInput() DAAL_C11_OVERRIDE { return &input; }
153 
158  virtual ParameterType *getLayerParameter() DAAL_C11_OVERRIDE { return &parameter; };
159 
164  layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
165  {
166  return getResult();
167  }
168 
173  ResultPtr getResult()
174  {
175  return _result;
176  }
177 
184  services::Status setResult(const ResultPtr& result)
185  {
186  DAAL_CHECK(result, services::ErrorNullResult)
187  _result = result;
188  _res = _result.get();
189  return services::Status();
190  }
191 
198  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
199  {
200  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
201  }
202 
208  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
209  {
210  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
211  this->_res = this->_result.get();
212  return s;
213  }
214 
215 protected:
216  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
217  {
218  return new Batch<algorithmFPType, method>(*this);
219  }
220 
221  void initialize()
222  {
223  Analysis<batch>::_ac = new __DAAL_ALGORITHM_LAYER_CONTAINER(BatchContainer, algorithmFPType, method)(&_env);
224  _in = &input;
225  _par = &parameter;
226  _result.reset(new ResultType());
227  }
228 
229 private:
230  ResultPtr _result;
231  ParameterType _defaultParameter;
232 };
234 } // namespace interface1
235 using interface1::BatchContainer;
236 using interface1::Batch;
237 } // namespace forward
238 } // namespace dropout
239 } // namespace layers
240 } // namespace neural_networks
241 } // namespace algorithms
242 } // namespace daal
243 #endif
daal
Definition: algorithm_base_common.h:31
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: dropout_layer_forward.h:198
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::input
InputType input
Definition: dropout_layer_forward.h:112
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::getLayerInput
virtual InputType * getLayerInput() DAAL_C11_OVERRIDE
Definition: dropout_layer_forward.h:152
daal_defines.h
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: dropout_layer_forward.h:184
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: dropout_layer_forward.h:146
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch
Provides methods for the forward dropout layer in the batch processing mode.
Definition: dropout_layer_forward.h:102
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::Batch
Batch(ParameterType &parameter)
Definition: dropout_layer_forward.h:125
daal::algorithms::neural_networks::layers::dropout::forward::interface1::BatchContainer
Provides methods to run implementations of the of the forward dropout layer This class is associated ...
Definition: dropout_layer_forward.h:62
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::getResult
ResultPtr getResult()
Definition: dropout_layer_forward.h:173
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::parameter
ParameterType & parameter
Definition: dropout_layer_forward.h:111
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: dropout_layer_forward.h:136
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::dropout::forward::interface1::Batch::getLayerResult
layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
Definition: dropout_layer_forward.h:164
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::getLayerParameter
virtual ParameterType * getLayerParameter() DAAL_C11_OVERRIDE
Definition: dropout_layer_forward.h:158
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::allocateResult
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: dropout_layer_forward.h:208
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::Batch
Batch()
Definition: dropout_layer_forward.h:115

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