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

initializer_types.h
1 /* file: initializer_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 neural_networks Network layer.
21 //--
22 */
23 
24 #ifndef __INITIALIZERS__TYPES__H__
25 #define __INITIALIZERS__TYPES__H__
26 
27 #include "algorithms/algorithm.h"
28 #include "data_management/data/tensor.h"
29 #include "services/daal_defines.h"
30 #include "services/collection.h"
31 #include "data_management/data/data_collection.h"
32 #include "algorithms/neural_networks/initializers/initializer_types_defs.h"
33 #include "algorithms/engines/engine.h"
34 #include "algorithms/engines/mt19937/mt19937.h"
35 
36 namespace daal
37 {
38 namespace algorithms
39 {
40 namespace neural_networks
41 {
51 namespace initializers
52 {
57 enum InputId
58 {
59  data,
60  lastInputId = data
61 };
62 
67 enum ResultId
68 {
69  value,
70  lastResultId = value
71 };
72 
76 namespace interface1
77 {
78 
83 class Parameter: public daal::algorithms::Parameter
84 {
85 public:
86  Parameter(layers::forward::LayerIfacePtr layerForParameter = layers::forward::LayerIfacePtr()): layer(layerForParameter) {}
87  virtual ~Parameter() {}
88 
89  layers::forward::LayerIfacePtr layer;
90  engines::EnginePtr engine;
91 };
92 
97 class DAAL_EXPORT Input : public daal::algorithms::Input
98 {
99 public:
103  Input() : daal::algorithms::Input(1) {}
105  Input(const Input& other) : daal::algorithms::Input(other){}
106 
107  virtual ~Input() {}
108 
114  data_management::TensorPtr get(InputId id) const
115  {
116  return data_management::Tensor::cast(Argument::get(id));
117  }
118 
124  void set(InputId id, const data_management::TensorPtr &ptr)
125  {
126  Argument::set(id, ptr);
127  }
128 
136  services::Status check(const daal::algorithms::Parameter *par, int method) const DAAL_C11_OVERRIDE;
137 };
138 
143 class DAAL_EXPORT Result : public daal::algorithms::Result
144 {
145 public:
147  Result() : daal::algorithms::Result(1) {}
148 
149  virtual ~Result() {}
150 
159  template <typename algorithmFPType>
160  services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *par, const int method)
161  {
162  const Input *algInput = static_cast<const Input *>(input);
163 
164  set(value, algInput->get(data));
165  return services::Status();
166  }
167 
173  data_management::TensorPtr get(ResultId id) const
174  {
175  return data_management::Tensor::cast(Argument::get(id));
176  }
177 
183  void set(ResultId id, const data_management::TensorPtr &ptr)
184  {
185  Argument::set(id, ptr);
186  }
187 
196  virtual services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
197  int method) const DAAL_C11_OVERRIDE;
198 
199 protected:
201  template<typename Archive, bool onDeserialize>
202  services::Status serialImpl(Archive *arch)
203  {
204  return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
205  }
206 };
207 typedef services::SharedPtr<Result> ResultPtr;
208 } // interface1
209 using interface1::Input;
210 using interface1::Result;
211 using interface1::ResultPtr;
212 using interface1::Parameter;
213 } // namespace initializers
215 } // namespace neural_networks
216 } // namespace algorithm
217 } // namespace daal
218 #endif
daal::algorithms::neural_networks::initializers::interface1::Result::Result
Result()
Constructor.
Definition: initializer_types.h:147
daal::algorithms::neural_networks::initializers::data
Definition: initializer_types.h:59
daal::algorithms::interface1::Result
Base class to represent final results of the computation. Algorithm-specific final results are repres...
Definition: algorithm_types.h:309
daal::algorithms::neural_networks::initializers::ResultId
ResultId
Definition: initializer_types.h:67
daal_defines.h
daal::algorithms::neural_networks::initializers::interface1::Result::allocate
services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *par, const int method)
Definition: initializer_types.h:160
daal::algorithms::interface1::Input
Base class to represent computation input arguments. Algorithm-specific input arguments are represent...
Definition: algorithm_types.h:193
daal::algorithms::neural_networks::initializers::value
Definition: initializer_types.h:69
daal::algorithms::neural_networks::initializers::interface1::Input
Input objects for initializer algorithm
Definition: initializer_types.h:97
daal::algorithms::interface1::Parameter
Base class to represent computation parameters. Algorithm-specific parameters are represented as deri...
Definition: algorithm_types.h:62
daal::algorithms::neural_networks::initializers::InputId
InputId
Definition: initializer_types.h:57
daal::algorithms::neural_networks::initializers::interface1::Parameter::layer
layers::forward::LayerIfacePtr layer
Definition: initializer_types.h:89
daal::algorithms::neural_networks::initializers::interface1::Result
Provides methods to access the result obtained with the compute() method of the neural network weight...
Definition: initializer_types.h:143
daal::algorithms::neural_networks::initializers::interface1::Input::Input
Input()
Definition: initializer_types.h:103
daal::algorithms::neural_networks::initializers::interface1::Input::Input
Input(const Input &other)
Definition: initializer_types.h:105
daal::algorithms::neural_networks::initializers::interface1::Result::set
void set(ResultId id, const data_management::TensorPtr &ptr)
Definition: initializer_types.h:183
daal::algorithms::neural_networks::initializers::interface1::Parameter
Definition: initializer_types.h:83
daal::algorithms::neural_networks::initializers::interface1::Parameter::engine
engines::EnginePtr engine
Definition: initializer_types.h:90
daal::algorithms::neural_networks::initializers::interface1::Input::set
void set(InputId id, const data_management::TensorPtr &ptr)
Definition: initializer_types.h:124
daal::algorithms::neural_networks::initializers::interface1::Input::get
data_management::TensorPtr get(InputId id) const
Definition: initializer_types.h:114

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