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

layer_forward_types.h
1 /* file: layer_forward_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 __LAYERS__FORWARD__TYPES__H__
25 #define __LAYERS__FORWARD__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/layers/layer_types.h"
33 
34 namespace daal
35 {
36 namespace algorithms
37 {
41 namespace neural_networks
42 {
46 namespace layers
47 {
57 namespace forward
58 {
63 enum InputId
64 {
65  data,
66  weights, /* Weights of the neural network layer */
67  biases, /* Biases of the neural network layer */
68  lastInputId = biases
69 };
70 
75 enum InputLayerDataId
76 {
77  inputLayerData = lastInputId + 1,
78  lastInputLayerDataId = inputLayerData
79 };
80 
85 enum ResultId
86 {
87  value,
88  lastResultId = value
89 };
90 
95 enum ResultLayerDataId
96 {
97  resultForBackward = lastResultId + 1,
98  lastResultLayerDataId = resultForBackward
99 };
100 
104 namespace interface1
105 {
111 class DAAL_EXPORT InputIface : public daal::algorithms::Input
112 {
113 public:
118  DAAL_DEPRECATED InputIface(size_t nElements) : daal::algorithms::Input(nElements) {}
119  /*
120  * \DAAL_DEPRECATED
121  */
122  DAAL_DEPRECATED InputIface(const InputIface& other);
123  /*
124  * \DAAL_DEPRECATED
125  */
126  virtual ~InputIface() {}
127 };
128 
134 class DAAL_EXPORT Input : public InputIface
135 {
136 public:
142  DAAL_DEPRECATED Input(size_t nElements = lastInputLayerDataId + 1);
143  /*
144  * \DAAL_DEPRECATED
145  */
146  DAAL_DEPRECATED Input(const Input& other);
147 
148  /*
149  * \DAAL_DEPRECATED
150  */
151  virtual ~Input() {}
152 
159  data_management::TensorPtr get(forward::InputId id) const;
160 
167  void set(InputId id, const data_management::TensorPtr &ptr);
168 
175  DAAL_DEPRECATED LayerDataPtr get(forward::InputLayerDataId id) const;
176 
183  DAAL_DEPRECATED void set(InputLayerDataId id, const LayerDataPtr &ptr);
184 
193  services::Status check(const daal::algorithms::Parameter *par, int method) const DAAL_C11_OVERRIDE;
194 
200  DAAL_DEPRECATED_VIRTUAL virtual LayerInputLayout getLayout();
201 
207  virtual const services::Collection<size_t> getWeightsSizes(const layers::Parameter *parameter) const;
208 
214  virtual const services::Collection<size_t> getBiasesSizes(const layers::Parameter *parameter) const;
215 
224  DAAL_DEPRECATED_VIRTUAL virtual services::Status addData(const data_management::TensorPtr &dataTensor, size_t index);
225 
232  DAAL_DEPRECATED_VIRTUAL virtual services::Status eraseInputData()
233  {
234  set(layers::forward::data, data_management::TensorPtr());
235  return services::Status();
236  }
237 };
238 
244 class DAAL_EXPORT Result : public daal::algorithms::Result
245 {
246  DECLARE_SERIALIZABLE_IMPL();
247 public:
248  DAAL_CAST_OPERATOR(Result);
253  DAAL_DEPRECATED Result();
254 
255  /*
256  * \DAAL_DEPRECATED
257  */
258  virtual ~Result() {};
259 
269  template <typename algorithmFPType>
270  services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *par, const int method)
271  {
272  return services::Status();
273  }
274 
283  DAAL_DEPRECATED_VIRTUAL virtual const services::Collection<size_t> getValueSize(const services::Collection<size_t> &inputSize,
284  const daal::algorithms::Parameter *par, const int method) const = 0;
285 
294  DAAL_DEPRECATED_VIRTUAL virtual services::Collection<size_t> getValueSize(const services::Collection< services::Collection<size_t> > &inputSize,
295  const daal::algorithms::Parameter *par, const int method);
296 
305  DAAL_DEPRECATED_VIRTUAL virtual services::Collection< services::Collection<size_t> > getValueCollectionSize(const services::Collection<size_t> &inputSize,
306  const daal::algorithms::Parameter *par, const int method);
307 
314  DAAL_DEPRECATED data_management::TensorPtr get(ResultId id) const;
315 
322  DAAL_DEPRECATED LayerDataPtr get(ResultLayerDataId id) const;
323 
330  DAAL_DEPRECATED void set(ResultId id, const data_management::TensorPtr &ptr);
331 
338  DAAL_DEPRECATED void set(ResultLayerDataId id, const LayerDataPtr &ptr);
339 
344  int getSerializationTag() const DAAL_C11_OVERRIDE { return SERIALIZATION_NEURAL_NETWORKS_LAYERS_FORWARD_RESULT_ID; }
345 
355  DAAL_DEPRECATED_VIRTUAL virtual services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
356  int method) const DAAL_C11_OVERRIDE;
357 
363  DAAL_DEPRECATED_VIRTUAL virtual LayerResultLayout getLayout();
364 
372  DAAL_DEPRECATED_VIRTUAL virtual services::Status setResultForBackward(const daal::algorithms::Input *input)
373  {
374  return services::Status();
375  }
376 
383  DAAL_DEPRECATED_VIRTUAL virtual data_management::TensorPtr getValue(size_t index) const;
384 
385 protected:
390  template<typename Archive, bool onDeserialize>
391  services::Status serialImpl(Archive *arch)
392  {
393  return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
394  }
395 };
396 typedef services::SharedPtr<Result> ResultPtr;
397 } // interface1
398 using interface1::InputIface;
399 using interface1::Input;
400 using interface1::Result;
401 using interface1::ResultPtr;
402 } // forward
404 } // namespace layer
405 } // namespace neural_networks
406 } // namespace algorithm
407 } // namespace daal
408 #endif
daal::algorithms::neural_networks::layers::forward::interface1::InputIface::InputIface
DAAL_DEPRECATED InputIface(size_t nElements)
Constructor.
Definition: layer_forward_types.h:118
daal::algorithms::neural_networks::layers::forward::interface1::Result
Provides methods to access the result obtained with the compute() method of the layer algorithm...
Definition: layer_forward_types.h:244
daal::algorithms::neural_networks::layers::forward::resultForBackward
Definition: layer_forward_types.h:97
daal::algorithms::neural_networks::layers::forward::data
Definition: layer_forward_types.h:65
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::layers::forward::ResultLayerDataId
ResultLayerDataId
Definition: layer_forward_types.h:95
daal::algorithms::neural_networks::layers::forward::interface1::Result::allocate
services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *par, const int method)
Definition: layer_forward_types.h:270
daal::algorithms::neural_networks::layers::LayerInputLayout
LayerInputLayout
Definition: layer_types.h:59
daal::algorithms::neural_networks::layers::forward::interface1::InputIface
Abstract class that specifies interface of the input objects for the neural network layer...
Definition: layer_forward_types.h:111
daal_defines.h
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::layers::forward::interface1::Input::eraseInputData
virtual DAAL_DEPRECATED_VIRTUAL services::Status eraseInputData()
Definition: layer_forward_types.h:232
daal::algorithms::neural_networks::layers::forward::InputLayerDataId
InputLayerDataId
Definition: layer_forward_types.h:75
daal::algorithms::neural_networks::layers::forward::InputId
InputId
Definition: layer_forward_types.h:63
daal::algorithms::neural_networks::layers::forward::ResultId
ResultId
Definition: layer_forward_types.h:85
daal::algorithms::neural_networks::layers::forward::interface1::Input
Input objects for layer algorithm
Definition: layer_forward_types.h:134
daal::algorithms::neural_networks::layers::forward::interface1::Result::getSerializationTag
int getSerializationTag() const DAAL_C11_OVERRIDE
Definition: layer_forward_types.h:344
daal::algorithms::neural_networks::layers::forward::value
Definition: layer_forward_types.h:87
daal::algorithms::neural_networks::layers::LayerResultLayout
LayerResultLayout
Definition: layer_types.h:70
daal::algorithms::neural_networks::layers::forward::interface1::Result::setResultForBackward
virtual DAAL_DEPRECATED_VIRTUAL services::Status setResultForBackward(const daal::algorithms::Input *input)
Definition: layer_forward_types.h:372

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