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

xavier_initializer.h
1 /* file: xavier_initializer.h */
2 /*******************************************************************************
3 * Copyright 2014-2017 Intel Corporation
4 * All Rights Reserved.
5 *
6 * If this software was obtained under the Intel Simplified Software License,
7 * the following terms apply:
8 *
9 * The source code, information and material ("Material") contained herein is
10 * owned by Intel Corporation or its suppliers or licensors, and title to such
11 * Material remains with Intel Corporation or its suppliers or licensors. The
12 * Material contains proprietary information of Intel or its suppliers and
13 * licensors. The Material is protected by worldwide copyright laws and treaty
14 * provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed or disclosed
16 * in any way without Intel's prior express written permission. No license under
17 * any patent, copyright or other intellectual property rights in the Material
18 * is granted to or conferred upon you, either expressly, by implication,
19 * inducement, estoppel or otherwise. Any license under such intellectual
20 * property rights must be express and approved by Intel in writing.
21 *
22 * Unless otherwise agreed by Intel in writing, you may not remove or alter this
23 * notice or any other notice embedded in Materials by Intel or Intel's
24 * suppliers or licensors in any way.
25 *
26 *
27 * If this software was obtained under the Apache License, Version 2.0 (the
28 * "License"), the following terms apply:
29 *
30 * You may not use this file except in compliance with the License. You may
31 * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
32 *
33 *
34 * Unless required by applicable law or agreed to in writing, software
35 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
36 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37 *
38 * See the License for the specific language governing permissions and
39 * limitations under the License.
40 *******************************************************************************/
41 
42 /*
43 //++
44 // Implementation of the Xavier initializer in the batch processing mode
45 //--
46 */
47 
48 #ifndef __XAVIER_INITIALIZER_H__
49 #define __XAVIER_INITIALIZER_H__
50 
51 #include "algorithms/algorithm.h"
52 #include "data_management/data/tensor.h"
53 #include "services/daal_defines.h"
54 #include "algorithms/neural_networks/initializers/initializer.h"
55 #include "algorithms/neural_networks/initializers/initializer_types.h"
56 #include "algorithms/neural_networks/initializers/xavier/xavier_initializer_types.h"
57 
58 namespace daal
59 {
60 namespace algorithms
61 {
62 namespace neural_networks
63 {
64 namespace initializers
65 {
66 namespace xavier
67 {
73 namespace interface1
74 {
85 template<typename algorithmFPType, Method method, CpuType cpu>
86 class DAAL_EXPORT BatchContainer : public initializers::InitializerContainerIface
87 {
88 public:
94  BatchContainer(daal::services::Environment::env *daalEnv);
96  ~BatchContainer();
102  services::Status compute() DAAL_C11_OVERRIDE;
103 };
104 
119 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
120 class DAAL_EXPORT Batch : public initializers::InitializerIface
121 {
122 public:
123  typedef initializers::InitializerIface super;
124  Parameter parameter;
129  Batch()
130  {
131  initialize();
132  }
133 
139  Batch(const Batch<algorithmFPType, method> &other) : super(other), parameter(other.parameter)
140  {
141  initialize();
142  }
143 
148  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
149 
154  virtual Parameter * getParameter() DAAL_C11_OVERRIDE { return &parameter; }
155 
160  ResultPtr getResult()
161  {
162  return _result;
163  }
164 
171  services::Status setResult(const ResultPtr &result)
172  {
173  _result = result;
174  _res = _result.get();
175  return services::Status();
176  }
177 
183  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
184  {
185  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
186  }
187 
193  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
194  {
195  _par = &parameter;
196  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
197  this->_res = this->_result.get();
198  return s;
199  }
200 
201 protected:
202  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
203  {
204  return new Batch<algorithmFPType, method>(*this);
205  }
206 
207  void initialize()
208  {
209  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
210  _in = &input;
211  _par = &parameter;
212  _result.reset(new Result());
213  }
214 
215 private:
216  ResultPtr _result;
217 };
218 
219 } // namespace interface1
220 using interface1::BatchContainer;
221 using interface1::Batch;
223 } // namespace xavier
224 } // namespace initializers
225 } // namespace neural_networks
226 } // namespace algorithms
227 } // namespace daal
228 #endif
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::getResult
ResultPtr getResult()
Definition: xavier_initializer.h:160
daal
Definition: algorithm_base_common.h:57
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: xavier_initializer.h:171
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch
Provides methods for Xavier initializer computations in the batch processing mode.
Definition: xavier_initializer.h:120
daal_defines.h
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: xavier_initializer.h:139
daal::batch
Definition: daal_defines.h:131
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:86
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::parameter
Parameter parameter
Definition: xavier_initializer.h:124
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::allocateResult
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: xavier_initializer.h:193
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::Batch
Batch()
Definition: xavier_initializer.h:129
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:94
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::getParameter
virtual Parameter * getParameter() DAAL_C11_OVERRIDE
Definition: xavier_initializer.h:154
daal::algorithms::neural_networks::initializers::xavier::interface1::Parameter
Xavier initializer parameters.
Definition: xavier_initializer_types.h:95
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: xavier_initializer.h:148
daal::algorithms::neural_networks::initializers::xavier::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: xavier_initializer.h:183

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