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

implicit_als_training_init_types.h
1 /* file: implicit_als_training_init_types.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 implicit ALS algorithm interface
45 //--
46 */
47 
48 #ifndef __IMPLICIT_ALS_TRAINING_INIT_TYPES_H__
49 #define __IMPLICIT_ALS_TRAINING_INIT_TYPES_H__
50 
51 #include "algorithms/implicit_als/implicit_als_model.h"
52 #include "algorithms/implicit_als/implicit_als_training_types.h"
53 #include "data_management/data/csr_numeric_table.h"
54 #include "algorithms/engines/mt19937/mt19937.h"
55 
56 namespace daal
57 {
58 namespace algorithms
59 {
60 namespace implicit_als
61 {
62 namespace training
63 {
73 namespace init
74 {
75 
80 enum Method
81 {
82  defaultDense = 0,
83  fastCSR = 1
84 };
85 
90 enum InputId
91 {
92  data,
93  lastInputId = data
94 };
95 
101 enum Step2LocalInputId
102 {
103  inputOfStep2FromStep1,
105  lastStep2LocalInputId = inputOfStep2FromStep1
106 };
107 
113 enum PartialResultBaseId
114 {
115  outputOfInitForComputeStep3,
117  offsets,
119  lastPartialResultBaseId = offsets
120 };
121 
127 enum PartialResultId
128 {
129  partialModel = lastPartialResultBaseId + 1,
130  lastPartialResultId = partialModel
131 };
132 
138 enum PartialResultCollectionId
139 {
140  outputOfStep1ForStep2 = lastPartialResultId + 1,
142  lastPartialResultCollectionId = outputOfStep1ForStep2
143 };
144 
150 enum DistributedPartialResultStep2Id
151 {
152  transposedData = lastPartialResultBaseId + 1,
153  lastDistributedPartialResultStep2Id = transposedData
154 };
155 
160 enum ResultId
161 {
162  model,
163  lastResultId = model
164 };
165 
169 namespace interface1
170 {
177 /* [Parameter source code] */
178 struct DAAL_EXPORT Parameter : public daal::algorithms::Parameter
179 {
186  Parameter(size_t nFactors = 10, size_t fullNUsers = 0, size_t seed = 777777);
187 
188  size_t nFactors;
189  size_t fullNUsers;
190  size_t seed;
191  engines::EnginePtr engine;
193  services::Status check() const DAAL_C11_OVERRIDE;
194 };
195 /* [Parameter source code] */
196 
203 /* [Distributed parameter source code] */
204 struct DAAL_EXPORT DistributedParameter : public Parameter
205 {
212  DistributedParameter(size_t nFactors = 10, size_t fullNUsers = 0, size_t seed = 777777);
213 
214  data_management::NumericTablePtr partition;
220  services::Status check() const DAAL_C11_OVERRIDE;
221 };
222 /* [Distributed parameter source code] */
223 
228 class DAAL_EXPORT Input : public daal::algorithms::Input
229 {
230 public:
231  Input(size_t nElements = lastInputId + 1);
232  Input(const Input& other) : daal::algorithms::Input(other){}
233 
234  virtual ~Input() {}
235 
241  data_management::NumericTablePtr get(InputId id) const;
242 
248  void set(InputId id, const data_management::NumericTablePtr &ptr);
249 
254  size_t getNumberOfItems() const;
255 
261  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
262 };
263 
268 template<ComputeStep step>
269 class DistributedInput
270 {};
271 
277 template <>
278 class DAAL_EXPORT DistributedInput<step1Local> : public Input
279 {
280 public:
282  DistributedInput();
283 
285  DistributedInput(const DistributedInput& other) : Input(other){}
286 
287  virtual ~DistributedInput() {}
288 
289  using Input::get;
290  using Input::set;
291 };
292 
298 template <>
299 class DAAL_EXPORT DistributedInput<step2Local> : public daal::algorithms::Input
300 {
301 public:
303  DistributedInput();
304 
306  DistributedInput(const DistributedInput& other) : daal::algorithms::Input(other){}
307 
308  virtual ~DistributedInput() {}
309 
315  data_management::KeyValueDataCollectionPtr get(Step2LocalInputId id) const;
316 
322  void set(Step2LocalInputId id, const data_management::KeyValueDataCollectionPtr &ptr);
323 
329  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
330 };
331 
337 class DAAL_EXPORT PartialResultBase : public daal::algorithms::PartialResult
338 {
339 public:
340  DECLARE_SERIALIZABLE_CAST(PartialResultBase);
341 
347  PartialResultBase(size_t nElements = 0);
348 
354  data_management::KeyValueDataCollectionPtr get(PartialResultBaseId id) const;
355 
362  data_management::NumericTablePtr get(PartialResultBaseId id, size_t key) const;
363 
369  void set(PartialResultBaseId id, const data_management::KeyValueDataCollectionPtr &ptr);
370 
377  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
378 
379 protected:
380  template <typename algorithmFPType>
381  DAAL_EXPORT services::Status allocate(size_t nParts);
382 
384  template<typename Archive, bool onDeserialize>
385  services::Status serialImpl(Archive *arch)
386  {
387  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
388  }
389 
390  services::Status checkImpl(size_t nParts) const;
391 };
392 
398 class DAAL_EXPORT PartialResult : public PartialResultBase
399 {
400 public:
401  DECLARE_SERIALIZABLE_CAST(PartialResult);
403  PartialResult();
404 
405  using PartialResultBase::get;
406  using PartialResultBase::set;
407 
414  template <typename algorithmFPType>
415  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
416 
422  PartialModelPtr get(PartialResultId id) const;
423 
429  void set(PartialResultId id, const PartialModelPtr &ptr);
430 
436  data_management::KeyValueDataCollectionPtr get(PartialResultCollectionId id) const;
437 
444  data_management::NumericTablePtr get(PartialResultCollectionId id, size_t key) const;
445 
451  void set(PartialResultCollectionId id, const data_management::KeyValueDataCollectionPtr &ptr);
452 
459  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
460 
461 protected:
463  template<typename Archive, bool onDeserialize>
464  services::Status serialImpl(Archive *arch)
465  {
466  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
467  }
468 };
469 
475 class DAAL_EXPORT DistributedPartialResultStep2 : public PartialResultBase
476 {
477 public:
478  DECLARE_SERIALIZABLE_CAST(DistributedPartialResultStep2);
480  DistributedPartialResultStep2();
481 
482  using PartialResultBase::get;
483  using PartialResultBase::set;
484 
491  template <typename algorithmFPType>
492  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
493 
499  data_management::NumericTablePtr get(DistributedPartialResultStep2Id id) const;
500 
506  void set(DistributedPartialResultStep2Id id, const data_management::NumericTablePtr &ptr);
507 
514  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
515 
516 protected:
518  template<typename Archive, bool onDeserialize>
519  services::Status serialImpl(Archive *arch)
520  {
521  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
522  }
523 };
524 
530 class DAAL_EXPORT Result : public daal::algorithms::implicit_als::training::Result
531 {
532 public:
533  DECLARE_SERIALIZABLE_CAST(Result);
534 
540  daal::algorithms::implicit_als::ModelPtr get(ResultId id) const;
541 
547  void set(ResultId id, const daal::algorithms::implicit_als::ModelPtr &ptr);
548 
549 protected:
551  template<typename Archive, bool onDeserialize>
552  services::Status serialImpl(Archive *arch)
553  {
554  return training::Result::serialImpl<Archive, onDeserialize>(arch);
555  }
556 };
557 typedef services::SharedPtr<Result> ResultPtr;
558 typedef services::SharedPtr<PartialResult> PartialResultPtr;
559 typedef services::SharedPtr<DistributedPartialResultStep2> DistributedPartialResultStep2Ptr;
560 
561 } // namespace interface1
562 using interface1::Parameter;
563 using interface1::DistributedParameter;
564 using interface1::Input;
565 using interface1::DistributedInput;
566 using interface1::PartialResultBase;
567 using interface1::PartialResult;
568 using interface1::PartialResultPtr;
569 using interface1::DistributedPartialResultStep2;
570 using interface1::DistributedPartialResultStep2Ptr;
571 using interface1::Result;
572 using interface1::ResultPtr;
573 
574 }
576 }
577 }
578 }
579 }
580 
581 #endif
daal::algorithms::implicit_als::training::init::interface1::DistributedInput< step1Local >::DistributedInput
DistributedInput(const DistributedInput &other)
Definition: implicit_als_training_init_types.h:285
daal::algorithms::implicit_als::training::init::Method
Method
Available methods for initializing the implicit ALS algorithm.
Definition: implicit_als_training_init_types.h:80
daal::algorithms::implicit_als::training::init::interface1::DistributedInput
Input objects for the implicit ALS initialization algorithm in the distributed processing mode ...
Definition: implicit_als_training_init_types.h:269
daal::algorithms::implicit_als::training::init::inputOfStep2FromStep1
Definition: implicit_als_training_init_types.h:103
daal::step2Local
Definition: daal_defines.h:147
daal
Definition: algorithm_base_common.h:57
daal::algorithms::implicit_als::training::init::ResultId
ResultId
Available identifiers of the results of the implicit ALS initialization algorithm.
Definition: implicit_als_training_init_types.h:160
daal::algorithms::implicit_als::training::init::model
Definition: implicit_als_training_init_types.h:162
daal::algorithms::implicit_als::training::init::transposedData
Definition: implicit_als_training_init_types.h:152
daal::algorithms::implicit_als::training::init::interface1::DistributedPartialResultStep2
Provides methods to access partial results obtained with the compute() method of the implicit ALS ini...
Definition: implicit_als_training_init_types.h:475
daal::algorithms::implicit_als::training::init::fastCSR
Definition: implicit_als_training_init_types.h:83
daal::algorithms::implicit_als::training::init::interface1::PartialResult
Provides methods to access partial results obtained with the compute() method of the implicit ALS ini...
Definition: implicit_als_training_init_types.h:398
daal::algorithms::implicit_als::training::init::interface1::Input
Input objects for the implicit ALS initialization algorithm
Definition: implicit_als_training_init_types.h:228
daal::algorithms::implicit_als::training::init::interface1::DistributedParameter::partition
data_management::NumericTablePtr partition
Definition: implicit_als_training_init_types.h:214
daal::algorithms::implicit_als::training::init::Step2LocalInputId
Step2LocalInputId
Definition: implicit_als_training_init_types.h:101
daal::algorithms::implicit_als::training::init::PartialResultBaseId
PartialResultBaseId
Available identifiers of partial results of the implicit ALS initialization algorithm in the first an...
Definition: implicit_als_training_init_types.h:113
daal::algorithms::implicit_als::training::init::interface1::Input::set
void set(InputId id, const data_management::NumericTablePtr &ptr)
daal::algorithms::implicit_als::training::init::PartialResultId
PartialResultId
Available identifiers of partial results of the implicit ALS initialization algorithm in the first st...
Definition: implicit_als_training_init_types.h:127
daal::algorithms::implicit_als::training::init::interface1::PartialResultBase
Provides interface to access partial results obtained with the implicit ALS initialization algorithm ...
Definition: implicit_als_training_init_types.h:337
daal::algorithms::implicit_als::training::init::interface1::DistributedParameter
Parameters of the compute() method of the implicit ALS initialization algorithm in the distributed co...
Definition: implicit_als_training_init_types.h:204
daal::algorithms::implicit_als::training::init::outputOfStep1ForStep2
Definition: implicit_als_training_init_types.h:140
daal::algorithms::implicit_als::training::init::outputOfInitForComputeStep3
Definition: implicit_als_training_init_types.h:115
daal::algorithms::implicit_als::training::init::DistributedPartialResultStep2Id
DistributedPartialResultStep2Id
Definition: implicit_als_training_init_types.h:150
daal::algorithms::implicit_als::training::init::interface1::DistributedInput< step2Local >::DistributedInput
DistributedInput(const DistributedInput &other)
Definition: implicit_als_training_init_types.h:306
daal::algorithms::implicit_als::training::init::interface1::PartialResultBase::set
void set(PartialResultBaseId id, const data_management::KeyValueDataCollectionPtr &ptr)
daal::algorithms::implicit_als::training::init::interface1::Parameter::fullNUsers
size_t fullNUsers
Definition: implicit_als_training_init_types.h:189
daal::algorithms::implicit_als::training::init::interface1::Input::get
data_management::NumericTablePtr get(InputId id) const
daal::algorithms::implicit_als::training::init::interface1::Result
Provides methods to access the results obtained with the compute() method of the implicit ALS initial...
Definition: implicit_als_training_init_types.h:530
daal::algorithms::implicit_als::training::init::data
Definition: implicit_als_training_init_types.h:92
daal::algorithms::implicit_als::training::init::InputId
InputId
Available identifiers of input objects for the implicit ALS initialization algorithm.
Definition: implicit_als_training_init_types.h:90
daal::algorithms::implicit_als::training::init::interface1::Parameter::nFactors
size_t nFactors
Definition: implicit_als_training_init_types.h:188
daal::algorithms::implicit_als::training::init::partialModel
Definition: implicit_als_training_init_types.h:129
daal::algorithms::implicit_als::training::init::interface1::Parameter::engine
engines::EnginePtr engine
Definition: implicit_als_training_init_types.h:191
daal::step1Local
Definition: daal_defines.h:142
daal::algorithms::implicit_als::training::init::interface1::Parameter::seed
size_t seed
Definition: implicit_als_training_init_types.h:190
daal::algorithms::implicit_als::training::init::PartialResultCollectionId
PartialResultCollectionId
Available identifiers of partial results of the implicit ALS initialization algorithm in the first st...
Definition: implicit_als_training_init_types.h:138
daal::algorithms::implicit_als::training::init::interface1::Parameter
Parameters of the compute() method of the implicit ALS initialization algorithm.
Definition: implicit_als_training_init_types.h:178
daal::algorithms::implicit_als::training::init::offsets
Definition: implicit_als_training_init_types.h:117
daal::algorithms::implicit_als::training::init::interface1::PartialResultBase::get
data_management::KeyValueDataCollectionPtr get(PartialResultBaseId id) const
daal::algorithms::implicit_als::training::init::defaultDense
Definition: implicit_als_training_init_types.h:82

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