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

implicit_als_training_types.h
1 /* file: implicit_als_training_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_TYPES_H__
49 #define __IMPLICIT_ALS_TRAINING_TYPES_H__
50 
51 #include "algorithms/implicit_als/implicit_als_model.h"
52 #include "data_management/data/csr_numeric_table.h"
53 
54 namespace daal
55 {
56 namespace algorithms
57 {
61 namespace implicit_als
62 {
72 namespace training
73 {
74 
79 enum Method
80 {
81  defaultDense = 0,
82  fastCSR = 1
83 };
84 
89 enum NumericTableInputId
90 {
91  data,
92  lastNumericTableInputId = data
93 };
94 
99 enum ModelInputId
100 {
101  inputModel = lastNumericTableInputId + 1,
102  lastModelInputId = inputModel
103 };
104 
109 enum PartialModelInputId
110 {
111  partialModel,
113  lastPartialModelInputId = partialModel
114 };
115 
121 enum MasterInputId
122 {
123  inputOfStep2FromStep1,
125  lastMasterInputId = inputOfStep2FromStep1
126 };
127 
133 enum DistributedPartialResultStep1Id
134 {
135  outputOfStep1ForStep2,
137  lastDistributedPartialResultStep1Id = outputOfStep1ForStep2
138 };
139 
145 enum DistributedPartialResultStep2Id
146 {
147  outputOfStep2ForStep4 ,
149  lastDistributedPartialResultStep2Id = outputOfStep2ForStep4
150 };
151 
157 enum Step3LocalCollectionInputId
158 {
159  partialModelBlocksToNode = lastDistributedPartialResultStep2Id + 1,
162  inputOfStep3FromInit = partialModelBlocksToNode,
164  lastStep3LocalCollectionInputId = inputOfStep3FromInit
165 };
166 
172 enum Step3LocalNumericTableInputId
173 {
174  offset = lastStep3LocalCollectionInputId + 1,
176  lastStep3LocalNumericTableInputId = offset
177 };
178 
184 enum DistributedPartialResultStep3Id
185 {
186  outputOfStep3ForStep4,
188  lastDistributedPartialResultStep3Id = outputOfStep3ForStep4
189 };
190 
196 enum Step4LocalPartialModelsInputId
197 {
198  partialModels,
201  lastStep4LocalPartialModelsInputId = partialModels
202 };
203 
209 enum Step4LocalNumericTableInputId
210 {
211  partialData = lastStep4LocalPartialModelsInputId + 1,
212  inputOfStep4FromStep2,
214  lastStep4LocalNumericTableInputId = inputOfStep4FromStep2
215 };
216 
222 enum DistributedPartialResultStep4Id
223 {
224  outputOfStep4ForStep1,
226  outputOfStep4ForStep3 = outputOfStep4ForStep1,
228  outputOfStep4 = outputOfStep4ForStep3,
230  lastDistributedPartialResultStep4Id = outputOfStep4
231 };
232 
237 enum ResultId
238 {
239  model,
240  lastResultId = model
241 };
242 
246 namespace interface1
247 {
252 class DAAL_EXPORT Input : public daal::algorithms::Input
253 {
254 public:
255  Input();
256  Input(const Input& other) : daal::algorithms::Input(other){}
257 
258  virtual ~Input() {}
259 
265  data_management::NumericTablePtr get(NumericTableInputId id) const;
266 
272  ModelPtr get(ModelInputId id) const;
273 
279  void set(NumericTableInputId id, const data_management::NumericTablePtr &ptr);
280 
286  void set(ModelInputId id, const ModelPtr &ptr);
287 
292  size_t getNumberOfUsers() const;
293 
298  size_t getNumberOfItems() const;
299 
305  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
306 };
307 
312 template<ComputeStep step>
313 class DistributedInput
314 {};
315 
321 template<>
322 class DAAL_EXPORT DistributedInput<step1Local> : public daal::algorithms::Input
323 {
324 public:
326  DistributedInput();
327 
329  DistributedInput(const DistributedInput& other) : daal::algorithms::Input(other){}
330 
331  virtual ~DistributedInput() {}
332 
338  PartialModelPtr get(PartialModelInputId id) const;
339 
345  void set(PartialModelInputId id, const PartialModelPtr &ptr);
346 
353  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
354 };
355 
361 class DAAL_EXPORT DistributedPartialResultStep1 : public daal::algorithms::PartialResult
362 {
363 public:
364  DECLARE_SERIALIZABLE_CAST(DistributedPartialResultStep1);
366  DistributedPartialResultStep1();
367 
368  virtual ~DistributedPartialResultStep1() {}
369 
375  data_management::NumericTablePtr get(DistributedPartialResultStep1Id id) const;
376 
382  void set(DistributedPartialResultStep1Id id, const data_management::NumericTablePtr &ptr);
383 
390  template <typename algorithmFPType>
391  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
392 
399  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
400  int method) const DAAL_C11_OVERRIDE;
401 
402 protected:
404  template<typename Archive, bool onDeserialize>
405  services::Status serialImpl(Archive *arch)
406  {
407  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
408  }
409 };
410 typedef services::SharedPtr<DistributedPartialResultStep1> DistributedPartialResultStep1Ptr;
411 
417 template<>
418 class DAAL_EXPORT DistributedInput<step2Master> : public daal::algorithms::Input
419 {
420 public:
422  DistributedInput();
423 
425  DistributedInput(const DistributedInput& other) : daal::algorithms::Input(other){}
426 
427  virtual ~DistributedInput() {}
428 
434  data_management::DataCollectionPtr get(MasterInputId id) const;
435 
441  void set(MasterInputId id, const data_management::DataCollectionPtr &ptr);
442 
449  void add(MasterInputId id, const DistributedPartialResultStep1Ptr &partialResult);
450 
457  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
458 };
459 
465 class DAAL_EXPORT DistributedPartialResultStep2 : public daal::algorithms::PartialResult
466 {
467 public:
468  DECLARE_SERIALIZABLE_CAST(DistributedPartialResultStep2);
470  DistributedPartialResultStep2();
471 
472  virtual ~DistributedPartialResultStep2() {}
473 
479  data_management::NumericTablePtr get(DistributedPartialResultStep2Id id) const;
480 
486  void set(DistributedPartialResultStep2Id id, const data_management::NumericTablePtr &ptr);
487 
494  template <typename algorithmFPType>
495  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
496 
503  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
504  int method) const DAAL_C11_OVERRIDE;
505 
506 protected:
508  template<typename Archive, bool onDeserialize>
509  services::Status serialImpl(Archive *arch)
510  {
511  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
512  }
513 };
514 typedef services::SharedPtr<DistributedPartialResultStep2> DistributedPartialResultStep2Ptr;
515 
521 template<>
522 class DAAL_EXPORT DistributedInput<step3Local> : public daal::algorithms::Input
523 {
524 public:
526  DistributedInput();
527 
529  DistributedInput(const DistributedInput& other) : daal::algorithms::Input(other){}
530 
531  virtual ~DistributedInput() {}
532 
538  PartialModelPtr get(PartialModelInputId id) const;
539 
545  data_management::KeyValueDataCollectionPtr get(Step3LocalCollectionInputId id) const;
546 
552  data_management::NumericTablePtr get(Step3LocalNumericTableInputId id) const;
553 
559  void set(PartialModelInputId id, const PartialModelPtr &ptr);
560 
566  void set(Step3LocalCollectionInputId id, const data_management::KeyValueDataCollectionPtr &ptr);
567 
573  void set(Step3LocalNumericTableInputId id, const data_management::NumericTablePtr &ptr);
574 
579  size_t getNumberOfBlocks() const;
580 
585  size_t getOffset() const;
586 
592  data_management::NumericTablePtr getOutBlockIndices(size_t key) const;
593 
600  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
601 };
602 
608 class DAAL_EXPORT DistributedPartialResultStep3 : public daal::algorithms::PartialResult
609 {
610 public:
611  DECLARE_SERIALIZABLE_CAST(DistributedPartialResultStep3);
613  DistributedPartialResultStep3();
614 
615  virtual ~DistributedPartialResultStep3() {}
616 
623  template <typename algorithmFPType>
624  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
625 
632  data_management::KeyValueDataCollectionPtr get(DistributedPartialResultStep3Id id) const;
633 
642  PartialModelPtr get(DistributedPartialResultStep3Id id, size_t key) const;
643 
649  void set(DistributedPartialResultStep3Id id, const data_management::KeyValueDataCollectionPtr &ptr);
650 
657  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
658  int method) const DAAL_C11_OVERRIDE;
659 
660 protected:
662  template<typename Archive, bool onDeserialize>
663  services::Status serialImpl(Archive *arch)
664  {
665  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
666  }
667 };
668 typedef services::SharedPtr<DistributedPartialResultStep3> DistributedPartialResultStep3Ptr;
669 
675 template<>
676 class DAAL_EXPORT DistributedInput<step4Local> : public daal::algorithms::Input
677 {
678 public:
680  DistributedInput();
681 
683  DistributedInput(const DistributedInput& other) : daal::algorithms::Input(other){}
684 
685  virtual ~DistributedInput() {}
686 
695  data_management::KeyValueDataCollectionPtr get(Step4LocalPartialModelsInputId id) const;
696 
702  data_management::NumericTablePtr get(Step4LocalNumericTableInputId id) const;
703 
709  void set(Step4LocalPartialModelsInputId id, const data_management::KeyValueDataCollectionPtr &ptr);
710 
716  void set(Step4LocalNumericTableInputId id, const data_management::NumericTablePtr &ptr);
717 
722  size_t getNumberOfRows() const;
723 
730  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
731 
732 };
733 
739 class DAAL_EXPORT DistributedPartialResultStep4 : public daal::algorithms::PartialResult
740 {
741 public:
742  DECLARE_SERIALIZABLE_CAST(DistributedPartialResultStep4);
744  DistributedPartialResultStep4();
745 
746  virtual ~DistributedPartialResultStep4() {}
747 
754  template <typename algorithmFPType>
755  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
756 
762  PartialModelPtr get(DistributedPartialResultStep4Id id) const;
763 
769  void set(DistributedPartialResultStep4Id id, const PartialModelPtr &ptr);
770 
777  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
778  int method) const DAAL_C11_OVERRIDE;
779 
780 protected:
782  template<typename Archive, bool onDeserialize>
783  services::Status serialImpl(Archive *arch)
784  {
785  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
786  }
787 };
788 typedef services::SharedPtr<DistributedPartialResultStep4> DistributedPartialResultStep4Ptr;
789 
795 class DAAL_EXPORT Result : public daal::algorithms::Result
796 {
797 public:
798  DECLARE_SERIALIZABLE_CAST(Result);
800  Result();
801 
808  template <typename algorithmFPType>
809  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
810 
816  daal::algorithms::implicit_als::ModelPtr get(ResultId id) const;
817 
823  void set(ResultId id, const daal::algorithms::implicit_als::ModelPtr &ptr);
824 
831  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
832  int method) const DAAL_C11_OVERRIDE;
833 
834 protected:
836  template<typename Archive, bool onDeserialize>
837  services::Status serialImpl(Archive *arch)
838  {
839  return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
840  }
841 };
842 typedef services::SharedPtr<Result> ResultPtr;
843 } // interface1
844 using interface1::Input;
845 using interface1::DistributedInput;
846 using interface1::DistributedPartialResultStep1;
847 using interface1::DistributedPartialResultStep1Ptr;
848 using interface1::DistributedPartialResultStep2;
849 using interface1::DistributedPartialResultStep2Ptr;
850 using interface1::DistributedPartialResultStep3;
851 using interface1::DistributedPartialResultStep3Ptr;
852 using interface1::DistributedPartialResultStep4;
853 using interface1::DistributedPartialResultStep4Ptr;
854 using interface1::Result;
855 using interface1::ResultPtr;
856 
857 }
859 }
860 }
861 }
862 
863 #endif
daal::algorithms::implicit_als::training::data
Definition: implicit_als_training_types.h:91
daal::algorithms::implicit_als::training::inputOfStep3FromInit
Definition: implicit_als_training_types.h:162
daal::algorithms::implicit_als::training::outputOfStep3ForStep4
Definition: implicit_als_training_types.h:186
daal
Definition: algorithm_base_common.h:57
daal::algorithms::implicit_als::training::Step4LocalPartialModelsInputId
Step4LocalPartialModelsInputId
Definition: implicit_als_training_types.h:196
daal::algorithms::implicit_als::training::ModelInputId
ModelInputId
Definition: implicit_als_training_types.h:99
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:739
daal::algorithms::implicit_als::training::Method
Method
Definition: implicit_als_training_types.h:79
daal::algorithms::implicit_als::training::defaultDense
Definition: implicit_als_training_types.h:81
daal::algorithms::implicit_als::training::Step3LocalCollectionInputId
Step3LocalCollectionInputId
Definition: implicit_als_training_types.h:157
daal::algorithms::implicit_als::training::NumericTableInputId
NumericTableInputId
Definition: implicit_als_training_types.h:89
daal::algorithms::implicit_als::training::Step3LocalNumericTableInputId
Step3LocalNumericTableInputId
Definition: implicit_als_training_types.h:172
daal::algorithms::implicit_als::training::model
Definition: implicit_als_training_types.h:239
daal::algorithms::implicit_als::training::inputOfStep4FromStep2
Definition: implicit_als_training_types.h:212
daal::algorithms::implicit_als::training::DistributedPartialResultStep1Id
DistributedPartialResultStep1Id
Definition: implicit_als_training_types.h:133
daal::algorithms::implicit_als::training::DistributedPartialResultStep2Id
DistributedPartialResultStep2Id
Definition: implicit_als_training_types.h:145
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:313
daal::algorithms::implicit_als::training::fastCSR
Definition: implicit_als_training_types.h:82
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:361
daal::algorithms::implicit_als::training::outputOfStep4ForStep3
Definition: implicit_als_training_types.h:226
daal::algorithms::implicit_als::training::inputModel
Definition: implicit_als_training_types.h:101
daal::algorithms::implicit_als::training::MasterInputId
MasterInputId
Definition: implicit_als_training_types.h:121
daal::algorithms::implicit_als::training::DistributedPartialResultStep3Id
DistributedPartialResultStep3Id
Definition: implicit_als_training_types.h:184
daal::algorithms::implicit_als::training::partialData
Definition: implicit_als_training_types.h:211
daal::algorithms::implicit_als::training::Step4LocalNumericTableInputId
Step4LocalNumericTableInputId
Definition: implicit_als_training_types.h:209
daal::step4Local
Definition: daal_defines.h:145
daal::algorithms::implicit_als::training::outputOfStep4
Definition: implicit_als_training_types.h:228
daal::algorithms::implicit_als::training::inputOfStep2FromStep1
Definition: implicit_als_training_types.h:123
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:608
daal::algorithms::implicit_als::training::partialModels
Definition: implicit_als_training_types.h:198
daal::algorithms::implicit_als::training::ResultId
ResultId
Available identifiers of the results of the implicit ALS training algorithm.
Definition: implicit_als_training_types.h:237
daal::algorithms::implicit_als::training::PartialModelInputId
PartialModelInputId
Definition: implicit_als_training_types.h:109
daal::algorithms::implicit_als::training::DistributedPartialResultStep4Id
DistributedPartialResultStep4Id
Definition: implicit_als_training_types.h:222
daal::algorithms::implicit_als::training::partialModelBlocksToNode
Definition: implicit_als_training_types.h:159
daal::algorithms::implicit_als::training::interface1::DistributedInput< step1Local >::DistributedInput
DistributedInput(const DistributedInput &other)
Definition: implicit_als_training_types.h:329
daal::step1Local
Definition: daal_defines.h:142
daal::step2Master
Definition: daal_defines.h:143
daal::algorithms::implicit_als::training::offset
Definition: implicit_als_training_types.h:174
daal::algorithms::implicit_als::training::partialModel
Definition: implicit_als_training_types.h:111
daal::algorithms::implicit_als::training::interface1::DistributedInput< step4Local >::DistributedInput
DistributedInput(const DistributedInput &other)
Definition: implicit_als_training_types.h:683
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:465
daal::algorithms::implicit_als::training::interface1::DistributedInput< step3Local >::DistributedInput
DistributedInput(const DistributedInput &other)
Definition: implicit_als_training_types.h:529
daal::step3Local
Definition: daal_defines.h:144
daal::algorithms::implicit_als::training::outputOfStep2ForStep4
Definition: implicit_als_training_types.h:147
daal::algorithms::implicit_als::training::outputOfStep1ForStep2
Definition: implicit_als_training_types.h:135
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:795
daal::algorithms::implicit_als::training::outputOfStep4ForStep1
Definition: implicit_als_training_types.h:224
daal::algorithms::implicit_als::training::interface1::Input
Input objects for the implicit ALS training algorithm
Definition: implicit_als_training_types.h:252
daal::algorithms::implicit_als::training::interface1::DistributedInput< step2Master >::DistributedInput
DistributedInput(const DistributedInput &other)
Definition: implicit_als_training_types.h:425

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