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

implicit_als_training_types.h
1 /* file: implicit_als_training_types.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 implicit ALS algorithm interface
21 //--
22 */
23 
24 #ifndef __IMPLICIT_ALS_TRAINING_TYPES_H__
25 #define __IMPLICIT_ALS_TRAINING_TYPES_H__
26 
27 #include "algorithms/implicit_als/implicit_als_model.h"
28 #include "data_management/data/csr_numeric_table.h"
29 
30 namespace daal
31 {
32 namespace algorithms
33 {
37 namespace implicit_als
38 {
48 namespace training
49 {
50 
55 enum Method
56 {
57  defaultDense = 0,
58  fastCSR = 1
59 };
60 
65 enum NumericTableInputId
66 {
67  data,
68  lastNumericTableInputId = data
69 };
70 
75 enum ModelInputId
76 {
77  inputModel = lastNumericTableInputId + 1,
78  lastModelInputId = inputModel
79 };
80 
85 enum PartialModelInputId
86 {
87  partialModel,
89  lastPartialModelInputId = partialModel
90 };
91 
97 enum MasterInputId
98 {
99  inputOfStep2FromStep1,
101  lastMasterInputId = inputOfStep2FromStep1
102 };
103 
109 enum DistributedPartialResultStep1Id
110 {
111  outputOfStep1ForStep2,
113  lastDistributedPartialResultStep1Id = outputOfStep1ForStep2
114 };
115 
121 enum DistributedPartialResultStep2Id
122 {
123  outputOfStep2ForStep4 ,
125  lastDistributedPartialResultStep2Id = outputOfStep2ForStep4
126 };
127 
133 enum Step3LocalCollectionInputId
134 {
135  partialModelBlocksToNode = lastDistributedPartialResultStep2Id + 1,
138  inputOfStep3FromInit = partialModelBlocksToNode,
140  lastStep3LocalCollectionInputId = inputOfStep3FromInit
141 };
142 
148 enum Step3LocalNumericTableInputId
149 {
150  offset = lastStep3LocalCollectionInputId + 1,
152  lastStep3LocalNumericTableInputId = offset
153 };
154 
160 enum DistributedPartialResultStep3Id
161 {
162  outputOfStep3ForStep4,
164  lastDistributedPartialResultStep3Id = outputOfStep3ForStep4
165 };
166 
172 enum Step4LocalPartialModelsInputId
173 {
174  partialModels,
177  lastStep4LocalPartialModelsInputId = partialModels
178 };
179 
185 enum Step4LocalNumericTableInputId
186 {
187  partialData = lastStep4LocalPartialModelsInputId + 1,
188  inputOfStep4FromStep2,
190  lastStep4LocalNumericTableInputId = inputOfStep4FromStep2
191 };
192 
198 enum DistributedPartialResultStep4Id
199 {
200  outputOfStep4ForStep1,
202  outputOfStep4ForStep3 = outputOfStep4ForStep1,
204  outputOfStep4 = outputOfStep4ForStep3,
206  lastDistributedPartialResultStep4Id = outputOfStep4
207 };
208 
213 enum ResultId
214 {
215  model,
216  lastResultId = model
217 };
218 
222 namespace interface1
223 {
228 class DAAL_EXPORT Input : public daal::algorithms::Input
229 {
230 public:
231  Input();
232  Input(const Input& other) : daal::algorithms::Input(other){}
233 
234  virtual ~Input() {}
235 
241  data_management::NumericTablePtr get(NumericTableInputId id) const;
242 
248  ModelPtr get(ModelInputId id) const;
249 
255  void set(NumericTableInputId id, const data_management::NumericTablePtr &ptr);
256 
262  void set(ModelInputId id, const ModelPtr &ptr);
263 
268  size_t getNumberOfUsers() const;
269 
274  size_t getNumberOfItems() const;
275 
281  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
282 };
283 
288 template<ComputeStep step>
289 class DistributedInput
290 {};
291 
297 template<>
298 class DAAL_EXPORT DistributedInput<step1Local> : public daal::algorithms::Input
299 {
300 public:
302  DistributedInput();
303 
305  DistributedInput(const DistributedInput& other) : daal::algorithms::Input(other){}
306 
307  virtual ~DistributedInput() {}
308 
314  PartialModelPtr get(PartialModelInputId id) const;
315 
321  void set(PartialModelInputId id, const PartialModelPtr &ptr);
322 
329  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
330 };
331 
337 class DAAL_EXPORT DistributedPartialResultStep1 : public daal::algorithms::PartialResult
338 {
339 public:
340  DECLARE_SERIALIZABLE_CAST(DistributedPartialResultStep1);
342  DistributedPartialResultStep1();
343 
344  virtual ~DistributedPartialResultStep1() {}
345 
351  data_management::NumericTablePtr get(DistributedPartialResultStep1Id id) const;
352 
358  void set(DistributedPartialResultStep1Id id, const data_management::NumericTablePtr &ptr);
359 
366  template <typename algorithmFPType>
367  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
368 
375  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
376  int method) const DAAL_C11_OVERRIDE;
377 
378 protected:
380  template<typename Archive, bool onDeserialize>
381  services::Status serialImpl(Archive *arch)
382  {
383  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
384  }
385 };
386 typedef services::SharedPtr<DistributedPartialResultStep1> DistributedPartialResultStep1Ptr;
387 
393 template<>
394 class DAAL_EXPORT DistributedInput<step2Master> : public daal::algorithms::Input
395 {
396 public:
398  DistributedInput();
399 
401  DistributedInput(const DistributedInput& other) : daal::algorithms::Input(other){}
402 
403  virtual ~DistributedInput() {}
404 
410  data_management::DataCollectionPtr get(MasterInputId id) const;
411 
417  void set(MasterInputId id, const data_management::DataCollectionPtr &ptr);
418 
425  void add(MasterInputId id, const DistributedPartialResultStep1Ptr &partialResult);
426 
433  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
434 };
435 
441 class DAAL_EXPORT DistributedPartialResultStep2 : public daal::algorithms::PartialResult
442 {
443 public:
444  DECLARE_SERIALIZABLE_CAST(DistributedPartialResultStep2);
446  DistributedPartialResultStep2();
447 
448  virtual ~DistributedPartialResultStep2() {}
449 
455  data_management::NumericTablePtr get(DistributedPartialResultStep2Id id) const;
456 
462  void set(DistributedPartialResultStep2Id id, const data_management::NumericTablePtr &ptr);
463 
470  template <typename algorithmFPType>
471  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
472 
479  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
480  int method) const DAAL_C11_OVERRIDE;
481 
482 protected:
484  template<typename Archive, bool onDeserialize>
485  services::Status serialImpl(Archive *arch)
486  {
487  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
488  }
489 };
490 typedef services::SharedPtr<DistributedPartialResultStep2> DistributedPartialResultStep2Ptr;
491 
497 template<>
498 class DAAL_EXPORT DistributedInput<step3Local> : public daal::algorithms::Input
499 {
500 public:
502  DistributedInput();
503 
505  DistributedInput(const DistributedInput& other) : daal::algorithms::Input(other){}
506 
507  virtual ~DistributedInput() {}
508 
514  PartialModelPtr get(PartialModelInputId id) const;
515 
521  data_management::KeyValueDataCollectionPtr get(Step3LocalCollectionInputId id) const;
522 
528  data_management::NumericTablePtr get(Step3LocalNumericTableInputId id) const;
529 
535  void set(PartialModelInputId id, const PartialModelPtr &ptr);
536 
542  void set(Step3LocalCollectionInputId id, const data_management::KeyValueDataCollectionPtr &ptr);
543 
549  void set(Step3LocalNumericTableInputId id, const data_management::NumericTablePtr &ptr);
550 
555  size_t getNumberOfBlocks() const;
556 
561  size_t getOffset() const;
562 
568  data_management::NumericTablePtr getOutBlockIndices(size_t key) const;
569 
576  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
577 };
578 
584 class DAAL_EXPORT DistributedPartialResultStep3 : public daal::algorithms::PartialResult
585 {
586 public:
587  DECLARE_SERIALIZABLE_CAST(DistributedPartialResultStep3);
589  DistributedPartialResultStep3();
590 
591  virtual ~DistributedPartialResultStep3() {}
592 
599  template <typename algorithmFPType>
600  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
601 
608  data_management::KeyValueDataCollectionPtr get(DistributedPartialResultStep3Id id) const;
609 
618  PartialModelPtr get(DistributedPartialResultStep3Id id, size_t key) const;
619 
625  void set(DistributedPartialResultStep3Id id, const data_management::KeyValueDataCollectionPtr &ptr);
626 
633  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
634  int method) const DAAL_C11_OVERRIDE;
635 
636 protected:
638  template<typename Archive, bool onDeserialize>
639  services::Status serialImpl(Archive *arch)
640  {
641  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
642  }
643 };
644 typedef services::SharedPtr<DistributedPartialResultStep3> DistributedPartialResultStep3Ptr;
645 
651 template<>
652 class DAAL_EXPORT DistributedInput<step4Local> : public daal::algorithms::Input
653 {
654 public:
656  DistributedInput();
657 
659  DistributedInput(const DistributedInput& other) : daal::algorithms::Input(other){}
660 
661  virtual ~DistributedInput() {}
662 
671  data_management::KeyValueDataCollectionPtr get(Step4LocalPartialModelsInputId id) const;
672 
678  data_management::NumericTablePtr get(Step4LocalNumericTableInputId id) const;
679 
685  void set(Step4LocalPartialModelsInputId id, const data_management::KeyValueDataCollectionPtr &ptr);
686 
692  void set(Step4LocalNumericTableInputId id, const data_management::NumericTablePtr &ptr);
693 
698  size_t getNumberOfRows() const;
699 
706  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
707 
708 };
709 
715 class DAAL_EXPORT DistributedPartialResultStep4 : public daal::algorithms::PartialResult
716 {
717 public:
718  DECLARE_SERIALIZABLE_CAST(DistributedPartialResultStep4);
720  DistributedPartialResultStep4();
721 
722  virtual ~DistributedPartialResultStep4() {}
723 
730  template <typename algorithmFPType>
731  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
732 
738  PartialModelPtr get(DistributedPartialResultStep4Id id) const;
739 
745  void set(DistributedPartialResultStep4Id id, const PartialModelPtr &ptr);
746 
753  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
754  int method) const DAAL_C11_OVERRIDE;
755 
756 protected:
758  template<typename Archive, bool onDeserialize>
759  services::Status serialImpl(Archive *arch)
760  {
761  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
762  }
763 };
764 typedef services::SharedPtr<DistributedPartialResultStep4> DistributedPartialResultStep4Ptr;
765 
771 class DAAL_EXPORT Result : public daal::algorithms::Result
772 {
773 public:
774  DECLARE_SERIALIZABLE_CAST(Result);
776  Result();
777 
784  template <typename algorithmFPType>
785  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
786 
792  daal::algorithms::implicit_als::ModelPtr get(ResultId id) const;
793 
799  void set(ResultId id, const daal::algorithms::implicit_als::ModelPtr &ptr);
800 
807  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
808  int method) const DAAL_C11_OVERRIDE;
809 
810 protected:
812  template<typename Archive, bool onDeserialize>
813  services::Status serialImpl(Archive *arch)
814  {
815  return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
816  }
817 };
818 typedef services::SharedPtr<Result> ResultPtr;
819 } // interface1
820 using interface1::Input;
821 using interface1::DistributedInput;
822 using interface1::DistributedPartialResultStep1;
823 using interface1::DistributedPartialResultStep1Ptr;
824 using interface1::DistributedPartialResultStep2;
825 using interface1::DistributedPartialResultStep2Ptr;
826 using interface1::DistributedPartialResultStep3;
827 using interface1::DistributedPartialResultStep3Ptr;
828 using interface1::DistributedPartialResultStep4;
829 using interface1::DistributedPartialResultStep4Ptr;
830 using interface1::Result;
831 using interface1::ResultPtr;
832 
833 }
835 }
836 }
837 }
838 
839 #endif
daal::step1Local
Definition: daal_defines.h:123
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:337
daal::algorithms::implicit_als::training::Method
Method
Definition: implicit_als_training_types.h:55
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:584
daal::algorithms::implicit_als::training::interface1::DistributedInput< step1Local >::DistributedInput
DistributedInput(const DistributedInput &other)
Definition: implicit_als_training_types.h:305
daal::algorithms::implicit_als::training::ModelInputId
ModelInputId
Definition: implicit_als_training_types.h:75
daal::algorithms::implicit_als::training::model
Definition: implicit_als_training_types.h:215
daal::step2Master
Definition: daal_defines.h:124
daal::algorithms::implicit_als::training::inputModel
Definition: implicit_als_training_types.h:77
daal::algorithms::implicit_als::training::inputOfStep4FromStep2
Definition: implicit_als_training_types.h:188
daal::algorithms::implicit_als::training::interface1::Input
Input objects for the implicit ALS training algorithm
Definition: implicit_als_training_types.h:228
daal::algorithms::implicit_als::training::outputOfStep4ForStep1
Definition: implicit_als_training_types.h:200
daal::algorithms::implicit_als::training::interface1::DistributedInput< step3Local >::DistributedInput
DistributedInput(const DistributedInput &other)
Definition: implicit_als_training_types.h:505
daal::algorithms::implicit_als::training::DistributedPartialResultStep2Id
DistributedPartialResultStep2Id
Definition: implicit_als_training_types.h:121
daal::step3Local
Definition: daal_defines.h:125
daal::algorithms::implicit_als::training::partialData
Definition: implicit_als_training_types.h:187
daal::algorithms::implicit_als::training::outputOfStep4ForStep3
Definition: implicit_als_training_types.h:202
daal::step4Local
Definition: daal_defines.h:126
daal::algorithms::implicit_als::training::Step4LocalPartialModelsInputId
Step4LocalPartialModelsInputId
Definition: implicit_als_training_types.h:172
daal::algorithms::implicit_als::training::Step4LocalNumericTableInputId
Step4LocalNumericTableInputId
Definition: implicit_als_training_types.h:185
daal::algorithms::implicit_als::training::outputOfStep2ForStep4
Definition: implicit_als_training_types.h:123
daal::algorithms::implicit_als::training::interface1::DistributedInput< step4Local >::DistributedInput
DistributedInput(const DistributedInput &other)
Definition: implicit_als_training_types.h:659
daal::algorithms::implicit_als::training::outputOfStep4
Definition: implicit_als_training_types.h:204
daal::algorithms::implicit_als::training::inputOfStep3FromInit
Definition: implicit_als_training_types.h:138
daal::algorithms::implicit_als::training::ResultId
ResultId
Available identifiers of the results of the implicit ALS training algorithm.
Definition: implicit_als_training_types.h:213
daal::algorithms::implicit_als::training::DistributedPartialResultStep1Id
DistributedPartialResultStep1Id
Definition: implicit_als_training_types.h:109
daal::algorithms::implicit_als::training::PartialModelInputId
PartialModelInputId
Definition: implicit_als_training_types.h:85
daal::algorithms::implicit_als::training::partialModelBlocksToNode
Definition: implicit_als_training_types.h:135
daal::algorithms::implicit_als::training::outputOfStep3ForStep4
Definition: implicit_als_training_types.h:162
daal::algorithms::implicit_als::training::partialModels
Definition: implicit_als_training_types.h:174
daal::algorithms::implicit_als::training::DistributedPartialResultStep3Id
DistributedPartialResultStep3Id
Definition: implicit_als_training_types.h:160
daal::algorithms::implicit_als::training::inputOfStep2FromStep1
Definition: implicit_als_training_types.h:99
daal::algorithms::implicit_als::training::partialModel
Definition: implicit_als_training_types.h:87
daal::algorithms::implicit_als::training::data
Definition: implicit_als_training_types.h:67
daal::algorithms::implicit_als::training::outputOfStep1ForStep2
Definition: implicit_als_training_types.h:111
daal::algorithms::implicit_als::training::Step3LocalCollectionInputId
Step3LocalCollectionInputId
Definition: implicit_als_training_types.h:133
daal::algorithms::implicit_als::training::DistributedPartialResultStep4Id
DistributedPartialResultStep4Id
Definition: implicit_als_training_types.h:198
daal::algorithms::implicit_als::training::MasterInputId
MasterInputId
Definition: implicit_als_training_types.h:97
daal::algorithms::implicit_als::training::fastCSR
Definition: implicit_als_training_types.h:58
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:715
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:441
daal::algorithms::implicit_als::training::interface1::DistributedInput< step2Master >::DistributedInput
DistributedInput(const DistributedInput &other)
Definition: implicit_als_training_types.h:401
daal::algorithms::implicit_als::training::offset
Definition: implicit_als_training_types.h:150
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:289
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:771
daal::algorithms::implicit_als::training::Step3LocalNumericTableInputId
Step3LocalNumericTableInputId
Definition: implicit_als_training_types.h:148
daal::algorithms::implicit_als::training::NumericTableInputId
NumericTableInputId
Definition: implicit_als_training_types.h:65
daal::algorithms::implicit_als::training::defaultDense
Definition: implicit_als_training_types.h:57

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