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

implicit_als_training_types.h
1 /* file: implicit_als_training_types.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 implicit ALS algorithm interface
19 //--
20 */
21 
22 #ifndef __IMPLICIT_ALS_TRAINING_TYPES_H__
23 #define __IMPLICIT_ALS_TRAINING_TYPES_H__
24 
25 #include "algorithms/implicit_als/implicit_als_model.h"
26 #include "data_management/data/csr_numeric_table.h"
27 
28 namespace daal
29 {
30 namespace algorithms
31 {
35 namespace implicit_als
36 {
46 namespace training
47 {
48 
53 enum Method
54 {
55  defaultDense = 0,
56  fastCSR = 1
57 };
58 
63 enum NumericTableInputId
64 {
65  data,
66  lastNumericTableInputId = data
67 };
68 
73 enum ModelInputId
74 {
75  inputModel = lastNumericTableInputId + 1,
76  lastModelInputId = inputModel
77 };
78 
83 enum PartialModelInputId
84 {
85  partialModel,
87  lastPartialModelInputId = partialModel
88 };
89 
95 enum MasterInputId
96 {
97  inputOfStep2FromStep1,
99  lastMasterInputId = inputOfStep2FromStep1
100 };
101 
107 enum DistributedPartialResultStep1Id
108 {
109  outputOfStep1ForStep2,
111  lastDistributedPartialResultStep1Id = outputOfStep1ForStep2
112 };
113 
119 enum DistributedPartialResultStep2Id
120 {
121  outputOfStep2ForStep4 ,
123  lastDistributedPartialResultStep2Id = outputOfStep2ForStep4
124 };
125 
131 enum Step3LocalCollectionInputId
132 {
133  partialModelBlocksToNode = lastDistributedPartialResultStep2Id + 1,
136  inputOfStep3FromInit = partialModelBlocksToNode,
138  lastStep3LocalCollectionInputId = inputOfStep3FromInit
139 };
140 
146 enum Step3LocalNumericTableInputId
147 {
148  offset = lastStep3LocalCollectionInputId + 1,
150  lastStep3LocalNumericTableInputId = offset
151 };
152 
158 enum DistributedPartialResultStep3Id
159 {
160  outputOfStep3ForStep4,
162  lastDistributedPartialResultStep3Id = outputOfStep3ForStep4
163 };
164 
170 enum Step4LocalPartialModelsInputId
171 {
172  partialModels,
175  lastStep4LocalPartialModelsInputId = partialModels
176 };
177 
183 enum Step4LocalNumericTableInputId
184 {
185  partialData = lastStep4LocalPartialModelsInputId + 1,
186  inputOfStep4FromStep2,
188  lastStep4LocalNumericTableInputId = inputOfStep4FromStep2
189 };
190 
196 enum DistributedPartialResultStep4Id
197 {
198  outputOfStep4ForStep1,
200  outputOfStep4ForStep3 = outputOfStep4ForStep1,
202  outputOfStep4 = outputOfStep4ForStep3,
204  lastDistributedPartialResultStep4Id = outputOfStep4
205 };
206 
211 enum ResultId
212 {
213  model,
214  lastResultId = model
215 };
216 
220 namespace interface1
221 {
226 class DAAL_EXPORT Input : public daal::algorithms::Input
227 {
228 public:
229  Input();
230  Input(const Input& other) : daal::algorithms::Input(other){}
231 
232  virtual ~Input() {}
233 
239  data_management::NumericTablePtr get(NumericTableInputId id) const;
240 
246  ModelPtr get(ModelInputId id) const;
247 
253  void set(NumericTableInputId id, const data_management::NumericTablePtr &ptr);
254 
260  void set(ModelInputId id, const ModelPtr &ptr);
261 
266  size_t getNumberOfUsers() const;
267 
272  size_t getNumberOfItems() const;
273 
279  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
280 };
281 
286 template<ComputeStep step>
287 class DistributedInput
288 {};
289 
295 template<>
296 class DAAL_EXPORT DistributedInput<step1Local> : public daal::algorithms::Input
297 {
298 public:
300  DistributedInput();
301 
303  DistributedInput(const DistributedInput& other) : daal::algorithms::Input(other){}
304 
305  virtual ~DistributedInput() {}
306 
312  PartialModelPtr get(PartialModelInputId id) const;
313 
319  void set(PartialModelInputId id, const PartialModelPtr &ptr);
320 
327  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
328 };
329 
335 class DAAL_EXPORT DistributedPartialResultStep1 : public daal::algorithms::PartialResult
336 {
337 public:
338  DECLARE_SERIALIZABLE_CAST(DistributedPartialResultStep1);
340  DistributedPartialResultStep1();
341 
342  virtual ~DistributedPartialResultStep1() {}
343 
349  data_management::NumericTablePtr get(DistributedPartialResultStep1Id id) const;
350 
356  void set(DistributedPartialResultStep1Id id, const data_management::NumericTablePtr &ptr);
357 
364  template <typename algorithmFPType>
365  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
366 
373  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
374  int method) const DAAL_C11_OVERRIDE;
375 
376 protected:
378  template<typename Archive, bool onDeserialize>
379  services::Status serialImpl(Archive *arch)
380  {
381  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
382  }
383 };
384 typedef services::SharedPtr<DistributedPartialResultStep1> DistributedPartialResultStep1Ptr;
385 
391 template<>
392 class DAAL_EXPORT DistributedInput<step2Master> : public daal::algorithms::Input
393 {
394 public:
396  DistributedInput();
397 
399  DistributedInput(const DistributedInput& other) : daal::algorithms::Input(other){}
400 
401  virtual ~DistributedInput() {}
402 
408  data_management::DataCollectionPtr get(MasterInputId id) const;
409 
415  void set(MasterInputId id, const data_management::DataCollectionPtr &ptr);
416 
423  void add(MasterInputId id, const DistributedPartialResultStep1Ptr &partialResult);
424 
431  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
432 };
433 
439 class DAAL_EXPORT DistributedPartialResultStep2 : public daal::algorithms::PartialResult
440 {
441 public:
442  DECLARE_SERIALIZABLE_CAST(DistributedPartialResultStep2);
444  DistributedPartialResultStep2();
445 
446  virtual ~DistributedPartialResultStep2() {}
447 
453  data_management::NumericTablePtr get(DistributedPartialResultStep2Id id) const;
454 
460  void set(DistributedPartialResultStep2Id id, const data_management::NumericTablePtr &ptr);
461 
468  template <typename algorithmFPType>
469  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
470 
477  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
478  int method) const DAAL_C11_OVERRIDE;
479 
480 protected:
482  template<typename Archive, bool onDeserialize>
483  services::Status serialImpl(Archive *arch)
484  {
485  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
486  }
487 };
488 typedef services::SharedPtr<DistributedPartialResultStep2> DistributedPartialResultStep2Ptr;
489 
495 template<>
496 class DAAL_EXPORT DistributedInput<step3Local> : public daal::algorithms::Input
497 {
498 public:
500  DistributedInput();
501 
503  DistributedInput(const DistributedInput& other) : daal::algorithms::Input(other){}
504 
505  virtual ~DistributedInput() {}
506 
512  PartialModelPtr get(PartialModelInputId id) const;
513 
519  data_management::KeyValueDataCollectionPtr get(Step3LocalCollectionInputId id) const;
520 
526  data_management::NumericTablePtr get(Step3LocalNumericTableInputId id) const;
527 
533  void set(PartialModelInputId id, const PartialModelPtr &ptr);
534 
540  void set(Step3LocalCollectionInputId id, const data_management::KeyValueDataCollectionPtr &ptr);
541 
547  void set(Step3LocalNumericTableInputId id, const data_management::NumericTablePtr &ptr);
548 
553  size_t getNumberOfBlocks() const;
554 
559  size_t getOffset() const;
560 
566  data_management::NumericTablePtr getOutBlockIndices(size_t key) const;
567 
574  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
575 };
576 
582 class DAAL_EXPORT DistributedPartialResultStep3 : public daal::algorithms::PartialResult
583 {
584 public:
585  DECLARE_SERIALIZABLE_CAST(DistributedPartialResultStep3);
587  DistributedPartialResultStep3();
588 
589  virtual ~DistributedPartialResultStep3() {}
590 
597  template <typename algorithmFPType>
598  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
599 
606  data_management::KeyValueDataCollectionPtr get(DistributedPartialResultStep3Id id) const;
607 
616  PartialModelPtr get(DistributedPartialResultStep3Id id, size_t key) const;
617 
623  void set(DistributedPartialResultStep3Id id, const data_management::KeyValueDataCollectionPtr &ptr);
624 
631  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
632  int method) const DAAL_C11_OVERRIDE;
633 
634 protected:
636  template<typename Archive, bool onDeserialize>
637  services::Status serialImpl(Archive *arch)
638  {
639  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
640  }
641 };
642 typedef services::SharedPtr<DistributedPartialResultStep3> DistributedPartialResultStep3Ptr;
643 
649 template<>
650 class DAAL_EXPORT DistributedInput<step4Local> : public daal::algorithms::Input
651 {
652 public:
654  DistributedInput();
655 
657  DistributedInput(const DistributedInput& other) : daal::algorithms::Input(other){}
658 
659  virtual ~DistributedInput() {}
660 
669  data_management::KeyValueDataCollectionPtr get(Step4LocalPartialModelsInputId id) const;
670 
676  data_management::NumericTablePtr get(Step4LocalNumericTableInputId id) const;
677 
683  void set(Step4LocalPartialModelsInputId id, const data_management::KeyValueDataCollectionPtr &ptr);
684 
690  void set(Step4LocalNumericTableInputId id, const data_management::NumericTablePtr &ptr);
691 
696  size_t getNumberOfRows() const;
697 
704  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
705 
706 };
707 
713 class DAAL_EXPORT DistributedPartialResultStep4 : public daal::algorithms::PartialResult
714 {
715 public:
716  DECLARE_SERIALIZABLE_CAST(DistributedPartialResultStep4);
718  DistributedPartialResultStep4();
719 
720  virtual ~DistributedPartialResultStep4() {}
721 
728  template <typename algorithmFPType>
729  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
730 
736  PartialModelPtr get(DistributedPartialResultStep4Id id) const;
737 
743  void set(DistributedPartialResultStep4Id id, const PartialModelPtr &ptr);
744 
751  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
752  int method) const DAAL_C11_OVERRIDE;
753 
754 protected:
756  template<typename Archive, bool onDeserialize>
757  services::Status serialImpl(Archive *arch)
758  {
759  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
760  }
761 };
762 typedef services::SharedPtr<DistributedPartialResultStep4> DistributedPartialResultStep4Ptr;
763 
769 class DAAL_EXPORT Result : public daal::algorithms::Result
770 {
771 public:
772  DECLARE_SERIALIZABLE_CAST(Result);
774  Result();
775 
782  template <typename algorithmFPType>
783  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
784 
790  daal::algorithms::implicit_als::ModelPtr get(ResultId id) const;
791 
797  void set(ResultId id, const daal::algorithms::implicit_als::ModelPtr &ptr);
798 
805  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
806  int method) const DAAL_C11_OVERRIDE;
807 
808 protected:
810  template<typename Archive, bool onDeserialize>
811  services::Status serialImpl(Archive *arch)
812  {
813  return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
814  }
815 };
816 typedef services::SharedPtr<Result> ResultPtr;
817 } // interface1
818 using interface1::Input;
819 using interface1::DistributedInput;
820 using interface1::DistributedPartialResultStep1;
821 using interface1::DistributedPartialResultStep1Ptr;
822 using interface1::DistributedPartialResultStep2;
823 using interface1::DistributedPartialResultStep2Ptr;
824 using interface1::DistributedPartialResultStep3;
825 using interface1::DistributedPartialResultStep3Ptr;
826 using interface1::DistributedPartialResultStep4;
827 using interface1::DistributedPartialResultStep4Ptr;
828 using interface1::Result;
829 using interface1::ResultPtr;
830 
831 }
833 }
834 }
835 }
836 
837 #endif
daal::algorithms::implicit_als::training::data
Definition: implicit_als_training_types.h:65
daal::algorithms::implicit_als::training::inputOfStep3FromInit
Definition: implicit_als_training_types.h:136
daal::algorithms::implicit_als::training::outputOfStep3ForStep4
Definition: implicit_als_training_types.h:160
daal
Definition: algorithm_base_common.h:31
daal::algorithms::implicit_als::training::Step4LocalPartialModelsInputId
Step4LocalPartialModelsInputId
Definition: implicit_als_training_types.h:170
daal::algorithms::implicit_als::training::ModelInputId
ModelInputId
Definition: implicit_als_training_types.h:73
daal::algorithms::implicit_als::training::interface1::DistributedPartialResultStep4
Provides methods to access partial results obtained with the compute() method of the implicit ALS alg...
Definition: implicit_als_training_types.h:713
daal::algorithms::implicit_als::training::Method
Method
Definition: implicit_als_training_types.h:53
daal::algorithms::implicit_als::training::defaultDense
Definition: implicit_als_training_types.h:55
daal::algorithms::implicit_als::training::Step3LocalCollectionInputId
Step3LocalCollectionInputId
Definition: implicit_als_training_types.h:131
daal::algorithms::implicit_als::training::NumericTableInputId
NumericTableInputId
Definition: implicit_als_training_types.h:63
daal::algorithms::implicit_als::training::Step3LocalNumericTableInputId
Step3LocalNumericTableInputId
Definition: implicit_als_training_types.h:146
daal::algorithms::implicit_als::training::model
Definition: implicit_als_training_types.h:213
daal::algorithms::implicit_als::training::inputOfStep4FromStep2
Definition: implicit_als_training_types.h:186
daal::algorithms::implicit_als::training::DistributedPartialResultStep1Id
DistributedPartialResultStep1Id
Definition: implicit_als_training_types.h:107
daal::algorithms::implicit_als::training::DistributedPartialResultStep2Id
DistributedPartialResultStep2Id
Definition: implicit_als_training_types.h:119
daal::algorithms::implicit_als::training::interface1::DistributedInput
Input objects for the implicit ALS training algorithm in the distributed processing mode ...
Definition: implicit_als_training_types.h:287
daal::algorithms::implicit_als::training::fastCSR
Definition: implicit_als_training_types.h:56
daal::algorithms::implicit_als::training::interface1::DistributedPartialResultStep1
Provides methods to access partial results obtained with the compute() method of the implicit ALS alg...
Definition: implicit_als_training_types.h:335
daal::algorithms::implicit_als::training::outputOfStep4ForStep3
Definition: implicit_als_training_types.h:200
daal::algorithms::implicit_als::training::inputModel
Definition: implicit_als_training_types.h:75
daal::algorithms::implicit_als::training::MasterInputId
MasterInputId
Definition: implicit_als_training_types.h:95
daal::algorithms::implicit_als::training::DistributedPartialResultStep3Id
DistributedPartialResultStep3Id
Definition: implicit_als_training_types.h:158
daal::algorithms::implicit_als::training::partialData
Definition: implicit_als_training_types.h:185
daal::algorithms::implicit_als::training::Step4LocalNumericTableInputId
Step4LocalNumericTableInputId
Definition: implicit_als_training_types.h:183
daal::step4Local
Definition: daal_defines.h:124
daal::algorithms::implicit_als::training::outputOfStep4
Definition: implicit_als_training_types.h:202
daal::algorithms::implicit_als::training::inputOfStep2FromStep1
Definition: implicit_als_training_types.h:97
daal::algorithms::implicit_als::training::interface1::DistributedPartialResultStep3
Provides methods to access partial results obtained with the compute() method of the implicit ALS alg...
Definition: implicit_als_training_types.h:582
daal::algorithms::implicit_als::training::partialModels
Definition: implicit_als_training_types.h:172
daal::algorithms::implicit_als::training::ResultId
ResultId
Available identifiers of the results of the implicit ALS training algorithm.
Definition: implicit_als_training_types.h:211
daal::algorithms::implicit_als::training::PartialModelInputId
PartialModelInputId
Definition: implicit_als_training_types.h:83
daal::algorithms::implicit_als::training::DistributedPartialResultStep4Id
DistributedPartialResultStep4Id
Definition: implicit_als_training_types.h:196
daal::algorithms::implicit_als::training::partialModelBlocksToNode
Definition: implicit_als_training_types.h:133
daal::algorithms::implicit_als::training::interface1::DistributedInput< step1Local >::DistributedInput
DistributedInput(const DistributedInput &other)
Definition: implicit_als_training_types.h:303
daal::step1Local
Definition: daal_defines.h:121
daal::step2Master
Definition: daal_defines.h:122
daal::algorithms::implicit_als::training::offset
Definition: implicit_als_training_types.h:148
daal::algorithms::implicit_als::training::partialModel
Definition: implicit_als_training_types.h:85
daal::algorithms::implicit_als::training::interface1::DistributedInput< step4Local >::DistributedInput
DistributedInput(const DistributedInput &other)
Definition: implicit_als_training_types.h:657
daal::algorithms::implicit_als::training::interface1::DistributedPartialResultStep2
Provides methods to access partial results obtained with the compute() method of the implicit ALS alg...
Definition: implicit_als_training_types.h:439
daal::algorithms::implicit_als::training::interface1::DistributedInput< step3Local >::DistributedInput
DistributedInput(const DistributedInput &other)
Definition: implicit_als_training_types.h:503
daal::step3Local
Definition: daal_defines.h:123
daal::algorithms::implicit_als::training::outputOfStep2ForStep4
Definition: implicit_als_training_types.h:121
daal::algorithms::implicit_als::training::outputOfStep1ForStep2
Definition: implicit_als_training_types.h:109
daal::algorithms::implicit_als::training::interface1::Result
Provides methods to access the results obtained with the compute() method of the implicit ALS trainin...
Definition: implicit_als_training_types.h:769
daal::algorithms::implicit_als::training::outputOfStep4ForStep1
Definition: implicit_als_training_types.h:198
daal::algorithms::implicit_als::training::interface1::Input
Input objects for the implicit ALS training algorithm
Definition: implicit_als_training_types.h:226
daal::algorithms::implicit_als::training::interface1::DistributedInput< step2Master >::DistributedInput
DistributedInput(const DistributedInput &other)
Definition: implicit_als_training_types.h:399

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