C++ API Reference for Intel® Data Analytics Acceleration Library 2019 Update 5

reshape_layer_forward.h
1 /* file: reshape_layer_forward.h */
2 /*******************************************************************************
3 * Copyright 2014-2019 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 reshape layer
19 // in the batch processing mode
20 //--
21 */
22 
23 #ifndef __RESHAPE_LAYER_FORWARD_H__
24 #define __RESHAPE_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/reshape/reshape_layer_types.h"
31 #include "algorithms/neural_networks/layers/reshape/reshape_layer_forward_types.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
37 namespace neural_networks
38 {
39 namespace layers
40 {
41 namespace reshape
42 {
43 namespace forward
44 {
45 namespace interface1
46 {
62 template<typename algorithmFPType, Method method, CpuType cpu>
63 class DAAL_EXPORT BatchContainer : public layers::forward::LayerContainerIfaceImpl
64 {
65 public:
70  BatchContainer(daal::services::Environment::env *daalEnv);
72  ~BatchContainer();
78  services::Status compute() DAAL_C11_OVERRIDE;
79 };
80 
98 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
99 class Batch : public layers::forward::LayerIfaceImpl
100 {
101 public:
102  typedef layers::forward::LayerIfaceImpl super;
103 
104  typedef algorithms::neural_networks::layers::reshape::forward::Input InputType;
105  typedef algorithms::neural_networks::layers::reshape::Parameter ParameterType;
106  typedef algorithms::neural_networks::layers::reshape::forward::Result ResultType;
107 
108  ParameterType &parameter;
109  InputType input;
112  Batch() : parameter(_defaultParameter)
113  {
114  initialize();
115  };
116 
122  Batch(const services::Collection<size_t> &dims) : parameter(_defaultParameter)
123  {
124  parameter.reshapeDimensions = dims;
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::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
173  {
174  return getResult();
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_LAYER_CONTAINER(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 forward
246 } // namespace reshape
247 } // namespace layers
248 } // namespace neural_networks
249 } // namespace algorithms
250 } // namespace daal
251 #endif
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::getLayerInput
virtual InputType * getLayerInput() DAAL_C11_OVERRIDE
Definition: reshape_layer_forward.h:160
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: reshape_layer_forward.h:192
daal
Definition: algorithm_base_common.h:31
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::Batch
Batch(ParameterType &parameter)
Definition: reshape_layer_forward.h:133
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: reshape_layer_forward.h:154
daal_defines.h
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::allocateResult
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: reshape_layer_forward.h:216
daal::algorithms::neural_networks::layers::reshape::forward::interface1::BatchContainer
Provides methods to run implementations of the of the forward reshape layer This class is associated ...
Definition: reshape_layer_forward.h:63
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: reshape_layer_forward.h:206
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::Batch
Batch(const services::Collection< size_t > &dims)
Definition: reshape_layer_forward.h:122
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::getLayerParameter
virtual ParameterType * getLayerParameter() DAAL_C11_OVERRIDE
Definition: reshape_layer_forward.h:166
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::getResult
ResultPtr getResult()
Definition: reshape_layer_forward.h:181
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::input
InputType input
Definition: reshape_layer_forward.h:109
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: reshape_layer_forward.h:144
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::getLayerResult
layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
Definition: reshape_layer_forward.h:172
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::reshape::forward::interface1::Batch
Computes the result of the forward reshape layer in the batch processing mode.
Definition: reshape_layer_forward.h:99
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::parameter
ParameterType & parameter
Definition: reshape_layer_forward.h:108
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::Batch
Batch()
Definition: reshape_layer_forward.h:112
daal::services::ErrorNullResult
Definition: error_indexes.h:96

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