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

stochastic_pooling2d_layer_backward.h
1 /* file: stochastic_pooling2d_layer_backward.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 backward stochastic two-dimensional (2D) pooling layer
21 // in the batch processing mode
22 //--
23 */
24 
25 #ifndef __STOCHASTIC_POOLING2D_LAYER_BACKWARD_H__
26 #define __STOCHASTIC_POOLING2D_LAYER_BACKWARD_H__
27 
28 #include "algorithms/algorithm.h"
29 #include "data_management/data/tensor.h"
30 #include "services/daal_defines.h"
31 #include "algorithms/neural_networks/layers/layer.h"
32 #include "algorithms/neural_networks/layers/pooling2d/stochastic_pooling2d_layer_types.h"
33 #include "algorithms/neural_networks/layers/pooling2d/stochastic_pooling2d_layer_backward_types.h"
34 
35 namespace daal
36 {
37 namespace algorithms
38 {
39 namespace neural_networks
40 {
41 namespace layers
42 {
43 namespace stochastic_pooling2d
44 {
45 namespace backward
46 {
50 namespace interface1
51 {
62 template<typename algorithmFPType, Method method, CpuType cpu>
63 class BatchContainer : public AnalysisContainerIface<batch>
64 {};
77 template<typename algorithmFPType, CpuType cpu>
78 class BatchContainer<algorithmFPType, defaultDense, cpu>: public AnalysisContainerIface<batch>
79 {
80 public:
87  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
92  DAAL_DEPRECATED ~BatchContainer();
99  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
100 };
101 
122 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
123 class Batch : public layers::backward::LayerIfaceImpl
124 {
125 public:
126  typedef layers::backward::LayerIfaceImpl super;
127 
128  typedef algorithms::neural_networks::layers::stochastic_pooling2d::backward::Input InputType;
129  typedef algorithms::neural_networks::layers::stochastic_pooling2d::Parameter ParameterType;
130  typedef algorithms::neural_networks::layers::stochastic_pooling2d::backward::Result ResultType;
131 
132  ParameterType &parameter;
133  InputType input;
140  DAAL_DEPRECATED Batch(size_t nDimensions) : _defaultParameter(nDimensions - 2, nDimensions - 1), parameter(_defaultParameter)
141  {
142  initialize();
143  }
144 
151  DAAL_DEPRECATED Batch(ParameterType& parameter) : parameter(parameter), _defaultParameter(parameter)
152  {
153  initialize();
154  }
155 
163  Batch(const Batch<algorithmFPType, method> &other) : super(other),
164  _defaultParameter(other.parameter), parameter(_defaultParameter), input(other.input)
165  {
166  initialize();
167  }
168 
174  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
175 
181  DAAL_DEPRECATED_VIRTUAL virtual InputType *getLayerInput() DAAL_C11_OVERRIDE { return &input; }
182 
188  DAAL_DEPRECATED_VIRTUAL virtual ParameterType *getLayerParameter() DAAL_C11_OVERRIDE { return &parameter; };
189 
195  DAAL_DEPRECATED layers::backward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
196  {
197  return _result;
198  }
199 
205  DAAL_DEPRECATED ResultPtr getResult()
206  {
207  return _result;
208  }
209 
217  DAAL_DEPRECATED services::Status setResult(const ResultPtr& result)
218  {
219  DAAL_CHECK(result, services::ErrorNullResult)
220  _result = result;
221  _res = _result.get();
222  return services::Status();
223  }
224 
232  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
233  {
234  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
235  }
236 
243  DAAL_DEPRECATED_VIRTUAL virtual services::Status allocateResult() DAAL_C11_OVERRIDE
244  {
245  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
246  this->_res = this->_result.get();
247  return s;
248  }
249 
250 protected:
251  /*
252  * \DAAL_DEPRECATED
253  */
254  DAAL_DEPRECATED_VIRTUAL virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
255  {
256  return new Batch<algorithmFPType, method>(*this);
257  }
258 
259  /*
260  * \DAAL_DEPRECATED
261  */
262  void initialize()
263  {
264  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
265  _in = &input;
266  _par = &parameter;
267  _result.reset(new ResultType());
268  }
269 
270 private:
271  ResultPtr _result;
272  ParameterType _defaultParameter;
273 };
275 } // namespace interface1
276 using interface1::BatchContainer;
277 using interface1::Batch;
278 } // namespace backward
279 } // namespace stochastic_pooling2d
280 } // namespace layers
281 } // namespace neural_networks
282 } // namespace algorithms
283 } // namespace daal
284 
285 #endif
daal::algorithms::neural_networks::layers::stochastic_pooling2d::backward::interface1::Batch::getResult
DAAL_DEPRECATED ResultPtr getResult()
Definition: stochastic_pooling2d_layer_backward.h:205
daal::algorithms::neural_networks::layers::stochastic_pooling2d::backward::interface1::Batch
Provides methods for the backward stochastic 2D pooling layer in the batch processing mode...
Definition: stochastic_pooling2d_layer_backward.h:123
daal::algorithms::neural_networks::layers::stochastic_pooling2d::backward::interface1::Batch::getLayerParameter
virtual DAAL_DEPRECATED_VIRTUAL ParameterType * getLayerParameter() DAAL_C11_OVERRIDE
Definition: stochastic_pooling2d_layer_backward.h:188
daal::batch
Definition: daal_defines.h:112
daal::algorithms::neural_networks::layers::stochastic_pooling2d::backward::interface1::Batch::allocateResult
virtual DAAL_DEPRECATED_VIRTUAL services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: stochastic_pooling2d_layer_backward.h:243
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:55
daal::algorithms::neural_networks::layers::stochastic_pooling2d::backward::interface1::Batch::parameter
ParameterType & parameter
Definition: stochastic_pooling2d_layer_backward.h:132
daal_defines.h
daal::algorithms::neural_networks::layers::stochastic_pooling2d::backward::interface1::BatchContainer
Provides methods to run implementations of the backward stochastic 2D pooling layer.
Definition: stochastic_pooling2d_layer_backward.h:63
daal::algorithms::neural_networks::layers::stochastic_pooling2d::backward::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: stochastic_pooling2d_layer_backward.h:163
daal::algorithms::neural_networks::layers::stochastic_pooling2d::defaultDense
Definition: stochastic_pooling2d_layer_types.h:55
daal::algorithms::neural_networks::layers::stochastic_pooling2d::backward::interface1::Batch::input
InputType input
Definition: stochastic_pooling2d_layer_backward.h:133
daal::algorithms::neural_networks::layers::stochastic_pooling2d::backward::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: stochastic_pooling2d_layer_backward.h:232
daal::algorithms::neural_networks::layers::stochastic_pooling2d::backward::interface1::Batch::Batch
DAAL_DEPRECATED Batch(ParameterType &parameter)
Definition: stochastic_pooling2d_layer_backward.h:151
daal::algorithms::neural_networks::layers::stochastic_pooling2d::backward::interface1::Batch::setResult
DAAL_DEPRECATED services::Status setResult(const ResultPtr &result)
Definition: stochastic_pooling2d_layer_backward.h:217
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::stochastic_pooling2d::backward::interface1::Batch::Batch
DAAL_DEPRECATED Batch(size_t nDimensions)
Definition: stochastic_pooling2d_layer_backward.h:140
daal::algorithms::neural_networks::layers::stochastic_pooling2d::backward::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: stochastic_pooling2d_layer_backward.h:174
daal::algorithms::neural_networks::layers::stochastic_pooling2d::backward::interface1::Batch::getLayerResult
DAAL_DEPRECATED layers::backward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
Definition: stochastic_pooling2d_layer_backward.h:195
daal::algorithms::neural_networks::layers::stochastic_pooling2d::backward::interface1::Batch::getLayerInput
virtual DAAL_DEPRECATED_VIRTUAL InputType * getLayerInput() DAAL_C11_OVERRIDE
Definition: stochastic_pooling2d_layer_backward.h:181

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