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

logistic_loss_batch.h
1 /* file: logistic_loss_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 Logistic loss objective function in the batch
21 // processing mode
22 //--
23 */
24 
25 #ifndef __LOGISTIC_LOSS_BATCH_H__
26 #define __LOGISTIC_LOSS_BATCH_H__
27 
28 #include "algorithms/algorithm.h"
29 #include "data_management/data/numeric_table.h"
30 #include "services/daal_defines.h"
31 #include "sum_of_functions_batch.h"
32 #include "logistic_loss_types.h"
33 
34 namespace daal
35 {
36 namespace algorithms
37 {
38 namespace optimization_solver
39 {
40 namespace logistic_loss
41 {
42 
43 namespace interface1
44 {
59 template<typename algorithmFPType, Method method, CpuType cpu>
60 class BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
61 {
62 public:
68  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
70  DAAL_DEPRECATED_VIRTUAL virtual ~BatchContainer();
76  DAAL_DEPRECATED_VIRTUAL virtual services::Status compute() DAAL_C11_OVERRIDE;
77 };
78 
95 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
96 class DAAL_EXPORT Batch : public sum_of_functions::interface1::Batch
97 {
98 public:
99  typedef sum_of_functions::interface1::Batch super;
100  typedef algorithms::optimization_solver::logistic_loss::interface1::Input InputType;
101  typedef algorithms::optimization_solver::logistic_loss::interface1::Parameter ParameterType;
102  typedef typename super::ResultType ResultType;
103 
107  DAAL_DEPRECATED Batch(size_t numberOfTerms) : sum_of_functions::interface1::Batch(numberOfTerms, &input, new ParameterType(numberOfTerms))
108  {
109  initialize();
110  }
111 
112  DAAL_DEPRECATED_VIRTUAL virtual ~Batch() {}
113 
120  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> &other) :
121  sum_of_functions::interface1::Batch(other.parameter().numberOfTerms, &input, new ParameterType(other.parameter())), input(other.input)
122  {
123  initialize();
124  }
125 
130  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
131 
137  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
138  {
139  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
140  }
141 
147  DAAL_DEPRECATED services::Status allocate()
148  {
149  return allocateResult();
150  }
151 
156  DAAL_DEPRECATED ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
157 
162  DAAL_DEPRECATED const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
163 
169  DAAL_DEPRECATED static services::SharedPtr<Batch<algorithmFPType, method> > create(size_t numberOfTerms);
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 = _result->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  _par = sumOfFunctionsParameter;
189  }
190 
191 public:
192  InputType input;
193 };
195 } // namespace interface1
196 
197 namespace interface2
198 {
213 template<typename algorithmFPType, Method method, CpuType cpu>
214 class BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
215 {
216 public:
222  BatchContainer(daal::services::Environment::env *daalEnv);
224  virtual ~BatchContainer();
230  virtual services::Status compute() DAAL_C11_OVERRIDE;
231 };
232 
249 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
250 class DAAL_EXPORT Batch : public sum_of_functions::Batch
251 {
252 public:
253  typedef sum_of_functions::Batch super;
254  typedef algorithms::optimization_solver::logistic_loss::Input InputType;
255  typedef algorithms::optimization_solver::logistic_loss::Parameter ParameterType;
256  typedef typename super::ResultType ResultType;
257 
261  Batch(size_t numberOfTerms);
262 
263  virtual ~Batch() {}
264 
271  Batch(const Batch<algorithmFPType, method> &other);
272 
277  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
278 
284  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
285  {
286  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
287  }
288 
294  services::Status allocate()
295  {
296  return allocateResult();
297  }
298 
303  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
304 
309  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
310 
316  static services::SharedPtr<Batch<algorithmFPType, method> > create(size_t numberOfTerms);
317 
318 protected:
319  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
320  {
321  return new Batch<algorithmFPType, method>(*this);
322  }
323 
324  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
325  {
326  services::Status s = _result->allocate<algorithmFPType>(&input, _par, (int) method);
327  _res = _result.get();
328  return s;
329  }
330 
331  void initialize()
332  {
333  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
334  _in = &input;
335  _par = sumOfFunctionsParameter;
336  }
337 
338 public:
339  InputType input;
340 };
342 } // namespace interface2
343 
344 using interface2::BatchContainer;
345 using interface2::Batch;
346 
347 } // namespace logistic_loss
348 } // namespace optimization_solver
349 } // namespace algorithm
350 } // namespace daal
351 #endif
daal::algorithms::optimization_solver::logistic_loss::interface1::Batch::parameter
DAAL_DEPRECATED ParameterType & parameter()
Definition: logistic_loss_batch.h:156
daal::batch
Definition: daal_defines.h:112
daal::algorithms::optimization_solver::logistic_loss::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: logistic_loss_batch.h:284
daal::algorithms::optimization_solver::logistic_loss::interface1::Parameter
Parameter for Logistic loss objective function
Definition: logistic_loss_types.h:87
daal::algorithms::optimization_solver::logistic_loss::interface2::BatchContainer::compute
virtual services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::optimization_solver::logistic_loss::interface2::Batch::parameter
ParameterType & parameter()
Definition: logistic_loss_batch.h:303
daal::algorithms::optimization_solver::logistic_loss::interface1::Batch::allocate
DAAL_DEPRECATED services::Status allocate()
Definition: logistic_loss_batch.h:147
daal::algorithms::optimization_solver::logistic_loss::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
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:63
daal::algorithms::optimization_solver::logistic_loss::interface1::BatchContainer::~BatchContainer
virtual DAAL_DEPRECATED_VIRTUAL ~BatchContainer()
daal::algorithms::optimization_solver::logistic_loss::interface2::Batch
Computes the Logistic loss objective function in the batch processing mode.
Definition: logistic_loss_batch.h:250
daal::algorithms::optimization_solver::logistic_loss::interface1::Input
Input objects for the Logistic loss objective function
Definition: logistic_loss_types.h:126
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::logistic_loss::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: logistic_loss_batch.h:277
daal::algorithms::optimization_solver::logistic_loss::interface1::Batch::Batch
DAAL_DEPRECATED Batch(size_t numberOfTerms)
Definition: logistic_loss_batch.h:107
daal::algorithms::optimization_solver::logistic_loss::interface2::BatchContainer::~BatchContainer
virtual ~BatchContainer()
daal_defines.h
daal::algorithms::optimization_solver::logistic_loss::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: logistic_loss_batch.h:130
daal::algorithms::optimization_solver::logistic_loss::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const Batch< algorithmFPType, method > &other)
Definition: logistic_loss_batch.h:120
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:214
daal::algorithms::optimization_solver::logistic_loss::interface2::Batch::allocate
services::Status allocate()
Definition: logistic_loss_batch.h:294
daal::algorithms::optimization_solver::logistic_loss::interface2::Batch::input
InputType input
Definition: logistic_loss_batch.h:339
daal::algorithms::optimization_solver::logistic_loss::interface1::Batch::input
InputType input
Definition: logistic_loss_batch.h:192
daal::algorithms::optimization_solver::logistic_loss::interface1::Batch
Computes the Logistic loss objective function in the batch processing mode.
Definition: logistic_loss_batch.h:96
daal::algorithms::optimization_solver::logistic_loss::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
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:60
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::logistic_loss::interface2::Batch::parameter
const ParameterType & parameter() const
Definition: logistic_loss_batch.h:309
daal::algorithms::optimization_solver::logistic_loss::interface1::BatchContainer::compute
virtual DAAL_DEPRECATED_VIRTUAL services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::optimization_solver::logistic_loss::interface1::Batch::parameter
DAAL_DEPRECATED const ParameterType & parameter() const
Definition: logistic_loss_batch.h:162
daal::algorithms::optimization_solver::logistic_loss::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: logistic_loss_batch.h:137

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