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

convolution2d_layer_forward.h
1 /* file: convolution2d_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 two-dimensional (2D) convolution layer in the batch
21 // processing mode
22 //--
23 */
24 
25 #ifndef __CONVOLUTION2D_LAYER_FORWARD_H__
26 #define __CONVOLUTION2D_LAYER_FORWARD_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/convolution2d/convolution2d_layer_types.h"
33 #include "algorithms/neural_networks/layers/convolution2d/convolution2d_layer_forward_types.h"
34 
35 namespace daal
36 {
37 namespace algorithms
38 {
39 namespace neural_networks
40 {
41 namespace layers
42 {
43 namespace convolution2d
44 {
45 namespace forward
46 {
47 namespace interface1
48 {
66 template<typename algorithmFPType, Method method, CpuType cpu>
67 class BatchContainer : public layers::forward::LayerContainerIfaceImpl
68 {
69 public:
76  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
81  DAAL_DEPRECATED ~BatchContainer();
88  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
89  /*
90  * \DAAL_DEPRECATED
91  */
92  DAAL_DEPRECATED services::Status setupCompute() DAAL_C11_OVERRIDE;
93  /*
94  * \DAAL_DEPRECATED
95  */
96  DAAL_DEPRECATED services::Status resetCompute() DAAL_C11_OVERRIDE;
97 
98  /*
99  * \DAAL_DEPRECATED
100  */
101  DAAL_DEPRECATED_VIRTUAL virtual services::Status allocateInput() DAAL_C11_OVERRIDE
102  {
103  Input *input = static_cast<Input *>(_in);
104  return input->allocate<algorithmFPType>(_par, (int) method);
105  }
106 };
107 
127 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
128 class Batch : public layers::forward::LayerIfaceImpl
129 {
130 public:
131  typedef layers::forward::LayerIfaceImpl super;
132 
133  typedef algorithms::neural_networks::layers::convolution2d::forward::Input InputType;
134  typedef algorithms::neural_networks::layers::convolution2d::Parameter ParameterType;
135  typedef algorithms::neural_networks::layers::convolution2d::forward::Result ResultType;
136 
137  ParameterType &parameter;
138  InputType input;
144  DAAL_DEPRECATED Batch() : parameter(_defaultParameter)
145  {
146  initialize();
147  };
148 
155  DAAL_DEPRECATED Batch(ParameterType& parameter) : parameter(parameter), _defaultParameter(parameter)
156  {
157  initialize();
158  };
159 
166  Batch(const Batch<algorithmFPType, method> &other) : super(other),
167  _defaultParameter(other.parameter), parameter(_defaultParameter), input(other.input)
168  {
169  initialize();
170  }
171 
177  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
178 
184  DAAL_DEPRECATED_VIRTUAL virtual InputType *getLayerInput() DAAL_C11_OVERRIDE { return &input; }
185 
191  DAAL_DEPRECATED_VIRTUAL virtual ParameterType *getLayerParameter() DAAL_C11_OVERRIDE { return &parameter; };
192 
198  DAAL_DEPRECATED layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
199  {
200  return getResult();
201  }
202 
208  ResultPtr getResult()
209  {
210  return _result;
211  }
212 
220  DAAL_DEPRECATED services::Status setResult(const ResultPtr& result)
221  {
222  DAAL_CHECK(result, services::ErrorNullResult)
223  _result = result;
224  _res = _result.get();
225  return services::Status();
226  }
227 
234  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
235  {
236  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
237  }
238 
239  /*
240  * \DAAL_DEPRECATED
241  */
242  DAAL_DEPRECATED_VIRTUAL virtual services::Status allocateResult() DAAL_C11_OVERRIDE
243  {
244  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
245  this->_res = this->_result.get();
246  return s;
247  }
248 
249 protected:
250  /*
251  * \DAAL_DEPRECATED
252  */
253  DAAL_DEPRECATED_VIRTUAL virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
254  {
255  return new Batch<algorithmFPType, method>(*this);
256  }
257 
258  /*
259  * \DAAL_DEPRECATED
260  */
261  void initialize()
262  {
263  Analysis<batch>::_ac = new __DAAL_ALGORITHM_LAYER_CONTAINER(BatchContainer, algorithmFPType, method)(&_env);
264  _in = &input;
265  _par = &parameter;
266  _result.reset(new ResultType());
267  }
268 
269 private:
270  ResultPtr _result;
271  ParameterType _defaultParameter;
272 };
273 
275 } // namespace interface1
276 using interface1::BatchContainer;
277 using interface1::Batch;
278 } // namespace forward
279 } // namespace convolution2d
280 } // namespace layers
281 } // namespace neural_networks
282 } // namespace algorithms
283 } // namespace daal
284 #endif
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::Batch::setResult
DAAL_DEPRECATED services::Status setResult(const ResultPtr &result)
Definition: convolution2d_layer_forward.h:220
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::BatchContainer
Provides methods to run implementations of the forward 2D convolution layer. This class is associated...
Definition: convolution2d_layer_forward.h:67
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: convolution2d_layer_forward.h:177
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::Input::allocate
DAAL_EXPORT services::Status allocate(const daal::algorithms::Parameter *parameter, const int method)
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::Batch::getLayerInput
virtual DAAL_DEPRECATED_VIRTUAL InputType * getLayerInput() DAAL_C11_OVERRIDE
Definition: convolution2d_layer_forward.h:184
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::Batch::getLayerParameter
virtual DAAL_DEPRECATED_VIRTUAL ParameterType * getLayerParameter() DAAL_C11_OVERRIDE
Definition: convolution2d_layer_forward.h:191
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::Batch::Batch
DAAL_DEPRECATED Batch()
Definition: convolution2d_layer_forward.h:144
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: convolution2d_layer_forward.h:234
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::Batch::input
InputType input
Definition: convolution2d_layer_forward.h:138
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::Batch::Batch
DAAL_DEPRECATED Batch(ParameterType &parameter)
Definition: convolution2d_layer_forward.h:155
daal_defines.h
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::Batch
Provides methods for forward 2D convolution layer computations in the batch processing mode...
Definition: convolution2d_layer_forward.h:128
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::Batch::getLayerResult
DAAL_DEPRECATED layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
Definition: convolution2d_layer_forward.h:198
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::Batch::getResult
ResultPtr getResult()
Definition: convolution2d_layer_forward.h:208
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::convolution2d::forward::interface1::Batch::parameter
ParameterType & parameter
Definition: convolution2d_layer_forward.h:137
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: convolution2d_layer_forward.h:166
daal::algorithms::neural_networks::layers::convolution2d::forward::interface1::Input
Input objects for the forward 2D convolution layer
Definition: convolution2d_layer_forward_types.h:66

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