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

ridge_regression_training_distributed.h
1 /* file: ridge_regression_training_distributed.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 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:
156  typedef Online<algorithmFPType, method> super;
157 
158  typedef typename super::InputType InputType;
159  typedef typename super::ParameterType ParameterType;
160  typedef typename super::ResultType ResultType;
161  typedef typename super::PartialResultType PartialResultType;
162 
164  Distributed<step1Local, algorithmFPType, method>() : Online<algorithmFPType, method>()
165  {}
166 
172  Distributed(const Distributed<step1Local, algorithmFPType, method> &other) : Online<algorithmFPType, method>(other)
173  {}
174 
175  ~Distributed() {}
176 
182  services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone() const
183  {
184  return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
185  }
186 
187 protected:
188  virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
189  {
190  return new Distributed<step1Local, algorithmFPType, method>(*this);
191  }
192 
193 }; // class : public Training
194 
211 template<typename algorithmFPType, Method method>
212 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> : public Training<distributed>
213 {
214 public:
215  typedef algorithms::ridge_regression::training::DistributedInput<step2Master> InputType;
216  typedef algorithms::ridge_regression::TrainParameter ParameterType;
217  typedef algorithms::ridge_regression::training::Result ResultType;
218  typedef algorithms::ridge_regression::training::PartialResult PartialResultType;
219 
221  Distributed()
222  {
223  initialize();
224  }
225 
231  Distributed(const Distributed<step2Master, algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
232  {
233  initialize();
234  }
235 
236  ~Distributed() {}
237 
242  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
243 
250  services::Status setPartialResult(const PartialResultPtr& partialResult)
251  {
252  DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
253  _partialResult = partialResult;
254  _pres = _partialResult.get();
255  return services::Status();
256  }
257 
262  PartialResultPtr getPartialResult() { return _partialResult; }
263 
270  services::Status setResult(const ResultPtr& res)
271  {
272  DAAL_CHECK(res, services::ErrorNullResult)
273  _result = res;
274  _res = _result.get();
275  return services::Status();
276  }
277 
282  ResultPtr getResult() { return _result; }
283 
289  services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone() const
290  {
291  return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
292  }
293 
294  DistributedInput<step2Master> input;
295  ParameterType parameter;
297 protected:
298  PartialResultPtr _partialResult;
299  ResultPtr _result;
300 
301  virtual Distributed<step2Master, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
302  {
303  return new Distributed<step2Master, algorithmFPType, method>(*this);
304  }
305 
306  services::Status allocateResult() DAAL_C11_OVERRIDE
307  {
308  services::Status s = _result->allocate<algorithmFPType>(_pres, &parameter, method);
309  _res = _result.get();
310  return s;
311  }
312 
313  services::Status allocatePartialResult() DAAL_C11_OVERRIDE
314  {
315  services::Status s = _partialResult->allocate<algorithmFPType>(&input, &parameter, method);
316  _pres = _partialResult.get();
317  return s;
318  }
319 
320  services::Status initializePartialResult() DAAL_C11_OVERRIDE
321  {
322  return services::Status();
323  }
324 
325  void initialize()
326  {
327  _ac = new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
328  _in = &input;
329  _par = &parameter;
330  _partialResult.reset(new PartialResultType());
331  _result.reset(new ResultType());
332  }
333 
334 }; // class : public Training
336 } // namespace interface1
337 
338 using interface1::DistributedContainer;
339 using interface1::Distributed;
340 
341 } // namespace training
342 } // namespace ridge_regression
343 } // namespace algorithms
344 } // namespace daal
345 
346 #endif
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed()
Definition: ridge_regression_training_distributed.h:221
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::setResult
services::Status setResult(const ResultPtr &res)
Definition: ridge_regression_training_distributed.h:270
daal::services::interface1::Environment::_envStruct
The environment structure.
Definition: env_detect.h:95
daal::services::interface1::Status
Class that holds the results of API calls. In case of API routine failure it contains the list of err...
Definition: error_handling.h:491
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:262
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:212
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:289
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:282
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:294
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: ridge_regression_training_distributed.h:231
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:182
daal::algorithms::linear_model::training::interface1::Result
Provides methods to access the result obtained with the compute() method of the regression model-base...
Definition: linear_model_training_types.h:174
daal::algorithms::linear_model::interface1::Parameter
Parameters for the regression algorithm.
Definition: linear_model_model.h:85
daal_defines.h
daal::algorithms::ridge_regression::interface1::TrainParameter
Parameters for the ridge regression algorithm.
Definition: ridge_regression_model.h:94
daal::algorithms::linear_model::training::interface1::Input
Input objects for the regression model-based training
Definition: linear_model_training_types.h:103
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:133
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: ridge_regression_training_distributed.h:242
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::parameter
ParameterType parameter
Definition: ridge_regression_training_distributed.h:295
daal::services::interface1::SharedPtr
Shared pointer that retains shared ownership of an object through a pointer. Several SharedPtr object...
Definition: daal_shared_ptr.h:187
daal::algorithms::ridge_regression::training::interface1::PartialResult
Provides methods to access a partial result obtained with the compute() method of ridge regression mo...
Definition: ridge_regression_training_types.h:216
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::services::interface1::SharedPtr::get
T * get() const
Definition: daal_shared_ptr.h:332
daal::services::interface1::SharedPtr::reset
void reset()
Definition: daal_shared_ptr.h:265
daal::algorithms::linear_model::training::interface1::PartialResult
Provides methods to access a partial result obtained with the compute() method of the linear model-ba...
Definition: linear_model_training_types.h:135
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:143
daal::step2Master
Definition: daal_defines.h:144
daal::algorithms::ridge_regression::training::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: ridge_regression_training_distributed.h:172
daal::algorithms::ridge_regression::training::interface1::Result
Provides methods to access the result obtained with the compute() method of ridge regression model-ba...
Definition: ridge_regression_training_types.h:358
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::DistributedInput
Input object for ridge regression model-based training in the distributed processing mode ...
Definition: ridge_regression_training_types.h:208
daal::algorithms::ridge_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const PartialResultPtr &partialResult)
Definition: ridge_regression_training_distributed.h:250
daal::services::ErrorNullResult
Definition: error_indexes.h:122
daal::algorithms::ridge_regression::training::interface1::Input
Input objects for ridge regression model-based training
Definition: ridge_regression_training_types.h:158
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.