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

smoothrelu_layer_backward.h
1 /* file: smoothrelu_layer_backward.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 backward SmoothReLU layer in the batch processing mode
19 //--
20 */
21 
22 #ifndef __SMOOTHRELU_LAYER_BACKWARD_H__
23 #define __SMOOTHRELU_LAYER_BACKWARD_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "data_management/data/tensor.h"
27 #include "services/daal_defines.h"
28 #include "algorithms/neural_networks/layers/layer.h"
29 #include "algorithms/neural_networks/layers/smoothrelu/smoothrelu_layer_types.h"
30 #include "algorithms/neural_networks/layers/smoothrelu/smoothrelu_layer_backward_types.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace neural_networks
37 {
38 namespace layers
39 {
40 namespace smoothrelu
41 {
42 namespace backward
43 {
44 namespace interface1
45 {
61 template<typename algorithmFPType, Method method, CpuType cpu>
62 class DAAL_EXPORT BatchContainer : public AnalysisContainerIface<batch>
63 {
64 public:
70  BatchContainer(daal::services::Environment::env *daalEnv);
72  ~BatchContainer();
78  services::Status compute() DAAL_C11_OVERRIDE;
79 };
80 
99 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
100 class Batch : public layers::backward::LayerIfaceImpl
101 {
102 public:
103  typedef layers::backward::LayerIfaceImpl super;
104 
105  typedef algorithms::neural_networks::layers::smoothrelu::backward::Input InputType;
106  typedef algorithms::neural_networks::layers::smoothrelu::Parameter ParameterType;
107  typedef algorithms::neural_networks::layers::smoothrelu::backward::Result ResultType;
108 
109  ParameterType &parameter;
110  InputType input;
113  Batch() : parameter(_defaultParameter)
114  {
115  initialize();
116  }
117 
123  Batch(ParameterType& parameter) : parameter(parameter), _defaultParameter(parameter)
124  {
125  initialize();
126  }
127 
134  Batch(const Batch<algorithmFPType, method> &other) : super(other),
135  _defaultParameter(other.parameter), parameter(_defaultParameter), input(other.input)
136  {
137  initialize();
138  }
139 
144  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
145 
150  virtual InputType *getLayerInput() DAAL_C11_OVERRIDE { return &input; }
151 
156  virtual ParameterType *getLayerParameter() DAAL_C11_OVERRIDE { return &parameter; };
157 
162  layers::backward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
163  {
164  return _result;
165  }
166 
171  ResultPtr getResult()
172  {
173  return _result;
174  }
175 
182  services::Status setResult(const ResultPtr& result)
183  {
184  DAAL_CHECK(result, services::ErrorNullResult)
185  _result = result;
186  _res = _result.get();
187  return services::Status();
188  }
189 
196  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
197  {
198  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
199  }
200 
206  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
207  {
208  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
209  this->_res = this->_result.get();
210  return s;
211  }
212 
213 protected:
214  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
215  {
216  return new Batch<algorithmFPType, method>(*this);
217  }
218 
219  void initialize()
220  {
221  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
222  _in = &input;
223  _par = &parameter;
224  _result.reset(new ResultType());
225  }
226 
227 private:
228  ResultPtr _result;
229  ParameterType _defaultParameter;
230 };
232 } // namespace interface1
233 using interface1::BatchContainer;
234 using interface1::Batch;
235 } // namespace backward
236 } // namespace smoothrelu
237 } // namespace layers
238 } // namespace neural_networks
239 } // namespace algorithms
240 } // namespace daal
241 #endif
daal::algorithms::neural_networks::layers::smoothrelu::backward::interface1::Batch::getLayerInput
virtual InputType * getLayerInput() DAAL_C11_OVERRIDE
Definition: smoothrelu_layer_backward.h:150
daal
Definition: algorithm_base_common.h:31
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:53
daal::algorithms::neural_networks::layers::smoothrelu::backward::interface1::Batch::Batch
Batch(ParameterType &parameter)
Definition: smoothrelu_layer_backward.h:123
daal::algorithms::neural_networks::layers::smoothrelu::backward::interface1::Batch
Provides methods for the backward smooth relu layer in the batch processing mode. ...
Definition: smoothrelu_layer_backward.h:100
daal::algorithms::neural_networks::layers::smoothrelu::backward::interface1::Batch::Batch
Batch()
Definition: smoothrelu_layer_backward.h:113
daal_defines.h
daal::algorithms::neural_networks::layers::smoothrelu::backward::interface1::BatchContainer
Provides methods to run implementations of the backward smooth relu layer This class is associated wi...
Definition: smoothrelu_layer_backward.h:62
daal::algorithms::neural_networks::layers::smoothrelu::backward::interface1::Batch::getResult
ResultPtr getResult()
Definition: smoothrelu_layer_backward.h:171
daal::batch
Definition: daal_defines.h:110
daal::algorithms::neural_networks::layers::smoothrelu::backward::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: smoothrelu_layer_backward.h:182
daal::algorithms::neural_networks::layers::smoothrelu::backward::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: smoothrelu_layer_backward.h:134
daal::algorithms::neural_networks::layers::smoothrelu::backward::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: smoothrelu_layer_backward.h:144
daal::algorithms::neural_networks::layers::smoothrelu::backward::interface1::Batch::getLayerResult
layers::backward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
Definition: smoothrelu_layer_backward.h:162
daal::algorithms::neural_networks::layers::smoothrelu::backward::interface1::Batch::getLayerParameter
virtual ParameterType * getLayerParameter() DAAL_C11_OVERRIDE
Definition: smoothrelu_layer_backward.h:156
daal::algorithms::neural_networks::layers::smoothrelu::backward::interface1::Batch::input
InputType input
Definition: smoothrelu_layer_backward.h:110
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::smoothrelu::backward::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: smoothrelu_layer_backward.h:196
daal::algorithms::neural_networks::layers::smoothrelu::backward::interface1::Batch::allocateResult
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: smoothrelu_layer_backward.h:206
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::neural_networks::layers::smoothrelu::backward::interface1::Batch::parameter
ParameterType & parameter
Definition: smoothrelu_layer_backward.h:109

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