C++ API Reference for Intel® Data Analytics Acceleration Library 2018 Update 3

lcn_layer_forward.h
1 /* file: lcn_layer_forward.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 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 local contrast normalization layer in the batch
19 // processing mode
20 //--
21 */
22 
23 #ifndef __NEURAL_NETWORK_LCN_LAYER_FORWARD_H__
24 #define __NEURAL_NETWORK_LCN_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/lcn/lcn_layer_types.h"
31 #include "algorithms/neural_networks/layers/lcn/lcn_layer_forward_types.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
37 namespace neural_networks
38 {
39 namespace layers
40 {
41 namespace lcn
42 {
43 namespace forward
44 {
45 namespace interface1
46 {
61 template<typename algorithmFPType, Method method, CpuType cpu>
62 class DAAL_EXPORT BatchContainer : public layers::forward::LayerContainerIfaceImpl
63 {
64 public:
70  BatchContainer(daal::services::Environment::env *daalEnv);
72  ~BatchContainer();
78  services::Status compute() DAAL_C11_OVERRIDE;
79  services::Status setupCompute() DAAL_C11_OVERRIDE;
80  services::Status resetCompute() DAAL_C11_OVERRIDE;
81 };
82 
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::lcn::forward::Input InputType;
105  typedef algorithms::neural_networks::layers::lcn::Parameter ParameterType;
106  typedef algorithms::neural_networks::layers::lcn::forward::Result ResultType;
107 
108  ParameterType &parameter;
109  InputType input;
112  Batch() : parameter(_defaultParameter)
113  {
114  initialize();
115  };
116 
122  Batch(ParameterType& parameter) : parameter(parameter), _defaultParameter(parameter)
123  {
124  initialize();
125  };
126 
132  Batch(const Batch<algorithmFPType, method> &other) : super(other),
133  _defaultParameter(other.parameter), parameter(_defaultParameter), input(other.input)
134  {
135  initialize();
136  }
137 
142  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
143 
148  virtual InputType *getLayerInput() DAAL_C11_OVERRIDE { return &input; }
149 
154  virtual ParameterType *getLayerParameter() DAAL_C11_OVERRIDE { return &parameter; };
155 
160  layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
161  {
162  return getResult();
163  }
164 
169  ResultPtr getResult()
170  {
171  return _result;
172  }
173 
180  services::Status setResult(const ResultPtr& result)
181  {
182  DAAL_CHECK(result, services::ErrorNullResult);
183  _result = result;
184  _res = _result.get();
185  return services::Status();
186  }
187 
193  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
194  {
195  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
196  }
197 
198  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
199  {
200  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
201  this->_res = this->_result.get();
202  return s;
203  }
204 
205 protected:
206  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
207  {
208  return new Batch<algorithmFPType, method>(*this);
209  }
210 
211  void initialize()
212  {
213  Analysis<batch>::_ac = new __DAAL_ALGORITHM_LAYER_CONTAINER(BatchContainer, algorithmFPType, method)(&_env);
214  _in = &input;
215  _par = &parameter;
216  _result.reset(new ResultType());
217  }
218 
219 private:
220  ResultPtr _result;
221  ParameterType _defaultParameter;
222 };
224 } // namespace interface1
225 using interface1::BatchContainer;
226 using interface1::Batch;
227 } // namespace forward
228 } // namespace lcn
229 } // namespace layers
230 } // namespace neural_networks
231 } // namespace algorithms
232 } // namespace daal
233 #endif
daal::algorithms::neural_networks::layers::lcn::forward::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: lcn_layer_forward.h:142
daal
Definition: algorithm_base_common.h:31
daal::algorithms::neural_networks::layers::lcn::forward::interface1::BatchContainer
Provides methods to run implementations of the forward local contrast normalization layer...
Definition: lcn_layer_forward.h:62
daal::algorithms::neural_networks::layers::lcn::forward::interface1::Batch::parameter
ParameterType & parameter
Definition: lcn_layer_forward.h:108
daal::algorithms::neural_networks::layers::lcn::forward::interface1::Batch::getResult
ResultPtr getResult()
Definition: lcn_layer_forward.h:169
daal::algorithms::neural_networks::layers::lcn::forward::interface1::Batch::getLayerInput
virtual InputType * getLayerInput() DAAL_C11_OVERRIDE
Definition: lcn_layer_forward.h:148
daal_defines.h
daal::algorithms::neural_networks::layers::lcn::forward::interface1::Batch::getLayerResult
layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
Definition: lcn_layer_forward.h:160
daal::algorithms::neural_networks::layers::lcn::forward::interface1::Batch::Batch
Batch(ParameterType &parameter)
Definition: lcn_layer_forward.h:122
daal::algorithms::neural_networks::layers::lcn::forward::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: lcn_layer_forward.h:180
daal::algorithms::neural_networks::layers::lcn::forward::interface1::Batch::Batch
Batch()
Definition: lcn_layer_forward.h:112
daal::algorithms::neural_networks::layers::lcn::forward::interface1::Batch::getLayerParameter
virtual ParameterType * getLayerParameter() DAAL_C11_OVERRIDE
Definition: lcn_layer_forward.h:154
daal::algorithms::neural_networks::layers::lcn::forward::interface1::Batch
Provides methods for forward local contrast normalization layer computations in the batch processing ...
Definition: lcn_layer_forward.h:99
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::lcn::forward::interface1::Batch::input
InputType input
Definition: lcn_layer_forward.h:109
daal::algorithms::neural_networks::layers::lcn::forward::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: lcn_layer_forward.h:132
daal::algorithms::neural_networks::layers::lcn::forward::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: lcn_layer_forward.h:193
daal::services::ErrorNullResult
Definition: error_indexes.h:96

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