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

smoothrelu_layer_forward.h
1 /* file: smoothrelu_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 SmoothReLU layer in the batch processing mode
21 //--
22 */
23 
24 #ifndef __SMOOTHRELU_LAYER_FORWARD_H__
25 #define __SMOOTHRELU_LAYER_FORWARD_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "data_management/data/tensor.h"
29 #include "services/daal_defines.h"
30 #include "algorithms/neural_networks/layers/layer.h"
31 #include "algorithms/neural_networks/layers/smoothrelu/smoothrelu_layer_types.h"
32 #include "algorithms/neural_networks/layers/smoothrelu/smoothrelu_layer_forward_types.h"
33 
34 namespace daal
35 {
36 namespace algorithms
37 {
38 namespace neural_networks
39 {
40 namespace layers
41 {
42 namespace smoothrelu
43 {
44 namespace forward
45 {
46 namespace interface1
47 {
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 
110 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
111 class Batch : public layers::forward::LayerIfaceImpl
112 {
113 public:
114  typedef layers::forward::LayerIfaceImpl super;
115 
116  typedef algorithms::neural_networks::layers::smoothrelu::forward::Input InputType;
117  typedef algorithms::neural_networks::layers::smoothrelu::Parameter ParameterType;
118  typedef algorithms::neural_networks::layers::smoothrelu::forward::Result ResultType;
119 
120  ParameterType &parameter;
121  InputType input;
127  DAAL_DEPRECATED Batch() : parameter(_defaultParameter)
128  {
129  initialize();
130  };
131 
138  DAAL_DEPRECATED Batch(ParameterType& parameter) : parameter(parameter), _defaultParameter(parameter)
139  {
140  initialize();
141  }
142 
150  Batch(const Batch<algorithmFPType, method> &other) : super(other),
151  _defaultParameter(other.parameter), parameter(_defaultParameter), input(other.input)
152  {
153  initialize();
154  }
155 
161  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
162 
168  DAAL_DEPRECATED_VIRTUAL virtual InputType *getLayerInput() DAAL_C11_OVERRIDE { return &input; }
169 
175  DAAL_DEPRECATED_VIRTUAL virtual ParameterType *getLayerParameter() DAAL_C11_OVERRIDE { return &parameter; };
176 
182  DAAL_DEPRECATED layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
183  {
184  return getResult();
185  }
186 
192  ResultPtr getResult()
193  {
194  return _result;
195  }
196 
204  DAAL_DEPRECATED services::Status setResult(const ResultPtr& result)
205  {
206  DAAL_CHECK(result, services::ErrorNullResult)
207  _result = result;
208  _res = _result.get();
209  return services::Status();
210  }
211 
219  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
220  {
221  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
222  }
223 
230  DAAL_DEPRECATED_VIRTUAL virtual services::Status allocateResult() DAAL_C11_OVERRIDE
231  {
232  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
233  this->_res = this->_result.get();
234  return s;
235  }
236 
237 protected:
238  /*
239  * \DAAL_DEPRECATED
240  */
241  DAAL_DEPRECATED_VIRTUAL virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
242  {
243  return new Batch<algorithmFPType, method>(*this);
244  }
245 
246  /*
247  * \DAAL_DEPRECATED
248  */
249  void initialize()
250  {
251  Analysis<batch>::_ac = new __DAAL_ALGORITHM_LAYER_CONTAINER(BatchContainer, algorithmFPType, method)(&_env);
252  _in = &input;
253  _par = &parameter;
254  _result.reset(new ResultType());
255  }
256 
257 private:
258  ResultPtr _result;
259  ParameterType _defaultParameter;
260 };
262 } // namespace interface1
263 using interface1::BatchContainer;
264 using interface1::Batch;
265 } // namespace forward
266 } // namespace smoothrelu
267 } // namespace layers
268 } // namespace neural_networks
269 } // namespace algorithms
270 } // namespace daal
271 #endif
daal::algorithms::neural_networks::layers::smoothrelu::forward::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::algorithms::neural_networks::layers::smoothrelu::forward::interface1::Batch::getLayerInput
virtual DAAL_DEPRECATED_VIRTUAL InputType * getLayerInput() DAAL_C11_OVERRIDE
Definition: smoothrelu_layer_forward.h:168
daal::algorithms::neural_networks::layers::smoothrelu::forward::interface1::Batch::getLayerParameter
virtual DAAL_DEPRECATED_VIRTUAL ParameterType * getLayerParameter() DAAL_C11_OVERRIDE
Definition: smoothrelu_layer_forward.h:175
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::neural_networks::layers::smoothrelu::forward::interface1::Batch
Provides methods for the forward smooth relu layer in the batch processing mode.
Definition: smoothrelu_layer_forward.h:111
daal::algorithms::neural_networks::layers::smoothrelu::forward::interface1::Batch::Batch
DAAL_DEPRECATED Batch()
Definition: smoothrelu_layer_forward.h:127
daal::algorithms::neural_networks::layers::smoothrelu::forward::interface1::Batch::input
InputType input
Definition: smoothrelu_layer_forward.h:121
daal_defines.h
daal::algorithms::neural_networks::layers::smoothrelu::forward::interface1::Batch::getResult
ResultPtr getResult()
Definition: smoothrelu_layer_forward.h:192
daal::algorithms::neural_networks::layers::smoothrelu::forward::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::neural_networks::layers::smoothrelu::forward::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: smoothrelu_layer_forward.h:150
daal::algorithms::neural_networks::layers::smoothrelu::forward::interface1::Batch::parameter
ParameterType & parameter
Definition: smoothrelu_layer_forward.h:120
daal::algorithms::neural_networks::layers::smoothrelu::forward::interface1::BatchContainer
Provides methods to run implementations of the forward smooth relu layer This class is associated wit...
Definition: smoothrelu_layer_forward.h:66
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::smoothrelu::forward::interface1::Batch::Batch
DAAL_DEPRECATED Batch(ParameterType &parameter)
Definition: smoothrelu_layer_forward.h:138
daal::algorithms::neural_networks::layers::smoothrelu::forward::interface1::Batch::setResult
DAAL_DEPRECATED services::Status setResult(const ResultPtr &result)
Definition: smoothrelu_layer_forward.h:204
daal::algorithms::neural_networks::layers::smoothrelu::forward::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::neural_networks::layers::smoothrelu::forward::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: smoothrelu_layer_forward.h:161
daal::algorithms::neural_networks::layers::smoothrelu::forward::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: smoothrelu_layer_forward.h:219
daal::algorithms::neural_networks::layers::smoothrelu::forward::interface1::Batch::allocateResult
virtual DAAL_DEPRECATED_VIRTUAL services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: smoothrelu_layer_forward.h:230
daal::algorithms::neural_networks::layers::smoothrelu::forward::interface1::Batch::getLayerResult
DAAL_DEPRECATED layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
Definition: smoothrelu_layer_forward.h:182

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