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

saga_batch.h
1 /* file: saga_batch.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 the Stochastic average gradient descent (SAGA) algorithm
19 // in the batch processing mode
20 //--
21 */
22 
23 #ifndef __SAGA_BATCH_H__
24 #define __SAGA_BATCH_H__
25 
26 #include "data_management/data/numeric_table.h"
27 #include "services/daal_defines.h"
28 #include "algorithms/optimization_solver/iterative_solver/iterative_solver_batch.h"
29 #include "saga_types.h"
30 
31 namespace daal
32 {
33 namespace algorithms
34 {
35 namespace optimization_solver
36 {
37 namespace saga
38 {
39 namespace interface1
40 {
54 template<typename algorithmFPType, Method method, CpuType cpu>
55 class DAAL_EXPORT BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
56 {
57 public:
63  BatchContainer(daal::services::Environment::env *daalEnv);
65  ~BatchContainer();
71  virtual services::Status compute() DAAL_C11_OVERRIDE;
72 };
73 
88 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
89 class DAAL_EXPORT Batch : public iterative_solver::Batch
90 {
91 public:
92  typedef algorithms::optimization_solver::saga::Input InputType;
93  typedef algorithms::optimization_solver::saga::Parameter ParameterType;
94  typedef algorithms::optimization_solver::saga::Result ResultType;
95 
96  InputType input;
99  Batch(const sum_of_functions::BatchPtr& objectiveFunction = sum_of_functions::BatchPtr());
100 
107  Batch(const Batch<algorithmFPType, method> &other);
108 
109  ~Batch()
110  {
111  delete _par;
112  }
117  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
118 
123  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
124 
129  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
130 
135  virtual iterative_solver::Input * getInput() DAAL_C11_OVERRIDE { return &input; }
136 
141  virtual iterative_solver::Parameter * getParameter() DAAL_C11_OVERRIDE { return &parameter(); }
142 
148  virtual services::Status createResult() DAAL_C11_OVERRIDE
149  {
150  _result = iterative_solver::ResultPtr(new ResultType());
151  _res = NULL;
152  return services::Status();
153  }
154 
160  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
161  {
162  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
163  }
164 
169  static services::SharedPtr<Batch<algorithmFPType, method> > create();
170 
171 protected:
172  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
173  {
174  return new Batch<algorithmFPType, method>(*this);
175  }
176 
177  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
178  {
179  services::Status s = static_cast<ResultType*>(_result.get())->allocate<algorithmFPType>(&input, _par, (int)method);
180  _res = _result.get();
181  return s;
182  }
183 
184  void initialize()
185  {
186  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
187  _in = &input;
188  _result.reset(new ResultType());
189  }
190 };
192 } // namespace interface1
193 using interface1::BatchContainer;
194 using interface1::Batch;
195 
196 } // namespace saga
197 } // namespace optimization_solver
198 } // namespace algorithm
199 } // namespace daal
200 #endif
daal::algorithms::optimization_solver::saga::interface1::Batch::parameter
const ParameterType & parameter() const
Definition: saga_batch.h:123
daal
Definition: algorithm_base_common.h:31
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:53
daal::algorithms::optimization_solver::saga::interface1::Batch::parameter
ParameterType & parameter()
Definition: saga_batch.h:117
daal::algorithms::optimization_solver::saga::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: saga_batch.h:160
daal::algorithms::optimization_solver::saga::interface1::Batch::getParameter
virtual iterative_solver::Parameter * getParameter() DAAL_C11_OVERRIDE
Definition: saga_batch.h:141
daal_defines.h
daal::batch
Definition: daal_defines.h:110
daal::algorithms::optimization_solver::saga::interface1::Batch::input
InputType input
Definition: saga_batch.h:96
daal::algorithms::optimization_solver::saga::interface1::Batch
Computes Stochastic average gradient descent in the batch processing mode.
Definition: saga_batch.h:89
daal::algorithms::optimization_solver::saga::interface1::Batch::getInput
virtual iterative_solver::Input * getInput() DAAL_C11_OVERRIDE
Definition: saga_batch.h:135
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::optimization_solver::saga::interface1::BatchContainer
Provides methods to run implementations of the stochastic average gradient descent algorithm...
Definition: saga_batch.h:55
daal::algorithms::optimization_solver::iterative_solver::interface1::Batch
Interface for computing the iterative solver in the batch processing mode.
Definition: iterative_solver_batch.h:52
daal::algorithms::optimization_solver::saga::interface1::Batch::createResult
virtual services::Status createResult() DAAL_C11_OVERRIDE
Definition: saga_batch.h:148
daal::algorithms::optimization_solver::saga::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: saga_batch.h:129
daal::algorithms::kmeans::objectiveFunction
Definition: kmeans_types.h:109

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