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

ridge_regression_training_distributed.h
1 /* file: ridge_regression_training_distributed.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 interface for ridge regression model-based training in the distributed processing mode
45 //--
46 */
47 
48 #ifndef __RIDGE_REGRESSION_TRAINING_DISTRIBUTED_H__
49 #define __RIDGE_REGRESSION_TRAINING_DISTRIBUTED_H__
50 
51 #include "algorithms/algorithm.h"
52 #include "data_management/data/numeric_table.h"
53 #include "services/daal_defines.h"
54 #include "services/daal_memory.h"
55 #include "algorithms/ridge_regression/ridge_regression_training_types.h"
56 #include "algorithms/ridge_regression/ridge_regression_training_online.h"
57 #include "algorithms/ridge_regression/ridge_regression_model.h"
58 
59 namespace daal
60 {
61 namespace algorithms
62 {
63 namespace ridge_regression
64 {
65 namespace training
66 {
67 namespace interface1
68 {
78 template<ComputeStep step, typename algorithmFPType, Method method, CpuType cpu>
79 class DAAL_EXPORT DistributedContainer
80 {};
81 
86 template<typename algorithmFPType, Method method, CpuType cpu>
87 class DAAL_EXPORT DistributedContainer<step2Master, algorithmFPType, method, cpu> : public TrainingContainerIface<distributed>
88 {
89 public:
94  DistributedContainer(daal::services::Environment::env *daalEnv);
95 
97  ~DistributedContainer();
98 
104  services::Status compute() DAAL_C11_OVERRIDE;
105 
111  services::Status finalizeCompute() DAAL_C11_OVERRIDE;
112 };
113 
132 template<ComputeStep step, typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = normEqDense>
133 class DAAL_EXPORT Distributed : public Training<distributed> {};
134 
152 template<typename algorithmFPType, Method method>
153 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> : public Online<algorithmFPType, method>
154 {
155 public:
157  Distributed<step1Local, algorithmFPType, method>() : Online<algorithmFPType, method>()
158  {}
159 
165  Distributed(const Distributed<step1Local, algorithmFPType, method> &other) : Online<algorithmFPType, method>(other)
166  {}
167 
168  ~Distributed() {}
169 
175  services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone() const
176  {
177  return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
178  }
179 
180 protected:
181  virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
182  {
183  return new Distributed<step1Local, algorithmFPType, method>(*this);
184  }
185 
186 }; // class : public Training
187 
204 template<typename algorithmFPType, Method method>
205 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> : public Training<distributed>
206 {
207 public:
209  Distributed()
210  {
211  initialize();
212  }
213 
219  Distributed(const Distributed<step2Master, algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
220  {
221  initialize();
222  }
223 
224  ~Distributed() {}
225 
230  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
231 
238  services::Status setPartialResult(const PartialResultPtr& partialResult)
239  {
240  DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
241  _partialResult = partialResult;
242  _pres = _partialResult.get();
243  return services::Status();
244  }
245 
250  PartialResultPtr getPartialResult() { return _partialResult; }
251 
258  services::Status setResult(const ResultPtr& res)
259  {
260  DAAL_CHECK(res, services::ErrorNullResult)
261  _result = res;
262  _res = _result.get();
263  return services::Status();
264  }
265 
270  ResultPtr getResult() { return _result; }
271 
277  services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone() const
278  {
279  return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
280  }
281 
282  DistributedInput<step2Master> input;
283  TrainParameter parameter;
285 protected:
286  PartialResultPtr _partialResult;
287  ResultPtr _result;
288 
289  virtual Distributed<step2Master, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
290  {
291  return new Distributed<step2Master, algorithmFPType, method>(*this);
292  }
293 
294  services::Status allocateResult() DAAL_C11_OVERRIDE
295  {
296  services::Status s = _result->allocate<algorithmFPType>(_pres, &parameter, method);
297  _res = _result.get();
298  return s;
299  }
300 
301  services::Status allocatePartialResult() DAAL_C11_OVERRIDE
302  {
303  services::Status s = _partialResult->allocate<algorithmFPType>(&input, &parameter, method);
304  _pres = _partialResult.get();
305  return s;
306  }
307 
308  services::Status initializePartialResult() DAAL_C11_OVERRIDE
309  {
310  return services::Status();
311  }
312 
313  void initialize()
314  {
315  _ac = new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
316  _in = &input;
317  _par = &parameter;
318  _partialResult.reset(new PartialResult());
319  _result.reset(new Result());
320  }
321 
322 }; // class : public Training
324 } // namespace interface1
325 
326 using interface1::DistributedContainer;
327 using interface1::Distributed;
328 
329 } // namespace training
330 } // namespace ridge_regression
331 } // namespace algorithms
332 } // namespace daal
333 
334 #endif
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed()
Definition: ridge_regression_training_distributed.h:209
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::setResult
services::Status setResult(const ResultPtr &res)
Definition: ridge_regression_training_distributed.h:258
daal
Definition: algorithm_base_common.h:57
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:79
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::getPartialResult
PartialResultPtr getPartialResult()
Definition: ridge_regression_training_distributed.h:250
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:205
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:277
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:131
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: ridge_regression_training_distributed.h:270
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:121
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::input
DistributedInput< step2Master > input
Definition: ridge_regression_training_distributed.h:282
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: ridge_regression_training_distributed.h:219
daal_defines.h
daal::algorithms::kmeans::init::interface1::Distributed
class DAAL_EXPORT Distributed
Computes initial clusters for the K-Means algorithm in the distributed processing mode...
Definition: kmeans_init_distributed.h:281
daal::distributed
Definition: daal_defines.h:132
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: ridge_regression_training_distributed.h:230
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:153
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:304
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::parameter
TrainParameter parameter
Definition: ridge_regression_training_distributed.h:283
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:175
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:81
daal::step1Local
Definition: daal_defines.h:142
daal::step2Master
Definition: daal_defines.h:143
daal::algorithms::ridge_regression::training::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: ridge_regression_training_distributed.h:165
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:133
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const PartialResultPtr &partialResult)
Definition: ridge_regression_training_distributed.h:238
daal::services::ErrorNullResult
Definition: error_indexes.h:122
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:76
daal::algorithms::Training
Provides methods to train models that depend on the data provided. For example, these methods enable ...
Definition: training.h:86

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