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

saga_batch.h
1 /* file: saga_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2020 Intel Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *******************************************************************************/
17 
18 /*
19 //++
20 // Implementation of the interface for the Stochastic average gradient descent (SAGA) algorithm
21 // in the batch processing mode
22 //--
23 */
24 
25 #ifndef __SAGA_BATCH_H__
26 #define __SAGA_BATCH_H__
27 
28 #include "data_management/data/numeric_table.h"
29 #include "services/daal_defines.h"
30 #include "algorithms/optimization_solver/iterative_solver/iterative_solver_batch.h"
31 #include "saga_types.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
37 namespace optimization_solver
38 {
39 namespace saga
40 {
41 namespace interface1
42 {
56 template<typename algorithmFPType, Method method, CpuType cpu>
57 class BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
58 {
59 public:
65  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
67  DAAL_DEPRECATED ~BatchContainer();
73  DAAL_DEPRECATED_VIRTUAL virtual services::Status compute() DAAL_C11_OVERRIDE;
74 };
75 
90 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
91 class DAAL_EXPORT Batch : public iterative_solver::interface1::Batch
92 {
93 public:
94  typedef algorithms::optimization_solver::saga::interface1::Input InputType;
95  typedef algorithms::optimization_solver::saga::interface1::Parameter ParameterType;
96  typedef algorithms::optimization_solver::saga::interface1::Result ResultType;
97 
98  InputType input;
101  DAAL_DEPRECATED Batch(const sum_of_functions::interface1::BatchPtr& objectiveFunction = sum_of_functions::interface1::BatchPtr());
102 
109  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> &other);
110 
111  DAAL_DEPRECATED ~Batch()
112  {
113  delete _par;
114  }
119  DAAL_DEPRECATED ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
120 
125  DAAL_DEPRECATED const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
126 
131  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
132 
137  DAAL_DEPRECATED_VIRTUAL virtual iterative_solver::interface1::Input * getInput() DAAL_C11_OVERRIDE { return &input; }
138 
143  DAAL_DEPRECATED_VIRTUAL virtual iterative_solver::interface1::Parameter * getParameter() DAAL_C11_OVERRIDE { return &parameter(); }
144 
150  DAAL_DEPRECATED_VIRTUAL virtual services::Status createResult() DAAL_C11_OVERRIDE
151  {
152  _result = iterative_solver::interface1::ResultPtr(new ResultType());
153  _res = NULL;
154  return services::Status();
155  }
156 
162  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
163  {
164  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
165  }
166 
171  DAAL_DEPRECATED static services::SharedPtr<Batch<algorithmFPType, method> > create();
172 
173 protected:
174  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
175  {
176  return new Batch<algorithmFPType, method>(*this);
177  }
178 
179  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
180  {
181  services::Status s = static_cast<ResultType*>(_result.get())->allocate<algorithmFPType>(&input, _par, (int)method);
182  _res = _result.get();
183  return s;
184  }
185 
186  void initialize()
187  {
188  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
189  _in = &input;
190  _result.reset(new ResultType());
191  }
192 };
194 } // namespace interface1
195 
196 namespace interface2
197 {
211 template<typename algorithmFPType, Method method, CpuType cpu>
212 class BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
213 {
214 public:
220  BatchContainer(daal::services::Environment::env *daalEnv);
222  ~BatchContainer();
228  virtual services::Status compute() DAAL_C11_OVERRIDE;
229 };
230 
245 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
246 class DAAL_EXPORT Batch : public iterative_solver::Batch
247 {
248 public:
249  typedef algorithms::optimization_solver::saga::Input InputType;
250  typedef algorithms::optimization_solver::saga::Parameter ParameterType;
251  typedef algorithms::optimization_solver::saga::Result ResultType;
252 
253  InputType input;
256  Batch(const sum_of_functions::BatchPtr& objectiveFunction = sum_of_functions::BatchPtr());
257 
264  Batch(const Batch<algorithmFPType, method> &other);
265 
266  ~Batch()
267  {
268  delete _par;
269  }
274  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
275 
280  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
281 
286  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
287 
292  virtual iterative_solver::Input * getInput() DAAL_C11_OVERRIDE { return &input; }
293 
298  virtual iterative_solver::Parameter * getParameter() DAAL_C11_OVERRIDE { return &parameter(); }
299 
305  virtual services::Status createResult() DAAL_C11_OVERRIDE
306  {
307  _result = iterative_solver::ResultPtr(new ResultType());
308  _res = NULL;
309  return services::Status();
310  }
311 
317  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
318  {
319  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
320  }
321 
326  static services::SharedPtr<Batch<algorithmFPType, method> > create();
327 
328 protected:
329  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
330  {
331  return new Batch<algorithmFPType, method>(*this);
332  }
333 
334  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
335  {
336  services::Status s = static_cast<ResultType*>(_result.get())->allocate<algorithmFPType>(&input, _par, (int)method);
337  _res = _result.get();
338  return s;
339  }
340 
341  void initialize()
342  {
343  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
344  _in = &input;
345  _result.reset(new ResultType());
346  }
347 };
349 } // namespace interface2
350 using interface2::BatchContainer;
351 using interface2::Batch;
352 
353 } // namespace saga
354 } // namespace optimization_solver
355 } // namespace algorithm
356 } // namespace daal
357 #endif
daal::algorithms::optimization_solver::saga::interface2::Batch::parameter
const ParameterType & parameter() const
Definition: saga_batch.h:280
daal::algorithms::optimization_solver::saga::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: saga_batch.h:286
daal::algorithms::optimization_solver::saga::interface2::Batch::parameter
ParameterType & parameter()
Definition: saga_batch.h:274
daal::batch
Definition: daal_defines.h:112
daal::algorithms::optimization_solver::saga::interface2::Batch::getInput
virtual iterative_solver::Input * getInput() DAAL_C11_OVERRIDE
Definition: saga_batch.h:292
daal::algorithms::optimization_solver::saga::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: saga_batch.h:131
daal::algorithms::optimization_solver::saga::interface1::Input
Input class for the Stochastic average gradient descent algorithm
Definition: saga_types.h:138
daal::algorithms::optimization_solver::saga::interface1::Batch::parameter
DAAL_DEPRECATED const ParameterType & parameter() const
Definition: saga_batch.h:125
daal::algorithms::optimization_solver::iterative_solver::interface1::Batch
Interface for computing the iterative solver in the batch processing mode.
Definition: iterative_solver_batch.h:54
daal::algorithms::optimization_solver::saga::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::optimization_solver::saga::interface1::Batch::createResult
virtual DAAL_DEPRECATED_VIRTUAL services::Status createResult() DAAL_C11_OVERRIDE
Definition: saga_batch.h:150
daal::algorithms::optimization_solver::saga::interface2::Batch
Computes Stochastic average gradient descent in the batch processing mode.
Definition: saga_batch.h:246
daal::algorithms::optimization_solver::saga::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: saga_batch.h:162
daal::algorithms::optimization_solver::saga::interface2::BatchContainer::compute
virtual services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::optimization_solver::saga::interface1::BatchContainer
Provides methods to run implementations of the stochastic average gradient descent algorithm...
Definition: saga_batch.h:57
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:55
daal::algorithms::optimization_solver::saga::interface1::Batch::input
InputType input
Definition: saga_batch.h:98
daal_defines.h
daal::algorithms::optimization_solver::saga::interface2::Batch::input
InputType input
Definition: saga_batch.h:253
daal::algorithms::optimization_solver::saga::interface1::Result
Results obtained with the compute() method of the saga algorithm in the batch processing mode...
Definition: saga_types.h:178
daal::algorithms::optimization_solver::saga::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: saga_batch.h:317
daal::algorithms::optimization_solver::saga::interface1::BatchContainer::compute
virtual DAAL_DEPRECATED_VIRTUAL services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::optimization_solver::saga::interface1::Batch
Computes Stochastic average gradient descent in the batch processing mode.
Definition: saga_batch.h:91
daal::algorithms::optimization_solver::saga::interface1::Batch::getInput
virtual DAAL_DEPRECATED_VIRTUAL iterative_solver::interface1::Input * getInput() DAAL_C11_OVERRIDE
Definition: saga_batch.h:137
daal::algorithms::optimization_solver::iterative_solver::interface1::Input
Input parameters for the iterative solver algorithm
Definition: iterative_solver_types.h:160
daal::algorithms::optimization_solver::saga::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::algorithms::optimization_solver::saga::interface1::Batch::parameter
DAAL_DEPRECATED ParameterType & parameter()
Definition: saga_batch.h:119
daal::algorithms::optimization_solver::saga::interface1::Batch::getParameter
virtual DAAL_DEPRECATED_VIRTUAL iterative_solver::interface1::Parameter * getParameter() DAAL_C11_OVERRIDE
Definition: saga_batch.h:143
daal::algorithms::optimization_solver::saga::interface2::Batch::getParameter
virtual iterative_solver::Parameter * getParameter() DAAL_C11_OVERRIDE
Definition: saga_batch.h:298
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70
daal::algorithms::optimization_solver::saga::interface2::Batch::createResult
virtual services::Status createResult() DAAL_C11_OVERRIDE
Definition: saga_batch.h:305
daal::algorithms::optimization_solver::saga::interface2::BatchContainer
Provides methods to run implementations of the stochastic average gradient descent algorithm...
Definition: saga_batch.h:212
daal::algorithms::optimization_solver::iterative_solver::interface1::Result
Results obtained with the compute() method of the iterative solver algorithm in the batch processing ...
Definition: iterative_solver_types.h:223
daal::algorithms::optimization_solver::iterative_solver::interface1::Parameter
Parameter base class for the iterative solver algorithm
Definition: iterative_solver_types.h:115
daal::algorithms::optimization_solver::saga::interface2::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::optimization_solver::saga::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::optimization_solver::saga::interface1::Parameter
Parameter base class for the Stochastic average gradient descent algorithm
Definition: saga_types.h:86

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