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

ridge_regression_training_distributed.h
1 /* file: ridge_regression_training_distributed.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 interface for ridge regression model-based training in the distributed processing mode
19 //--
20 */
21 
22 #ifndef __RIDGE_REGRESSION_TRAINING_DISTRIBUTED_H__
23 #define __RIDGE_REGRESSION_TRAINING_DISTRIBUTED_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "data_management/data/numeric_table.h"
27 #include "services/daal_defines.h"
28 #include "services/daal_memory.h"
29 #include "algorithms/ridge_regression/ridge_regression_training_types.h"
30 #include "algorithms/ridge_regression/ridge_regression_training_online.h"
31 #include "algorithms/ridge_regression/ridge_regression_model.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
37 namespace ridge_regression
38 {
39 namespace training
40 {
41 namespace interface1
42 {
52 template<ComputeStep step, typename algorithmFPType, Method method, CpuType cpu>
53 class DAAL_EXPORT DistributedContainer
54 {};
55 
60 template<typename algorithmFPType, Method method, CpuType cpu>
61 class DAAL_EXPORT DistributedContainer<step2Master, algorithmFPType, method, cpu> : public TrainingContainerIface<distributed>
62 {
63 public:
68  DistributedContainer(daal::services::Environment::env *daalEnv);
69 
71  ~DistributedContainer();
72 
78  services::Status compute() DAAL_C11_OVERRIDE;
79 
85  services::Status finalizeCompute() DAAL_C11_OVERRIDE;
86 };
87 
106 template<ComputeStep step, typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = normEqDense>
107 class DAAL_EXPORT Distributed : public Training<distributed> {};
108 
126 template<typename algorithmFPType, Method method>
127 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> : public Online<algorithmFPType, method>
128 {
129 public:
130  typedef Online<algorithmFPType, method> super;
131 
132  typedef typename super::InputType InputType;
133  typedef typename super::ParameterType ParameterType;
134  typedef typename super::ResultType ResultType;
135  typedef typename super::PartialResultType PartialResultType;
136 
138  Distributed<step1Local, algorithmFPType, method>() : Online<algorithmFPType, method>()
139  {}
140 
146  Distributed(const Distributed<step1Local, algorithmFPType, method> &other) : Online<algorithmFPType, method>(other)
147  {}
148 
149  ~Distributed() {}
150 
156  services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone() const
157  {
158  return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
159  }
160 
161 protected:
162  virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
163  {
164  return new Distributed<step1Local, algorithmFPType, method>(*this);
165  }
166 
167 }; // class : public Training
168 
185 template<typename algorithmFPType, Method method>
186 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> : public Training<distributed>
187 {
188 public:
189  typedef algorithms::ridge_regression::training::DistributedInput<step2Master> InputType;
190  typedef algorithms::ridge_regression::TrainParameter ParameterType;
191  typedef algorithms::ridge_regression::training::Result ResultType;
192  typedef algorithms::ridge_regression::training::PartialResult PartialResultType;
193 
195  Distributed()
196  {
197  initialize();
198  }
199 
205  Distributed(const Distributed<step2Master, algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
206  {
207  initialize();
208  }
209 
210  ~Distributed() {}
211 
216  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
217 
224  services::Status setPartialResult(const PartialResultPtr& partialResult)
225  {
226  DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
227  _partialResult = partialResult;
228  _pres = _partialResult.get();
229  return services::Status();
230  }
231 
236  PartialResultPtr getPartialResult() { return _partialResult; }
237 
244  services::Status setResult(const ResultPtr& res)
245  {
246  DAAL_CHECK(res, services::ErrorNullResult)
247  _result = res;
248  _res = _result.get();
249  return services::Status();
250  }
251 
256  ResultPtr getResult() { return _result; }
257 
263  services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone() const
264  {
265  return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
266  }
267 
268  DistributedInput<step2Master> input;
269  ParameterType parameter;
271 protected:
272  PartialResultPtr _partialResult;
273  ResultPtr _result;
274 
275  virtual Distributed<step2Master, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
276  {
277  return new Distributed<step2Master, algorithmFPType, method>(*this);
278  }
279 
280  services::Status allocateResult() DAAL_C11_OVERRIDE
281  {
282  services::Status s = _result->allocate<algorithmFPType>(_pres, &parameter, method);
283  _res = _result.get();
284  return s;
285  }
286 
287  services::Status allocatePartialResult() DAAL_C11_OVERRIDE
288  {
289  services::Status s = _partialResult->allocate<algorithmFPType>(&input, &parameter, method);
290  _pres = _partialResult.get();
291  return s;
292  }
293 
294  services::Status initializePartialResult() DAAL_C11_OVERRIDE
295  {
296  return services::Status();
297  }
298 
299  void initialize()
300  {
301  _ac = new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
302  _in = &input;
303  _par = &parameter;
304  _partialResult.reset(new PartialResultType());
305  _result.reset(new ResultType());
306  }
307 
308 }; // class : public Training
310 } // namespace interface1
311 
312 using interface1::DistributedContainer;
313 using interface1::Distributed;
314 
315 } // namespace training
316 } // namespace ridge_regression
317 } // namespace algorithms
318 } // namespace daal
319 
320 #endif
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed()
Definition: ridge_regression_training_distributed.h:195
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::setResult
services::Status setResult(const ResultPtr &res)
Definition: ridge_regression_training_distributed.h:244
daal
Definition: algorithm_base_common.h:31
daal::algorithms::ridge_regression::training::interface1::DistributedContainer
Class containing methods for ridge regression model-based training in the distributed processing mode...
Definition: ridge_regression_training_distributed.h:53
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::getPartialResult
PartialResultPtr getPartialResult()
Definition: ridge_regression_training_distributed.h:236
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >
Performs ridge regression model-based training in the the second step of distributed processing mode...
Definition: ridge_regression_training_distributed.h:186
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, method > > clone() const
Definition: ridge_regression_training_distributed.h:263
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:105
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: ridge_regression_training_distributed.h:256
daal::algorithms::ridge_regression::training::interface1::Online
Provides methods for ridge regression model-based training in the online processing mode...
Definition: ridge_regression_training_online.h:95
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::input
DistributedInput< step2Master > input
Definition: ridge_regression_training_distributed.h:268
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: ridge_regression_training_distributed.h:205
daal_defines.h
daal::algorithms::kmeans::init::interface2::Distributed
class DAAL_EXPORT Distributed
Computes initial clusters for the K-Means algorithm in the distributed processing mode...
Definition: kmeans_init_distributed.h:275
daal::distributed
Definition: daal_defines.h:111
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: ridge_regression_training_distributed.h:216
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::parameter
ParameterType parameter
Definition: ridge_regression_training_distributed.h:269
daal::algorithms::ridge_regression::training::interface1::Distributed< step1Local, algorithmFPType, method >
Performs ridge regression model-based training in the the first step of the distributed processing mo...
Definition: ridge_regression_training_distributed.h:127
daal::algorithms::ridge_regression::training::interface1::DistributedInput< step2Master >
Input object for ridge regression model-based training in the second step of the distributed processi...
Definition: ridge_regression_training_types.h:278
daal::algorithms::ridge_regression::training::interface1::Distributed< step1Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step1Local, algorithmFPType, method > > clone() const
Definition: ridge_regression_training_distributed.h:156
daal::algorithms::kmeans::interface1::DistributedContainer
class DAAL_EXPORT DistributedContainer
Provides methods to run implementations of the K-Means algorithm. This class is associated with the d...
Definition: kmeans_distributed.h:55
daal::step1Local
Definition: daal_defines.h:121
daal::step2Master
Definition: daal_defines.h:122
daal::algorithms::ridge_regression::training::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: ridge_regression_training_distributed.h:146
daal::algorithms::ridge_regression::training::interface1::Distributed
Provides methods for ridge regression model-based training in the distributed processing mode...
Definition: ridge_regression_training_distributed.h:107
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const PartialResultPtr &partialResult)
Definition: ridge_regression_training_distributed.h:224
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:50
daal::algorithms::Training
Provides methods to train models that depend on the data provided. For example, these methods enable ...
Definition: training.h:60

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