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

transposed_conv2d_layer_forward.h
1 /* file: transposed_conv2d_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) transposed convolution layer in the batch
21 // processing mode
22 //--
23 */
24 
25 #ifndef __TRANSPOSED_CONV2D_LAYER_FORWARD_H__
26 #define __TRANSPOSED_CONV2D_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/transposed_conv2d/transposed_conv2d_layer_types.h"
33 #include "algorithms/neural_networks/layers/transposed_conv2d/transposed_conv2d_layer_forward_types.h"
34 
35 namespace daal
36 {
37 namespace algorithms
38 {
39 namespace neural_networks
40 {
41 namespace layers
42 {
43 namespace transposed_conv2d
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();
87  services::Status compute() DAAL_C11_OVERRIDE;
88  services::Status setupCompute() DAAL_C11_OVERRIDE;
89 
90  virtual services::Status allocateInput() DAAL_C11_OVERRIDE
91  {
92  Input *input = static_cast<Input *>(_in);
93  return input->allocate<algorithmFPType>(_par, (int) method);
94  }
95 };
96 
116 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
117 class Batch : public layers::forward::LayerIfaceImpl
118 {
119 public:
120  typedef layers::forward::LayerIfaceImpl super;
121 
122  typedef algorithms::neural_networks::layers::transposed_conv2d::forward::Input InputType;
123  typedef algorithms::neural_networks::layers::transposed_conv2d::Parameter ParameterType;
124  typedef algorithms::neural_networks::layers::transposed_conv2d::forward::Result ResultType;
125 
126  ParameterType &parameter;
127  InputType input;
133  DAAL_DEPRECATED Batch() : parameter(_defaultParameter)
134  {
135  initialize();
136  };
137 
144  DAAL_DEPRECATED Batch(ParameterType& parameter) : parameter(parameter), _defaultParameter(parameter)
145  {
146  initialize();
147  };
148 
155  Batch(const Batch<algorithmFPType, method> &other) : super(other),
156  _defaultParameter(other.parameter), parameter(_defaultParameter), input(other.input)
157  {
158  initialize();
159  }
160 
165  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
166 
171  virtual InputType *getLayerInput() DAAL_C11_OVERRIDE { return &input; }
172 
177  virtual ParameterType *getLayerParameter() DAAL_C11_OVERRIDE { return &parameter; };
178 
183  layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
184  {
185  return getResult();
186  }
187 
192  ResultPtr getResult()
193  {
194  return _result;
195  }
196 
203  services::Status setResult(const ResultPtr& result)
204  {
205  DAAL_CHECK(result, services::ErrorNullResult)
206  _result = result;
207  _res = _result.get();
208  return services::Status();
209  }
210 
216  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
217  {
218  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
219  }
220 
221  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
222  {
223  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
224  this->_res = this->_result.get();
225  return s;
226  }
227 
228 protected:
229  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
230  {
231  return new Batch<algorithmFPType, method>(*this);
232  }
233 
234  void initialize()
235  {
236  Analysis<batch>::_ac = new __DAAL_ALGORITHM_LAYER_CONTAINER(BatchContainer, algorithmFPType, method)(&_env);
237  _in = &input;
238  _par = &parameter;
239  _result.reset(new ResultType());
240  }
241 
242 private:
243  ResultPtr _result;
244  ParameterType _defaultParameter;
245 };
246 
248 } // namespace interface1
249 using interface1::BatchContainer;
250 using interface1::Batch;
251 } // namespace forward
252 } // namespace transposed_conv2d
253 } // namespace layers
254 } // namespace neural_networks
255 } // namespace algorithms
256 } // namespace daal
257 #endif
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::Batch::Batch
DAAL_DEPRECATED Batch(ParameterType &parameter)
Definition: transposed_conv2d_layer_forward.h:144
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: transposed_conv2d_layer_forward.h:203
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::BatchContainer
Provides methods to run implementations of the forward 2D transposed convolution layer. This class is associated with the daal::algorithms::neural_networks::layers::transposed_conv2d::forward::Batch class and supports the method of forward 2D transposed convolution layer computation in the batch processing mode.
Definition: transposed_conv2d_layer_forward.h:67
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::Input
Input objects for the forward 2D transposed convolution layer
Definition: transposed_conv2d_layer_forward_types.h:66
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: transposed_conv2d_layer_forward.h:155
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: transposed_conv2d_layer_forward.h:216
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::Batch::getLayerParameter
virtual ParameterType * getLayerParameter() DAAL_C11_OVERRIDE
Definition: transposed_conv2d_layer_forward.h:177
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::Batch::getResult
ResultPtr getResult()
Definition: transposed_conv2d_layer_forward.h:192
daal_defines.h
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::Input::allocate
DAAL_EXPORT services::Status allocate(const daal::algorithms::Parameter *parameter, const int method)
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::Batch::getLayerResult
layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
Definition: transposed_conv2d_layer_forward.h:183
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: transposed_conv2d_layer_forward.h:165
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::Batch
Provides methods for forward 2D transposed convolution layer computations in the batch processing mod...
Definition: transposed_conv2d_layer_forward.h:117
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::Batch::Batch
DAAL_DEPRECATED Batch()
Definition: transposed_conv2d_layer_forward.h:133
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::Batch::getLayerInput
virtual InputType * getLayerInput() DAAL_C11_OVERRIDE
Definition: transposed_conv2d_layer_forward.h:171
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::transposed_conv2d::forward::interface1::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::Batch::input
InputType input
Definition: transposed_conv2d_layer_forward.h:127
daal::algorithms::neural_networks::layers::transposed_conv2d::forward::interface1::Batch::parameter
ParameterType & parameter
Definition: transposed_conv2d_layer_forward.h:126

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