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

xavier_initializer.h
1 /* file: xavier_initializer.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 Xavier initializer in the batch processing mode
21 //--
22 */
23 
24 #ifndef __XAVIER_INITIALIZER_H__
25 #define __XAVIER_INITIALIZER_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/initializers/initializer.h"
31 #include "algorithms/neural_networks/initializers/initializer_types.h"
32 #include "algorithms/neural_networks/initializers/xavier/xavier_initializer_types.h"
33 
34 namespace daal
35 {
36 namespace algorithms
37 {
38 namespace neural_networks
39 {
40 namespace initializers
41 {
42 namespace xavier
43 {
49 namespace interface1
50 {
61 template<typename algorithmFPType, Method method, CpuType cpu>
62 class BatchContainer : public initializers::InitializerContainerIface
63 {
64 public:
70  BatchContainer(daal::services::Environment::env *daalEnv);
72  ~BatchContainer();
78  services::Status compute() DAAL_C11_OVERRIDE;
79 };
80 
95 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
96 class DAAL_EXPORT Batch : public initializers::InitializerIface
97 {
98 public:
99  typedef initializers::InitializerIface super;
100 
101  typedef typename super::InputType InputType;
102  typedef algorithms::neural_networks::initializers::xavier::Parameter ParameterType;
103  typedef typename super::ResultType ResultType;
104 
105  ParameterType parameter;
110  Batch()
111  {
112  initialize();
113  }
114 
120  Batch(const Batch<algorithmFPType, method> &other) : super(other), parameter(other.parameter)
121  {
122  initialize();
123  }
124 
129  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
130 
135  virtual ParameterType * getParameter() DAAL_C11_OVERRIDE { return &parameter; }
136 
141  ResultPtr getResult()
142  {
143  return _result;
144  }
145 
152  services::Status setResult(const ResultPtr &result)
153  {
154  _result = result;
155  _res = _result.get();
156  return services::Status();
157  }
158 
164  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
165  {
166  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
167  }
168 
174  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
175  {
176  _par = &parameter;
177  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
178  this->_res = this->_result.get();
179  return s;
180  }
181 
182 protected:
183  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
184  {
185  return new Batch<algorithmFPType, method>(*this);
186  }
187 
188  void initialize()
189  {
190  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
191  _in = &input;
192  _par = &parameter;
193  _result.reset(new ResultType());
194  }
195 
196 private:
197  ResultPtr _result;
198 };
199 
200 } // namespace interface1
201 using interface1::BatchContainer;
202 using interface1::Batch;
204 } // namespace xavier
205 } // namespace initializers
206 } // namespace neural_networks
207 } // namespace algorithms
208 } // namespace daal
209 #endif
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::Batch
Batch()
Definition: xavier_initializer.h:110
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: xavier_initializer.h:164
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch
Provides methods for Xavier initializer computations in the batch processing mode.
Definition: xavier_initializer.h:96
daal::batch
Definition: daal_defines.h:112
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: xavier_initializer.h:120
daal::algorithms::neural_networks::initializers::xavier::interface1::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::getParameter
virtual ParameterType * getParameter() DAAL_C11_OVERRIDE
Definition: xavier_initializer.h:135
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: xavier_initializer.h:129
daal::algorithms::neural_networks::initializers::xavier::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal_defines.h
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: xavier_initializer.h:152
daal::algorithms::neural_networks::initializers::xavier::interface1::BatchContainer
Provides methods to run implementations of the Xavier initializer. This class is associated with the ...
Definition: xavier_initializer.h:62
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::getResult
ResultPtr getResult()
Definition: xavier_initializer.h:141
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::parameter
ParameterType parameter
Definition: xavier_initializer.h:105
daal::algorithms::neural_networks::initializers::xavier::interface1::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::allocateResult
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: xavier_initializer.h:174
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70

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