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

logistic_loss_batch.h
1 /* file: logistic_loss_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 Logistic loss objective function in the batch
19 // processing mode
20 //--
21 */
22 
23 #ifndef __LOGISTIC_LOSS_BATCH_H__
24 #define __LOGISTIC_LOSS_BATCH_H__
25 
26 #include "algorithms/algorithm.h"
27 #include "data_management/data/numeric_table.h"
28 #include "services/daal_defines.h"
29 #include "sum_of_functions_batch.h"
30 #include "logistic_loss_types.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace optimization_solver
37 {
38 namespace logistic_loss
39 {
40 
41 namespace interface1
42 {
57 template<typename algorithmFPType, Method method, CpuType cpu>
58 class DAAL_EXPORT BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
59 {
60 public:
66  BatchContainer(daal::services::Environment::env *daalEnv);
68  virtual ~BatchContainer();
74  virtual services::Status compute() DAAL_C11_OVERRIDE;
75 };
76 
93 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
94 class DAAL_EXPORT Batch : public sum_of_functions::interface1::Batch
95 {
96 public:
97  typedef sum_of_functions::interface1::Batch super;
98  typedef algorithms::optimization_solver::logistic_loss::interface1::Input InputType;
99  typedef algorithms::optimization_solver::logistic_loss::interface1::Parameter ParameterType;
100  typedef typename super::ResultType ResultType;
101 
105  Batch(size_t numberOfTerms) : sum_of_functions::interface1::Batch(numberOfTerms, &input, new ParameterType(numberOfTerms))
106  {
107  initialize();
108  }
109 
110  virtual ~Batch() {}
111 
118  Batch(const Batch<algorithmFPType, method> &other) :
119  sum_of_functions::interface1::Batch(other.parameter().numberOfTerms, &input, new ParameterType(other.parameter())), input(other.input)
120  {
121  initialize();
122  }
123 
128  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
129 
135  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
136  {
137  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
138  }
139 
145  services::Status allocate()
146  {
147  return allocateResult();
148  }
149 
154  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
155 
160  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
161 
167  static services::SharedPtr<Batch<algorithmFPType, method> > create(size_t numberOfTerms);
168 
169 protected:
170  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
171  {
172  return new Batch<algorithmFPType, method>(*this);
173  }
174 
175  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
176  {
177  services::Status s = _result->allocate<algorithmFPType>(&input, _par, (int) method);
178  _res = _result.get();
179  return s;
180  }
181 
182  void initialize()
183  {
184  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
185  _in = &input;
186  _par = sumOfFunctionsParameter;
187  }
188 
189 public:
190  InputType input;
191 };
193 } // namespace interface1
194 
195 namespace interface2
196 {
211 template<typename algorithmFPType, Method method, CpuType cpu>
212 class DAAL_EXPORT BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
213 {
214 public:
220  BatchContainer(daal::services::Environment::env *daalEnv);
222  virtual ~BatchContainer();
228  virtual services::Status compute() DAAL_C11_OVERRIDE;
229 };
230 
247 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
248 class DAAL_EXPORT Batch : public sum_of_functions::Batch
249 {
250 public:
251  typedef sum_of_functions::Batch super;
252  typedef algorithms::optimization_solver::logistic_loss::Input InputType;
253  typedef algorithms::optimization_solver::logistic_loss::Parameter ParameterType;
254  typedef typename super::ResultType ResultType;
255 
259  Batch(size_t numberOfTerms);
260 
261  virtual ~Batch() {}
262 
269  Batch(const Batch<algorithmFPType, method> &other);
270 
275  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
276 
282  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
283  {
284  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
285  }
286 
292  services::Status allocate()
293  {
294  return allocateResult();
295  }
296 
301  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
302 
307  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
308 
314  static services::SharedPtr<Batch<algorithmFPType, method> > create(size_t numberOfTerms);
315 
316 protected:
317  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
318  {
319  return new Batch<algorithmFPType, method>(*this);
320  }
321 
322  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
323  {
324  services::Status s = _result->allocate<algorithmFPType>(&input, _par, (int) method);
325  _res = _result.get();
326  return s;
327  }
328 
329  void initialize()
330  {
331  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
332  _in = &input;
333  _par = sumOfFunctionsParameter;
334  }
335 
336 public:
337  InputType input;
338 };
340 } // namespace interface2
341 
342 using interface2::BatchContainer;
343 using interface2::Batch;
344 
345 } // namespace logistic_loss
346 } // namespace optimization_solver
347 } // namespace algorithm
348 } // namespace daal
349 #endif
daal::algorithms::optimization_solver::logistic_loss::interface1::Batch::parameter
const ParameterType & parameter() const
Definition: logistic_loss_batch.h:160
daal::algorithms::optimization_solver::logistic_loss::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: logistic_loss_batch.h:275
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::logistic_loss::interface1::Batch::Batch
Batch(size_t numberOfTerms)
Definition: logistic_loss_batch.h:105
daal::algorithms::optimization_solver::logistic_loss::interface2::Batch
Computes the Logistic loss objective function in the batch processing mode.
Definition: logistic_loss_batch.h:248
daal::algorithms::optimization_solver::logistic_loss::interface1::Batch
Computes the Logistic loss objective function in the batch processing mode.
Definition: logistic_loss_batch.h:94
daal::algorithms::optimization_solver::logistic_loss::interface1::BatchContainer
Provides methods to run implementations of the Logistic loss objective function. This class is associ...
Definition: logistic_loss_batch.h:58
daal_defines.h
daal::algorithms::optimization_solver::sum_of_functions::interface1::Batch
Interface for computing the Sum of functions in the batch processing mode.
Definition: sum_of_functions_batch.h:61
daal::algorithms::optimization_solver::logistic_loss::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: logistic_loss_batch.h:118
daal::batch
Definition: daal_defines.h:110
daal::algorithms::optimization_solver::logistic_loss::interface2::Batch::parameter
ParameterType & parameter()
Definition: logistic_loss_batch.h:301
daal::algorithms::optimization_solver::logistic_loss::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: logistic_loss_batch.h:135
daal::algorithms::optimization_solver::logistic_loss::interface1::Batch::allocate
services::Status allocate()
Definition: logistic_loss_batch.h:145
daal::algorithms::optimization_solver::logistic_loss::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: logistic_loss_batch.h:282
daal::algorithms::optimization_solver::logistic_loss::interface2::Batch::allocate
services::Status allocate()
Definition: logistic_loss_batch.h:292
daal::algorithms::optimization_solver::logistic_loss::interface2::BatchContainer
Provides methods to run implementations of the Logistic loss objective function. This class is associ...
Definition: logistic_loss_batch.h:212
daal::algorithms::optimization_solver::logistic_loss::interface2::Batch::parameter
const ParameterType & parameter() const
Definition: logistic_loss_batch.h:307
daal::algorithms::optimization_solver::logistic_loss::interface1::Input
Input objects for the Logistic loss objective function
Definition: logistic_loss_types.h:124
daal::algorithms::optimization_solver::logistic_loss::interface2::Batch::input
InputType input
Definition: logistic_loss_batch.h:337
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::logistic_loss::interface1::Batch::input
InputType input
Definition: logistic_loss_batch.h:190
daal::algorithms::optimization_solver::logistic_loss::interface1::Batch::parameter
ParameterType & parameter()
Definition: logistic_loss_batch.h:154
daal::algorithms::optimization_solver::logistic_loss::interface1::Parameter
Parameter for Logistic loss objective function
Definition: logistic_loss_types.h:85
daal::algorithms::optimization_solver::logistic_loss::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: logistic_loss_batch.h:128

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