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

spatial_stochastic_pooling2d_layer_backward.h
1 /* file: spatial_stochastic_pooling2d_layer_backward.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 backward spatial pyramid stochastic two-dimensional (2D) pooling layer
19 // in the batch processing mode
20 //--
21 */
22 
23 #ifndef __SPATIAL_STOCHASTIC_POOLING2D_LAYER_BACKWARD_H__
24 #define __SPATIAL_STOCHASTIC_POOLING2D_LAYER_BACKWARD_H__
25 
26 #include "algorithms/algorithm.h"
27 #include "data_management/data/tensor.h"
28 #include "services/daal_defines.h"
29 #include "algorithms/neural_networks/layers/layer.h"
30 #include "algorithms/neural_networks/layers/spatial_pooling2d/spatial_stochastic_pooling2d_layer_backward_types.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace neural_networks
37 {
38 namespace layers
39 {
40 namespace spatial_stochastic_pooling2d
41 {
42 namespace backward
43 {
47 namespace interface1
48 {
54 template<typename algorithmFPType, Method method, CpuType cpu>
55 class DAAL_EXPORT BatchContainer : public AnalysisContainerIface<batch>
56 {};
67 template<typename algorithmFPType, CpuType cpu>
68 class DAAL_EXPORT BatchContainer<algorithmFPType, defaultDense, cpu> : public AnalysisContainerIface<batch>
69 {
70 public:
76  BatchContainer(daal::services::Environment::env *daalEnv);
78  ~BatchContainer();
84  services::Status compute() DAAL_C11_OVERRIDE;
85 };
86 
105 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
106 class Batch : public layers::backward::LayerIfaceImpl
107 {
108 public:
109  typedef layers::backward::LayerIfaceImpl super;
110 
111  typedef algorithms::neural_networks::layers::spatial_stochastic_pooling2d::backward::Input InputType;
112  typedef algorithms::neural_networks::layers::spatial_stochastic_pooling2d::Parameter ParameterType;
113  typedef algorithms::neural_networks::layers::spatial_stochastic_pooling2d::backward::Result ResultType;
114 
115  ParameterType &parameter;
116  InputType input;
123  Batch(size_t pyramidHeight, size_t nDimensions) : _defaultParameter(pyramidHeight, nDimensions - 2, nDimensions - 1), parameter(_defaultParameter)
124  {
125  initialize();
126  }
127 
133  Batch(ParameterType& parameter) : parameter(parameter), _defaultParameter(parameter)
134  {
135  initialize();
136  }
137 
144  Batch(const Batch<algorithmFPType, method> &other) : super(other),
145  _defaultParameter(other.parameter), parameter(_defaultParameter), input(other.input)
146  {
147  initialize();
148  }
149 
154  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
155 
160  virtual InputType *getLayerInput() DAAL_C11_OVERRIDE { return &input; }
161 
166  virtual ParameterType *getLayerParameter() DAAL_C11_OVERRIDE { return &parameter; };
167 
172  layers::backward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
173  {
174  return _result;
175  }
176 
181  ResultPtr getResult()
182  {
183  return _result;
184  }
185 
192  services::Status setResult(const ResultPtr& result)
193  {
194  DAAL_CHECK(result, services::ErrorNullResult)
195  _result = result;
196  _res = _result.get();
197  return services::Status();
198  }
199 
206  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
207  {
208  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
209  }
210 
216  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
217  {
218  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
219  this->_res = this->_result.get();
220  return s;
221  }
222 
223 protected:
224  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
225  {
226  return new Batch<algorithmFPType, method>(*this);
227  }
228 
229  void initialize()
230  {
231  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
232  _in = &input;
233  _par = &parameter;
234  _result.reset(new ResultType());
235  }
236 
237 private:
238  ResultPtr _result;
239  ParameterType _defaultParameter;
240 };
242 } // namespace interface1
243 using interface1::BatchContainer;
244 using interface1::Batch;
245 } // namespace backward
246 } // namespace spatial_stochastic_pooling2d
247 } // namespace layers
248 } // namespace neural_networks
249 } // namespace algorithms
250 } // namespace daal
251 
252 #endif
daal::algorithms::neural_networks::layers::spatial_stochastic_pooling2d::backward::interface1::Batch::getLayerParameter
virtual ParameterType * getLayerParameter() DAAL_C11_OVERRIDE
Definition: spatial_stochastic_pooling2d_layer_backward.h:166
daal
Definition: algorithm_base_common.h:31
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:53
daal::algorithms::neural_networks::layers::spatial_stochastic_pooling2d::backward::interface1::Batch::getLayerInput
virtual InputType * getLayerInput() DAAL_C11_OVERRIDE
Definition: spatial_stochastic_pooling2d_layer_backward.h:160
daal::algorithms::neural_networks::layers::spatial_stochastic_pooling2d::backward::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: spatial_stochastic_pooling2d_layer_backward.h:154
daal::algorithms::neural_networks::layers::spatial_stochastic_pooling2d::backward::interface1::Batch::Batch
Batch(size_t pyramidHeight, size_t nDimensions)
Definition: spatial_stochastic_pooling2d_layer_backward.h:123
daal::algorithms::neural_networks::layers::spatial_stochastic_pooling2d::backward::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: spatial_stochastic_pooling2d_layer_backward.h:192
daal_defines.h
daal::algorithms::neural_networks::layers::spatial_stochastic_pooling2d::backward::interface1::Batch::input
InputType input
Definition: spatial_stochastic_pooling2d_layer_backward.h:116
daal::batch
Definition: daal_defines.h:106
daal::algorithms::neural_networks::layers::spatial_stochastic_pooling2d::backward::interface1::Batch::getResult
ResultPtr getResult()
Definition: spatial_stochastic_pooling2d_layer_backward.h:181
daal::algorithms::neural_networks::layers::spatial_stochastic_pooling2d::backward::interface1::Batch::parameter
ParameterType & parameter
Definition: spatial_stochastic_pooling2d_layer_backward.h:115
daal::algorithms::neural_networks::layers::spatial_stochastic_pooling2d::defaultDense
Definition: spatial_stochastic_pooling2d_layer_types.h:54
daal::algorithms::neural_networks::layers::spatial_stochastic_pooling2d::backward::interface1::Batch::allocateResult
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: spatial_stochastic_pooling2d_layer_backward.h:216
daal::algorithms::neural_networks::layers::spatial_stochastic_pooling2d::backward::interface1::BatchContainer
Definition: spatial_stochastic_pooling2d_layer_backward.h:55
daal::algorithms::neural_networks::layers::spatial_stochastic_pooling2d::backward::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: spatial_stochastic_pooling2d_layer_backward.h:144
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::spatial_stochastic_pooling2d::backward::interface1::Batch::Batch
Batch(ParameterType &parameter)
Definition: spatial_stochastic_pooling2d_layer_backward.h:133
daal::algorithms::neural_networks::layers::spatial_stochastic_pooling2d::backward::interface1::Batch::getLayerResult
layers::backward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
Definition: spatial_stochastic_pooling2d_layer_backward.h:172
daal::algorithms::neural_networks::layers::spatial_stochastic_pooling2d::backward::interface1::Batch
Provides methods for the backward spatial pyramid stochastic 2D pooling layer in the batch processing...
Definition: spatial_stochastic_pooling2d_layer_backward.h:106
daal::algorithms::neural_networks::layers::spatial_stochastic_pooling2d::backward::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: spatial_stochastic_pooling2d_layer_backward.h:206
daal::services::ErrorNullResult
Definition: error_indexes.h:96

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