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

maximum_pooling2d_layer_forward.h
1 /* file: maximum_pooling2d_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 maximum two-dimensional (2D) pooling layer
19 // in the batch processing mode
20 //--
21 */
22 
23 #ifndef __MAXIMUM_POOLING2D_LAYER_FORWARD_H__
24 #define __MAXIMUM_POOLING2D_LAYER_FORWARD_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/pooling2d/maximum_pooling2d_layer_types.h"
31 #include "algorithms/neural_networks/layers/pooling2d/maximum_pooling2d_layer_forward_types.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
37 namespace neural_networks
38 {
39 namespace layers
40 {
41 namespace maximum_pooling2d
42 {
43 namespace forward
44 {
48 namespace interface1
49 {
65 template<typename algorithmFPType, Method method, CpuType cpu>
66 class DAAL_EXPORT BatchContainer : public layers::forward::LayerContainerIfaceImpl
67 {
68 public:
74  BatchContainer(daal::services::Environment::env *daalEnv);
76  ~BatchContainer();
82  services::Status compute() DAAL_C11_OVERRIDE;
83  services::Status setupCompute() DAAL_C11_OVERRIDE;
84 };
85 
104 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
105 class Batch : public layers::forward::LayerIfaceImpl
106 {
107 public:
108  typedef layers::forward::LayerIfaceImpl super;
109 
110  typedef algorithms::neural_networks::layers::maximum_pooling2d::forward::Input InputType;
111  typedef algorithms::neural_networks::layers::maximum_pooling2d::Parameter ParameterType;
112  typedef algorithms::neural_networks::layers::maximum_pooling2d::forward::Result ResultType;
113 
114  ParameterType &parameter;
115  InputType input;
121  Batch(size_t nDimensions) : _defaultParameter(nDimensions - 2, nDimensions - 1),parameter(_defaultParameter)
122  {
123  initialize();
124  }
125 
131  Batch(ParameterType& parameter) : parameter(parameter), _defaultParameter(parameter)
132  {
133  initialize();
134  }
135 
142  Batch(const Batch<algorithmFPType, method> &other) : super(other),
143  _defaultParameter(other.parameter), parameter(_defaultParameter), input(other.input)
144  {
145  initialize();
146  }
147 
152  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
153 
158  virtual InputType *getLayerInput() DAAL_C11_OVERRIDE { return &input; }
159 
164  virtual ParameterType *getLayerParameter() DAAL_C11_OVERRIDE { return &parameter; };
165 
170  layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
171  {
172  return getResult();
173  }
174 
179  ResultPtr getResult()
180  {
181  return _result;
182  }
183 
190  services::Status setResult(const ResultPtr& result)
191  {
192  DAAL_CHECK(result, services::ErrorNullResult)
193  _result = result;
194  _res = _result.get();
195  return services::Status();
196  }
197 
204  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
205  {
206  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
207  }
208 
214  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
215  {
216  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
217  this->_res = this->_result.get();
218  return s;
219  }
220 
221 protected:
222  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
223  {
224  return new Batch<algorithmFPType, method>(*this);
225  }
226 
227  void initialize()
228  {
229  Analysis<batch>::_ac = new __DAAL_ALGORITHM_LAYER_CONTAINER(BatchContainer, algorithmFPType, method)(&_env);
230  _in = &input;
231  _par = &parameter;
232  _result.reset(new ResultType());
233  }
234 
235 private:
236  ResultPtr _result;
237  ParameterType _defaultParameter;
238 };
240 } // namespace interface1
241 using interface1::BatchContainer;
242 using interface1::Batch;
243 } // namespace forward
244 } // namespace maximum_pooling2d
245 } // namespace layers
246 } // namespace neural_networks
247 } // namespace algorithms
248 } // namespace daal
249 
250 #endif
daal
Definition: algorithm_base_common.h:31
daal::algorithms::neural_networks::layers::maximum_pooling2d::forward::interface1::Batch::getLayerParameter
virtual ParameterType * getLayerParameter() DAAL_C11_OVERRIDE
Definition: maximum_pooling2d_layer_forward.h:164
daal::algorithms::neural_networks::layers::maximum_pooling2d::forward::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: maximum_pooling2d_layer_forward.h:204
daal::algorithms::neural_networks::layers::maximum_pooling2d::forward::interface1::Batch::getLayerInput
virtual InputType * getLayerInput() DAAL_C11_OVERRIDE
Definition: maximum_pooling2d_layer_forward.h:158
daal::algorithms::neural_networks::layers::maximum_pooling2d::forward::interface1::Batch::allocateResult
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: maximum_pooling2d_layer_forward.h:214
daal_defines.h
daal::algorithms::neural_networks::layers::maximum_pooling2d::forward::interface1::Batch::getResult
ResultPtr getResult()
Definition: maximum_pooling2d_layer_forward.h:179
daal::algorithms::neural_networks::layers::maximum_pooling2d::forward::interface1::Batch::parameter
ParameterType & parameter
Definition: maximum_pooling2d_layer_forward.h:114
daal::algorithms::neural_networks::layers::maximum_pooling2d::forward::interface1::BatchContainer
Provides methods to run implementations of the forward maximum 2D pooling layer. This class is associ...
Definition: maximum_pooling2d_layer_forward.h:66
daal::algorithms::neural_networks::layers::maximum_pooling2d::forward::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: maximum_pooling2d_layer_forward.h:152
daal::algorithms::neural_networks::layers::maximum_pooling2d::forward::interface1::Batch::input
InputType input
Definition: maximum_pooling2d_layer_forward.h:115
daal::algorithms::neural_networks::layers::maximum_pooling2d::forward::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: maximum_pooling2d_layer_forward.h:190
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::maximum_pooling2d::forward::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: maximum_pooling2d_layer_forward.h:142
daal::algorithms::neural_networks::layers::maximum_pooling2d::forward::interface1::Batch
Provides methods for the forward maximum 2D pooling layer in the batch processing mode...
Definition: maximum_pooling2d_layer_forward.h:105
daal::algorithms::neural_networks::layers::maximum_pooling2d::forward::interface1::Batch::Batch
Batch(size_t nDimensions)
Definition: maximum_pooling2d_layer_forward.h:121
daal::algorithms::neural_networks::layers::maximum_pooling2d::forward::interface1::Batch::Batch
Batch(ParameterType &parameter)
Definition: maximum_pooling2d_layer_forward.h:131
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::neural_networks::layers::maximum_pooling2d::forward::interface1::Batch::getLayerResult
layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
Definition: maximum_pooling2d_layer_forward.h:170

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