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

locallyconnected2d_layer_forward.h
1 /* file: locallyconnected2d_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) locally connected layer in the batch
21 // processing mode
22 //--
23 */
24 
25 #ifndef __LOCALLYCONNECTED2D_LAYER_FORWARD_H__
26 #define __LOCALLYCONNECTED2D_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/locallyconnected2d/locallyconnected2d_layer_types.h"
33 #include "algorithms/neural_networks/layers/locallyconnected2d/locallyconnected2d_layer_forward_types.h"
34 
35 namespace daal
36 {
37 namespace algorithms
38 {
39 namespace neural_networks
40 {
41 namespace layers
42 {
43 namespace locallyconnected2d
44 {
45 namespace forward
46 {
47 namespace interface1
48 {
65 template<typename algorithmFPType, Method method, CpuType cpu>
66 class BatchContainer : public layers::forward::LayerContainerIfaceImpl
67 {
68 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  * \DAAL_DEPRECATED
90  */
91  DAAL_DEPRECATED services::Status setupCompute() DAAL_C11_OVERRIDE;
92  /*
93  * \DAAL_DEPRECATED
94  */
95  DAAL_DEPRECATED_VIRTUAL virtual services::Status allocateInput() DAAL_C11_OVERRIDE
96  {
97  Input *input = static_cast<Input *>(_in);
98  return input->allocate<algorithmFPType>(_par, (int) method);
99  }
100 };
101 
119 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
120 class Batch : public layers::forward::LayerIfaceImpl
121 {
122 public:
123  typedef layers::forward::LayerIfaceImpl super;
124 
125  typedef algorithms::neural_networks::layers::locallyconnected2d::forward::Input InputType;
126  typedef algorithms::neural_networks::layers::locallyconnected2d::Parameter ParameterType;
127  typedef algorithms::neural_networks::layers::locallyconnected2d::forward::Result ResultType;
128 
129  ParameterType &parameter;
130  InputType input;
136  DAAL_DEPRECATED Batch() : parameter(_defaultParameter)
137  {
138  initialize();
139  };
140 
147  DAAL_DEPRECATED Batch(ParameterType& parameter) : parameter(parameter), _defaultParameter(parameter)
148  {
149  initialize();
150  };
151 
158  Batch(const Batch<algorithmFPType, method> &other) : super(other),
159  _defaultParameter(other.parameter), parameter(_defaultParameter), input(other.input)
160  {
161  initialize();
162  }
163 
169  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
170 
176  DAAL_DEPRECATED_VIRTUAL virtual InputType *getLayerInput() DAAL_C11_OVERRIDE { return &input; }
177 
183  DAAL_DEPRECATED_VIRTUAL virtual ParameterType *getLayerParameter() DAAL_C11_OVERRIDE { return &parameter; };
184 
190  DAAL_DEPRECATED layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
191  {
192  return getResult();
193  }
194 
200  ResultPtr getResult()
201  {
202  return _result;
203  }
204 
212  DAAL_DEPRECATED services::Status setResult(const ResultPtr& result)
213  {
214  DAAL_CHECK(result, services::ErrorNullResult)
215  _result = result;
216  _res = _result.get();
217  return services::Status();
218  }
219 
226  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
227  {
228  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
229  }
230 
231  /*
232  * \DAAL_DEPRECATED
233  */
234  DAAL_DEPRECATED_VIRTUAL virtual services::Status allocateResult() DAAL_C11_OVERRIDE
235  {
236  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
237  this->_res = this->_result.get();
238  return s;
239  }
240 
241 protected:
242  /*
243  * \DAAL_DEPRECATED
244  */
245  DAAL_DEPRECATED_VIRTUAL virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
246  {
247  return new Batch<algorithmFPType, method>(*this);
248  }
249 
250  /*
251  * \DAAL_DEPRECATED
252  */
253  void initialize()
254  {
255  Analysis<batch>::_ac = new __DAAL_ALGORITHM_LAYER_CONTAINER(BatchContainer, algorithmFPType, method)(&_env);
256  _in = &input;
257  _par = &parameter;
258  _result.reset(new ResultType());
259  }
260 
261 private:
262  ResultPtr _result;
263  ParameterType _defaultParameter;
264 };
265 
267 } // namespace interface1
268 using interface1::BatchContainer;
269 using interface1::Batch;
270 } // namespace forward
271 } // namespace locallyconnected2d
272 } // namespace layers
273 } // namespace neural_networks
274 } // namespace algorithms
275 } // namespace daal
276 #endif
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::Batch::Batch
DAAL_DEPRECATED Batch(ParameterType &parameter)
Definition: locallyconnected2d_layer_forward.h:147
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::Batch::getLayerParameter
virtual DAAL_DEPRECATED_VIRTUAL ParameterType * getLayerParameter() DAAL_C11_OVERRIDE
Definition: locallyconnected2d_layer_forward.h:183
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: locallyconnected2d_layer_forward.h:169
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::Input
Input objects for the forward 2D locally connected layer
Definition: locallyconnected2d_layer_forward_types.h:66
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: locallyconnected2d_layer_forward.h:226
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::Input::allocate
DAAL_EXPORT services::Status allocate(const daal::algorithms::Parameter *parameter, const int method)
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::Batch::getResult
ResultPtr getResult()
Definition: locallyconnected2d_layer_forward.h:200
daal_defines.h
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::Batch
Provides methods for forward 2D locally connected layer computations in the batch processing mode...
Definition: locallyconnected2d_layer_forward.h:120
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::Batch::parameter
ParameterType & parameter
Definition: locallyconnected2d_layer_forward.h:129
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: locallyconnected2d_layer_forward.h:158
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::Batch::getLayerInput
virtual DAAL_DEPRECATED_VIRTUAL InputType * getLayerInput() DAAL_C11_OVERRIDE
Definition: locallyconnected2d_layer_forward.h:176
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::BatchContainer
Provides methods to run implementations of the forward 2D locally connected layer. This class is associated with the daal::algorithms::neural_networks::layers::locallyconnected2d::forward::Batch class and supports the method of forward 2D locally connected layer computation in the batch processing mode.
Definition: locallyconnected2d_layer_forward.h:66
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::Batch::setResult
DAAL_DEPRECATED services::Status setResult(const ResultPtr &result)
Definition: locallyconnected2d_layer_forward.h:212
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::locallyconnected2d::forward::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::Batch::getLayerResult
DAAL_DEPRECATED layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
Definition: locallyconnected2d_layer_forward.h:190
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::Batch::Batch
DAAL_DEPRECATED Batch()
Definition: locallyconnected2d_layer_forward.h:136
daal::algorithms::neural_networks::layers::locallyconnected2d::forward::interface1::Batch::input
InputType input
Definition: locallyconnected2d_layer_forward.h:130

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