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

relu.h
1 /* file: relu.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 rectified linear function
21 //--
22 */
23 
24 #ifndef __RELU_H__
25 #define __RELU_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "data_management/data/numeric_table.h"
29 #include "services/daal_defines.h"
30 #include "algorithms/math/relu_types.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace math
37 {
38 namespace relu
39 {
40 namespace interface1
41 {
52 template<typename algorithmFPType, Method method, CpuType cpu>
53 class BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
54 {
55 public:
62  BatchContainer(daal::services::Environment::env *daalEnv);
67  ~BatchContainer();
74  virtual services::Status compute() DAAL_C11_OVERRIDE;
75 };
76 
93 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
94 class DAAL_EXPORT Batch : public daal::algorithms::Analysis<batch>
95 {
96 public:
97  typedef algorithms::math::relu::Input InputType;
98  typedef algorithms::math::relu::Result ResultType;
99 
104  Batch()
105  {
106  initialize();
107  }
108 
114  Batch(const Batch<algorithmFPType, method> &other) : input(other.input)
115  {
116  initialize();
117  }
118 
123  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
124 
129  ResultPtr getResult()
130  {
131  return _result;
132  }
133 
140  services::Status setResult(const ResultPtr &result)
141  {
142  DAAL_CHECK(result, services::ErrorNullResult)
143  _result = result;
144  _res = _result.get();
145  return services::Status();
146  }
147 
148  InputType input;
155  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
156  {
157  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
158  }
159 
160 protected:
161  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
162  {
163  return new Batch<algorithmFPType, method>(*this);
164  }
165 
166  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
167  {
168  _result.reset(new ResultType());
169  services::Status s = _result->allocate<algorithmFPType>(&input, NULL, (int) method);
170  _res = _result.get();
171  return s;
172  }
173 
174  void initialize()
175  {
176  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
177  _in = &input;
178  }
179 private:
180  ResultPtr _result;
181 };
183 } // namespace interface1
184 using interface1::BatchContainer;
185 using interface1::Batch;
186 
187 } // namespace relu
188 } // namespace math
189 } // namespace algorithms
190 } // namespace daal
191 #endif
daal::algorithms::math::relu::interface1::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::math::relu::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::math::relu::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: relu.h:155
daal::algorithms::math::relu::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: relu.h:140
daal::batch
Definition: daal_defines.h:112
daal::algorithms::math::relu::interface1::Batch::getResult
ResultPtr getResult()
Definition: relu.h:129
daal::algorithms::math::relu::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: relu.h:114
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:55
daal::algorithms::math::relu::interface1::Batch
Computes the rectified linear function in the batch processing mode.
Definition: relu.h:94
daal_defines.h
daal::algorithms::math::relu::interface1::BatchContainer
Class containing methods for the rectified linear function computing using algorithmFPType precision ...
Definition: relu.h:53
daal::algorithms::math::relu::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: relu.h:123
daal::algorithms::math::relu::interface1::Batch::Batch
Batch()
Definition: relu.h:104
daal::algorithms::math::relu::interface1::Batch::input
InputType input
Definition: relu.h:148
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70
daal::algorithms::math::relu::interface1::BatchContainer::compute
virtual services::Status compute() DAAL_C11_OVERRIDE

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