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

dropout_layer_forward.h
1 /* file: dropout_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 the interface for the forward dropout layer in the batch processing mode
21 //--
22 */
23 
24 #ifndef __DROPOUT_LAYER_FORWARD_H__
25 #define __DROPOUT_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.h"
31 #include "algorithms/neural_networks/layers/dropout/dropout_layer_types.h"
32 #include "algorithms/neural_networks/layers/dropout/dropout_layer_forward_types.h"
33 
34 namespace daal
35 {
36 namespace algorithms
37 {
38 namespace neural_networks
39 {
40 namespace layers
41 {
42 namespace dropout
43 {
44 namespace forward
45 {
46 namespace interface1
47 {
65 template<typename algorithmFPType, Method method, CpuType cpu>
66 class BatchContainer : public layers::forward::LayerContainerIfaceImpl
67 {
68 public:
75  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
80  DAAL_DEPRECATED ~BatchContainer();
87  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
88  /*
89  * \DAAL_DEPRECATED
90  */
91  DAAL_DEPRECATED services::Status setupCompute() DAAL_C11_OVERRIDE;
92  /*
93  * \DAAL_DEPRECATED
94  */
95  DAAL_DEPRECATED services::Status resetCompute() DAAL_C11_OVERRIDE;
96 };
97 
118 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
119 class Batch : public layers::forward::LayerIfaceImpl
120 {
121 public:
122  typedef layers::forward::LayerIfaceImpl super;
123 
124  typedef algorithms::neural_networks::layers::dropout::forward::Input InputType;
125  typedef algorithms::neural_networks::layers::dropout::Parameter ParameterType;
126  typedef algorithms::neural_networks::layers::dropout::forward::Result ResultType;
127 
128  ParameterType &parameter;
129  InputType input;
135  DAAL_DEPRECATED Batch() : parameter(_defaultParameter)
136  {
137  initialize();
138  };
139 
146  DAAL_DEPRECATED Batch(ParameterType& parameter) : parameter(parameter), _defaultParameter(parameter)
147  {
148  initialize();
149  }
150 
158  Batch(const Batch<algorithmFPType, method> &other) : super(other),
159  _defaultParameter(other.parameter), parameter(_defaultParameter), input(other.input)
160  {
161  initialize();
162  }
163 
169  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
170 
176  DAAL_DEPRECATED_VIRTUAL virtual InputType *getLayerInput() DAAL_C11_OVERRIDE { return &input; }
177 
182  DAAL_DEPRECATED_VIRTUAL virtual ParameterType *getLayerParameter() DAAL_C11_OVERRIDE { return &parameter; };
183 
189  DAAL_DEPRECATED layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
190  {
191  return getResult();
192  }
193 
199  ResultPtr getResult()
200  {
201  return _result;
202  }
203 
211  DAAL_DEPRECATED services::Status setResult(const ResultPtr& result)
212  {
213  DAAL_CHECK(result, services::ErrorNullResult)
214  _result = result;
215  _res = _result.get();
216  return services::Status();
217  }
218 
226  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
227  {
228  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
229  }
230 
237  DAAL_DEPRECATED_VIRTUAL virtual services::Status allocateResult() DAAL_C11_OVERRIDE
238  {
239  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
240  this->_res = this->_result.get();
241  return s;
242  }
243 
244 protected:
245  /*
246  * \DAAL_DEPRECATED
247  */
248  DAAL_DEPRECATED_VIRTUAL virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
249  {
250  return new Batch<algorithmFPType, method>(*this);
251  }
252 
253  /*
254  * \DAAL_DEPRECATED
255  */
256  void initialize()
257  {
258  Analysis<batch>::_ac = new __DAAL_ALGORITHM_LAYER_CONTAINER(BatchContainer, algorithmFPType, method)(&_env);
259  _in = &input;
260  _par = &parameter;
261  _result.reset(new ResultType());
262  }
263 
264 private:
265  ResultPtr _result;
266  ParameterType _defaultParameter;
267 };
269 } // namespace interface1
270 using interface1::BatchContainer;
271 using interface1::Batch;
272 } // namespace forward
273 } // namespace dropout
274 } // namespace layers
275 } // namespace neural_networks
276 } // namespace algorithms
277 } // namespace daal
278 #endif
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::parameter
ParameterType & parameter
Definition: dropout_layer_forward.h:128
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::getLayerInput
virtual DAAL_DEPRECATED_VIRTUAL InputType * getLayerInput() DAAL_C11_OVERRIDE
Definition: dropout_layer_forward.h:176
daal::algorithms::neural_networks::layers::dropout::forward::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: dropout_layer_forward.h:169
daal::algorithms::neural_networks::layers::dropout::forward::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::neural_networks::layers::dropout::forward::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::getLayerParameter
virtual DAAL_DEPRECATED_VIRTUAL ParameterType * getLayerParameter() DAAL_C11_OVERRIDE
Definition: dropout_layer_forward.h:182
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:119
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: dropout_layer_forward.h:226
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::Batch
DAAL_DEPRECATED Batch()
Definition: dropout_layer_forward.h:135
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::Batch
DAAL_DEPRECATED Batch(ParameterType &parameter)
Definition: dropout_layer_forward.h:146
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::getLayerResult
DAAL_DEPRECATED layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
Definition: dropout_layer_forward.h:189
daal_defines.h
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::input
InputType input
Definition: dropout_layer_forward.h:129
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::getResult
ResultPtr getResult()
Definition: dropout_layer_forward.h:199
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: dropout_layer_forward.h:158
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:66
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::dropout::forward::interface1::Batch::allocateResult
virtual DAAL_DEPRECATED_VIRTUAL services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: dropout_layer_forward.h:237
daal::algorithms::neural_networks::layers::dropout::forward::interface1::Batch::setResult
DAAL_DEPRECATED services::Status setResult(const ResultPtr &result)
Definition: dropout_layer_forward.h:211

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