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

reshape_layer_forward.h
1 /* file: reshape_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 reshape layer
21 // in the batch processing mode
22 //--
23 */
24 
25 #ifndef __RESHAPE_LAYER_FORWARD_H__
26 #define __RESHAPE_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/reshape/reshape_layer_types.h"
33 #include "algorithms/neural_networks/layers/reshape/reshape_layer_forward_types.h"
34 
35 namespace daal
36 {
37 namespace algorithms
38 {
39 namespace neural_networks
40 {
41 namespace layers
42 {
43 namespace reshape
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:
75  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
80  DAAL_DEPRECATED ~BatchContainer();
87  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
88 };
89 
109 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
110 class Batch : public layers::forward::LayerIfaceImpl
111 {
112 public:
113  typedef layers::forward::LayerIfaceImpl super;
114 
115  typedef algorithms::neural_networks::layers::reshape::forward::Input InputType;
116  typedef algorithms::neural_networks::layers::reshape::Parameter ParameterType;
117  typedef algorithms::neural_networks::layers::reshape::forward::Result ResultType;
118 
119  ParameterType &parameter;
120  InputType input;
126  DAAL_DEPRECATED Batch() : parameter(_defaultParameter)
127  {
128  initialize();
129  };
130 
137  DAAL_DEPRECATED Batch(const services::Collection<size_t> &dims) : parameter(_defaultParameter)
138  {
139  parameter.reshapeDimensions = dims;
140  initialize();
141  };
142 
149  DAAL_DEPRECATED Batch(ParameterType& parameter) : parameter(parameter), _defaultParameter(parameter)
150  {
151  initialize();
152  }
153 
161  Batch(const Batch<algorithmFPType, method> &other) : super(other),
162  _defaultParameter(other.parameter), parameter(_defaultParameter), input(other.input)
163  {
164  initialize();
165  }
166 
172  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
173 
179  DAAL_DEPRECATED_VIRTUAL virtual InputType *getLayerInput() DAAL_C11_OVERRIDE { return &input; }
180 
186  DAAL_DEPRECATED_VIRTUAL virtual ParameterType *getLayerParameter() DAAL_C11_OVERRIDE { return &parameter; };
187 
193  DAAL_DEPRECATED layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
194  {
195  return getResult();
196  }
197 
203  ResultPtr getResult()
204  {
205  return _result;
206  }
207 
215  DAAL_DEPRECATED services::Status setResult(const ResultPtr& result)
216  {
217  DAAL_CHECK(result, services::ErrorNullResult)
218  _result = result;
219  _res = _result.get();
220  return services::Status();
221  }
222 
230  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
231  {
232  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
233  }
234 
241  DAAL_DEPRECATED_VIRTUAL virtual services::Status allocateResult() DAAL_C11_OVERRIDE
242  {
243  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
244  this->_res = this->_result.get();
245  return s;
246  }
247 
248 protected:
249  /*
250  * \DAAL_DEPRECATED
251  */
252  DAAL_DEPRECATED_VIRTUAL virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
253  {
254  return new Batch<algorithmFPType, method>(*this);
255  }
256 
257  /*
258  * \DAAL_DEPRECATED
259  */
260  void initialize()
261  {
262  Analysis<batch>::_ac = new __DAAL_ALGORITHM_LAYER_CONTAINER(BatchContainer, algorithmFPType, method)(&_env);
263  _in = &input;
264  _par = &parameter;
265  _result.reset(new ResultType());
266  }
267 
268 private:
269  ResultPtr _result;
270  ParameterType _defaultParameter;
271 };
273 } // namespace interface1
274 using interface1::BatchContainer;
275 using interface1::Batch;
276 } // namespace forward
277 } // namespace reshape
278 } // namespace layers
279 } // namespace neural_networks
280 } // namespace algorithms
281 } // namespace daal
282 #endif
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::Batch
DAAL_DEPRECATED Batch()
Definition: reshape_layer_forward.h:126
daal::algorithms::neural_networks::layers::reshape::forward::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::setResult
DAAL_DEPRECATED services::Status setResult(const ResultPtr &result)
Definition: reshape_layer_forward.h:215
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::input
InputType input
Definition: reshape_layer_forward.h:120
daal::algorithms::neural_networks::layers::reshape::forward::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: reshape_layer_forward.h:230
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const services::Collection< size_t > &dims)
Definition: reshape_layer_forward.h:137
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: reshape_layer_forward.h:161
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::getLayerInput
virtual DAAL_DEPRECATED_VIRTUAL InputType * getLayerInput() DAAL_C11_OVERRIDE
Definition: reshape_layer_forward.h:179
daal_defines.h
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: reshape_layer_forward.h:172
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:67
daal::algorithms::neural_networks::layers::reshape::forward::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::allocateResult
virtual DAAL_DEPRECATED_VIRTUAL services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: reshape_layer_forward.h:241
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::parameter
ParameterType & parameter
Definition: reshape_layer_forward.h:119
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::getLayerParameter
virtual DAAL_DEPRECATED_VIRTUAL ParameterType * getLayerParameter() DAAL_C11_OVERRIDE
Definition: reshape_layer_forward.h:186
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::getLayerResult
DAAL_DEPRECATED layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
Definition: reshape_layer_forward.h:193
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:110
daal::algorithms::neural_networks::layers::reshape::forward::interface1::Batch::Batch
DAAL_DEPRECATED Batch(ParameterType &parameter)
Definition: reshape_layer_forward.h:149
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::reshape::forward::interface1::Batch::getResult
ResultPtr getResult()
Definition: reshape_layer_forward.h:203

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