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

tanh_layer_forward.h
1 /* file: tanh_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 hyperbolic tangent layer
21 // in the batch processing mode
22 //--
23 */
24 
25 #ifndef __TANH_LAYER_FORWARD_H__
26 #define __TANH_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/tanh/tanh_layer_forward_types.h"
33 
34 namespace daal
35 {
36 namespace algorithms
37 {
38 namespace neural_networks
39 {
40 namespace layers
41 {
45 namespace tanh
46 {
50 namespace forward
51 {
52 namespace interface1
53 {
71 template<typename algorithmFPType, Method method, CpuType cpu>
72 class BatchContainer : public layers::forward::LayerContainerIfaceImpl
73 {
74 public:
81  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
86  DAAL_DEPRECATED ~BatchContainer();
92  services::Status compute() DAAL_C11_OVERRIDE;
93 };
94 
115 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
116 class Batch : public layers::forward::LayerIfaceImpl
117 {
118 public:
119  typedef layers::forward::LayerIfaceImpl super;
120 
121  typedef algorithms::neural_networks::layers::tanh::forward::Input InputType;
122  typedef algorithms::neural_networks::layers::tanh::Parameter ParameterType;
123  typedef algorithms::neural_networks::layers::tanh::forward::Result ResultType;
124 
125  ParameterType &parameter;
126  InputType input;
132  DAAL_DEPRECATED Batch() : parameter(_defaultParameter)
133  {
134  initialize();
135  };
136 
143  DAAL_DEPRECATED Batch(ParameterType& parameter) : parameter(parameter), _defaultParameter(parameter)
144  {
145  initialize();
146  }
147 
155  Batch(const Batch<algorithmFPType, method> &other) : super(other),
156  _defaultParameter(other.parameter), parameter(_defaultParameter), input(other.input)
157  {
158  initialize();
159  }
160 
165  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
166 
171  virtual InputType *getLayerInput() DAAL_C11_OVERRIDE { return &input; }
172 
177  virtual ParameterType *getLayerParameter() DAAL_C11_OVERRIDE { return &parameter; };
178 
183  layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
184  {
185  return getResult();
186  }
187 
192  ResultPtr getResult()
193  {
194  return _result;
195  }
196 
203  services::Status setResult(const ResultPtr& result)
204  {
205  DAAL_CHECK(result, services::ErrorNullResult)
206  _result = result;
207  _res = _result.get();
208  return services::Status();
209  }
210 
216  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
217  {
218  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
219  }
220 
226  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
227  {
228  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
229  this->_res = this->_result.get();
230  return s;
231  }
232 
233 protected:
234  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
235  {
236  return new Batch<algorithmFPType, method>(*this);
237  }
238 
239  void initialize()
240  {
241  Analysis<batch>::_ac = new __DAAL_ALGORITHM_LAYER_CONTAINER(BatchContainer, algorithmFPType, method)(&_env);
242  _in = &input;
243  _par = &parameter;
244  _result.reset(new ResultType());
245  }
246 
247 private:
248  ResultPtr _result;
249  ParameterType _defaultParameter;
250 };
252 } // namespace interface1
253 using interface1::BatchContainer;
254 using interface1::Batch;
255 } // namespace forward
256 } // namespace tanh
257 } // namespace layers
258 } // namespace neural_networks
259 } // namespace algorithms
260 } // namespace daal
261 #endif
daal::algorithms::neural_networks::layers::tanh::forward::interface1::Batch::getLayerInput
virtual InputType * getLayerInput() DAAL_C11_OVERRIDE
Definition: tanh_layer_forward.h:171
daal::algorithms::neural_networks::layers::tanh::forward::interface1::Batch::Batch
DAAL_DEPRECATED Batch()
Definition: tanh_layer_forward.h:132
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::neural_networks::layers::tanh::forward::interface1::Batch::input
InputType input
Definition: tanh_layer_forward.h:126
daal::algorithms::neural_networks::layers::tanh::forward::interface1::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal_defines.h
daal::algorithms::neural_networks::layers::tanh::forward::interface1::Batch::Batch
DAAL_DEPRECATED Batch(ParameterType &parameter)
Definition: tanh_layer_forward.h:143
daal::algorithms::neural_networks::layers::tanh::forward::interface1::Batch
Computes the results of the forward hyperbolic tangent in the batch processing mode.
Definition: tanh_layer_forward.h:116
daal::algorithms::neural_networks::layers::tanh::forward::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: tanh_layer_forward.h:203
daal::algorithms::neural_networks::layers::tanh::forward::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: tanh_layer_forward.h:216
daal::algorithms::neural_networks::layers::tanh::forward::interface1::Batch::getResult
ResultPtr getResult()
Definition: tanh_layer_forward.h:192
daal::algorithms::neural_networks::layers::tanh::forward::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::algorithms::neural_networks::layers::tanh::forward::interface1::Batch::allocateResult
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: tanh_layer_forward.h:226
daal::algorithms::neural_networks::layers::tanh::forward::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: tanh_layer_forward.h:155
daal::algorithms::neural_networks::layers::tanh::forward::interface1::Batch::parameter
ParameterType & parameter
Definition: tanh_layer_forward.h:125
daal::algorithms::neural_networks::layers::tanh::forward::interface1::BatchContainer
Provides methods to run implementations of the of the forward tanh layer This class is associated wit...
Definition: tanh_layer_forward.h:72
daal::algorithms::neural_networks::layers::tanh::forward::interface1::Batch::getLayerParameter
virtual ParameterType * getLayerParameter() DAAL_C11_OVERRIDE
Definition: tanh_layer_forward.h:177
daal::algorithms::neural_networks::layers::tanh::forward::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
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::tanh::forward::interface1::Batch::getLayerResult
layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
Definition: tanh_layer_forward.h:183
daal::algorithms::neural_networks::layers::tanh::forward::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: tanh_layer_forward.h:165

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