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

xavier_initializer.h
1 /* file: xavier_initializer.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 Xavier initializer in the batch processing mode
19 //--
20 */
21 
22 #ifndef __XAVIER_INITIALIZER_H__
23 #define __XAVIER_INITIALIZER_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/initializers/initializer.h"
29 #include "algorithms/neural_networks/initializers/initializer_types.h"
30 #include "algorithms/neural_networks/initializers/xavier/xavier_initializer_types.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace neural_networks
37 {
38 namespace initializers
39 {
40 namespace xavier
41 {
47 namespace interface1
48 {
59 template<typename algorithmFPType, Method method, CpuType cpu>
60 class DAAL_EXPORT BatchContainer : public initializers::InitializerContainerIface
61 {
62 public:
68  BatchContainer(daal::services::Environment::env *daalEnv);
70  ~BatchContainer();
76  services::Status compute() DAAL_C11_OVERRIDE;
77 };
78 
93 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
94 class DAAL_EXPORT Batch : public initializers::InitializerIface
95 {
96 public:
97  typedef initializers::InitializerIface super;
98 
99  typedef typename super::InputType InputType;
100  typedef algorithms::neural_networks::initializers::xavier::Parameter ParameterType;
101  typedef typename super::ResultType ResultType;
102 
103  ParameterType parameter;
108  Batch()
109  {
110  initialize();
111  }
112 
118  Batch(const Batch<algorithmFPType, method> &other) : super(other), parameter(other.parameter)
119  {
120  initialize();
121  }
122 
127  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
128 
133  virtual ParameterType * getParameter() DAAL_C11_OVERRIDE { return &parameter; }
134 
139  ResultPtr getResult()
140  {
141  return _result;
142  }
143 
150  services::Status setResult(const ResultPtr &result)
151  {
152  _result = result;
153  _res = _result.get();
154  return services::Status();
155  }
156 
162  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
163  {
164  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
165  }
166 
172  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
173  {
174  _par = &parameter;
175  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
176  this->_res = this->_result.get();
177  return s;
178  }
179 
180 protected:
181  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
182  {
183  return new Batch<algorithmFPType, method>(*this);
184  }
185 
186  void initialize()
187  {
188  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
189  _in = &input;
190  _par = &parameter;
191  _result.reset(new ResultType());
192  }
193 
194 private:
195  ResultPtr _result;
196 };
197 
198 } // namespace interface1
199 using interface1::BatchContainer;
200 using interface1::Batch;
202 } // namespace xavier
203 } // namespace initializers
204 } // namespace neural_networks
205 } // namespace algorithms
206 } // namespace daal
207 #endif
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::getResult
ResultPtr getResult()
Definition: xavier_initializer.h:139
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::getParameter
virtual ParameterType * getParameter() DAAL_C11_OVERRIDE
Definition: xavier_initializer.h:133
daal
Definition: algorithm_base_common.h:31
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: xavier_initializer.h:150
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch
Provides methods for Xavier initializer computations in the batch processing mode.
Definition: xavier_initializer.h:94
daal_defines.h
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: xavier_initializer.h:118
daal::batch
Definition: daal_defines.h:110
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:60
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::parameter
ParameterType parameter
Definition: xavier_initializer.h:103
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::allocateResult
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: xavier_initializer.h:172
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::Batch
Batch()
Definition: xavier_initializer.h:108
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::initializers::xavier::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: xavier_initializer.h:127
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: xavier_initializer.h:162

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