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

implicit_als_training_batch.h
1 /* file: implicit_als_training_batch.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 implicit ALS model-based training in the
45 // batch processing mode
46 //--
47 */
48 
49 #ifndef __IMPLICIT_ALS_TRAINING_BATCH_H__
50 #define __IMPLICIT_ALS_TRAINING_BATCH_H__
51 
52 #include "algorithms/algorithm.h"
53 #include "algorithms/implicit_als/implicit_als_training_types.h"
54 
55 namespace daal
56 {
57 namespace algorithms
58 {
59 namespace implicit_als
60 {
61 namespace training
62 {
63 
64 namespace interface1
65 {
75 template<typename algorithmFPType, Method method, CpuType cpu>
76 class DAAL_EXPORT BatchContainer : public TrainingContainerIface<batch>
77 {
78 public:
84  BatchContainer(daal::services::Environment::env *daalEnv);
86  ~BatchContainer();
90  services::Status compute() DAAL_C11_OVERRIDE;
91 };
92 
105 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
106 class DAAL_EXPORT Batch : public daal::algorithms::Training<batch>
107 {
108 public:
109  Input input;
110  Parameter parameter;
113  Batch()
114  {
115  initialize();
116  }
117 
124  Batch(const Batch<algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
125  {
126  initialize();
127  }
128 
133  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
134 
139  ResultPtr getResult()
140  {
141  return _result;
142  }
143 
148  services::Status setResult(const ResultPtr& res)
149  {
150  DAAL_CHECK(res, services::ErrorNullResult)
151  _result = res;
152  _res = _result.get();
153  return services::Status();
154  }
155 
161  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
162  {
163  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
164  }
165 
166 protected:
167  training::ResultPtr _result;
168 
169  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
170  {
171  return new Batch<algorithmFPType, method>(*this);
172  }
173 
174  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
175  {
176  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int) method);
177  _res = _result.get();
178  return s;
179  }
180 
181  void initialize()
182  {
183  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
184  _in = &input;
185  _par = &parameter;
186  _result = training::ResultPtr(new Result());
187  }
188 };
190 } // namespace interface1
191 using interface1::BatchContainer;
192 using interface1::Batch;
193 
194 }
195 }
196 }
197 }
198 
199 #endif
daal
Definition: algorithm_base_common.h:57
daal::algorithms::implicit_als::training::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: implicit_als_training_batch.h:124
daal::algorithms::implicit_als::training::interface1::BatchContainer
Provides methods to run implementations of implicit ALS model-based training.
Definition: implicit_als_training_batch.h:76
daal::algorithms::implicit_als::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: implicit_als_training_batch.h:161
daal::algorithms::implicit_als::training::interface1::Batch::Batch
Batch()
Definition: implicit_als_training_batch.h:113
daal::algorithms::implicit_als::training::interface1::Batch::getResult
ResultPtr getResult()
Definition: implicit_als_training_batch.h:139
daal::algorithms::implicit_als::training::interface1::Batch::input
Input input
Definition: implicit_als_training_batch.h:109
daal::batch
Definition: daal_defines.h:131
daal::algorithms::implicit_als::training::interface1::Batch::setResult
services::Status setResult(const ResultPtr &res)
Definition: implicit_als_training_batch.h:148
daal::algorithms::implicit_als::training::interface1::Batch
Algorithm class for training the implicit ALS model.
Definition: implicit_als_training_batch.h:106
daal::algorithms::implicit_als::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: implicit_als_training_batch.h:133
daal::algorithms::implicit_als::training::interface1::Batch::parameter
Parameter parameter
Definition: implicit_als_training_batch.h:110
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::implicit_als::training::interface1::Input
Input objects for the implicit ALS training algorithm
Definition: implicit_als_training_types.h:252
daal::algorithms::Training
Provides methods to train models that depend on the data provided. For example, these methods enable ...
Definition: training.h:86

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