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

linear_regression_training_distributed.h
1 /* file: linear_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 linear regression model-based training
45 // in the distributed processing mode
46 //--
47 */
48 
49 #ifndef __LINEAR_REGRESSION_TRAINING_DISTRIBUTED_H__
50 #define __LINEAR_REGRESSION_TRAINING_DISTRIBUTED_H__
51 
52 #include "algorithms/algorithm.h"
53 #include "data_management/data/numeric_table.h"
54 #include "services/daal_defines.h"
55 #include "services/daal_memory.h"
56 #include "algorithms/linear_regression/linear_regression_training_types.h"
57 #include "algorithms/linear_regression/linear_regression_training_online.h"
58 
59 #include "algorithms/linear_regression/linear_regression_model.h"
60 
61 namespace daal
62 {
63 namespace algorithms
64 {
65 namespace linear_regression
66 {
67 namespace training
68 {
69 
70 namespace interface1
71 {
81 template<ComputeStep step, typename algorithmFPType, Method method, CpuType cpu>
82 class DAAL_EXPORT DistributedContainer
83 {};
84 
90 template<typename algorithmFPType, Method method, CpuType cpu>
91 class DAAL_EXPORT DistributedContainer<step2Master, algorithmFPType, method, cpu> : public
92  TrainingContainerIface<distributed>
93 {
94 public:
100  DistributedContainer(daal::services::Environment::env *daalEnv);
102  ~DistributedContainer();
103 
110  services::Status compute() DAAL_C11_OVERRIDE;
117  services::Status finalizeCompute() DAAL_C11_OVERRIDE;
118 };
119 
139 template<ComputeStep step, typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = normEqDense>
140 class DAAL_EXPORT Distributed : public Training<distributed> {};
141 
161 template<typename algorithmFPType, Method method>
162 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> : public Online<algorithmFPType, method>
163 {
164 public:
166  Distributed<step1Local, algorithmFPType, method>()
167  {}
168 
175  Distributed(const Distributed<step1Local, algorithmFPType, method> &other) :
176  Online<algorithmFPType, method>(other)
177  {}
178 
185  services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone() const
186  {
187  return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
188  }
189 
190 protected:
191  virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
192  {
193  return new Distributed<step1Local, algorithmFPType, method>(*this);
194  }
195 };
196 
214 template<typename algorithmFPType, Method method>
215 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> : public Training<distributed>
216 {
217 public:
219  Distributed()
220  {
221  initialize();
222  }
223 
230  Distributed(const Distributed<step2Master, algorithmFPType, method> &other)
231  {
232  initialize();
233  input.set(partialModels, other.input.get(partialModels));
234  parameter = other.parameter;
235  }
236 
237  ~Distributed() {}
238 
243  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
244 
251  services::Status setPartialResult(const PartialResultPtr& partialResult)
252  {
253  DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
254  _partialResult = partialResult;
255  _pres = _partialResult.get();
256  return services::Status();
257  }
258 
263  PartialResultPtr getPartialResult() { return _partialResult; }
264 
271  services::Status setResult(const ResultPtr& res)
272  {
273  DAAL_CHECK(res, services::ErrorNullResult)
274  _result = res;
275  _res = _result.get();
276  return services::Status();
277  }
278 
285  ResultPtr getResult() { return _result; }
286 
293  services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone() const
294  {
295  return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
296  }
297 
298  DistributedInput<step2Master> input;
299  Parameter parameter;
301 protected:
302  PartialResultPtr _partialResult;
303  ResultPtr _result;
304 
305  virtual Distributed<step2Master, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
306  {
307  return new Distributed<step2Master, algorithmFPType, method>(*this);
308  }
309 
310  services::Status allocateResult() DAAL_C11_OVERRIDE
311  {
312  services::Status s = _result->allocate<algorithmFPType>(_pres, &parameter, method);
313  _res = _result.get();
314  return s;
315  }
316 
317  services::Status allocatePartialResult() DAAL_C11_OVERRIDE
318  {
319  services::Status s = _partialResult->allocate<algorithmFPType>(&input, &parameter, method);
320  _pres = _partialResult.get();
321  return s;
322  }
323 
324  services::Status initializePartialResult() DAAL_C11_OVERRIDE
325  {
326  return services::Status();
327  }
328 
329  void initialize()
330  {
331  _ac = new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
332  _in = &input;
333  _par = &parameter;
334  _partialResult.reset(new PartialResult());
335  _result.reset(new Result());
336  }
337 
338 }; // class : public Training
340 } // namespace interface1
341 using interface1::DistributedContainer;
342 using interface1::Distributed;
343 
344 }
345 }
346 }
347 }
348 #endif
daal::algorithms::linear_regression::training::interface1::Distributed< step1Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step1Local, algorithmFPType, method > > clone() const
Definition: linear_regression_training_distributed.h:185
daal
Definition: algorithm_base_common.h:57
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: linear_regression_training_distributed.h:230
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, method > > clone() const
Definition: linear_regression_training_distributed.h:293
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::parameter
Parameter parameter
Definition: linear_regression_training_distributed.h:299
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:131
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed()
Definition: linear_regression_training_distributed.h:219
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::getPartialResult
PartialResultPtr getPartialResult()
Definition: linear_regression_training_distributed.h:263
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::setResult
services::Status setResult(const ResultPtr &res)
Definition: linear_regression_training_distributed.h:271
daal_defines.h
daal::algorithms::linear_regression::training::interface1::DistributedInput< step2Master >
Input object for linear regression model-based training in the second step of the distributed process...
Definition: linear_regression_training_types.h:307
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::linear_regression::training::partialModels
Definition: linear_regression_training_types.h:105
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: linear_regression_training_distributed.h:285
daal::algorithms::linear_regression::training::interface1::Distributed
Provides methods for linear regression model-based training in the distributed processing mode...
Definition: linear_regression_training_distributed.h:140
daal::algorithms::linear_regression::training::interface1::DistributedContainer
Class containing methods for linear regression model-based training in the distributed processing mod...
Definition: linear_regression_training_distributed.h:82
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const PartialResultPtr &partialResult)
Definition: linear_regression_training_distributed.h:251
daal::algorithms::linear_regression::training::interface1::DistributedInput< step2Master >::get
data_management::DataCollectionPtr get(Step2MasterInputId id) const
daal::algorithms::linear_regression::training::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: linear_regression_training_distributed.h:175
daal::algorithms::linear_regression::training::interface1::Distributed< step1Local, algorithmFPType, method >
Performs linear regression model-based training in the the first step of the distributed processing m...
Definition: linear_regression_training_distributed.h:162
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::input
DistributedInput< step2Master > input
Definition: linear_regression_training_distributed.h:298
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >
Performs linear regression model-based training in the the second step of distributed processing mode...
Definition: linear_regression_training_distributed.h:215
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::linear_regression::training::interface1::Online
Provides methods for linear regression model-based training in the online processing mode...
Definition: linear_regression_training_online.h:125
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
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: linear_regression_training_distributed.h:243

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