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

layer_forward_types.h
1 /* file: layer_forward_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 neural_networks Network layer.
45 //--
46 */
47 
48 #ifndef __LAYERS__FORWARD__TYPES__H__
49 #define __LAYERS__FORWARD__TYPES__H__
50 
51 #include "algorithms/algorithm.h"
52 #include "data_management/data/tensor.h"
53 #include "services/daal_defines.h"
54 #include "services/collection.h"
55 #include "data_management/data/data_collection.h"
56 #include "algorithms/neural_networks/layers/layer_types.h"
57 
58 namespace daal
59 {
60 namespace algorithms
61 {
65 namespace neural_networks
66 {
70 namespace layers
71 {
81 namespace forward
82 {
87 enum InputId
88 {
89  data,
90  weights, /* Weights of the neural network layer */
91  biases, /* Biases of the neural network layer */
92  lastInputId = biases
93 };
94 
99 enum InputLayerDataId
100 {
101  inputLayerData = lastInputId + 1,
102  lastInputLayerDataId = inputLayerData
103 };
104 
109 enum ResultId
110 {
111  value,
112  lastResultId = value
113 };
114 
119 enum ResultLayerDataId
120 {
121  resultForBackward = lastResultId + 1,
122  lastResultLayerDataId = resultForBackward
123 };
124 
128 namespace interface1
129 {
134 class DAAL_EXPORT InputIface : public daal::algorithms::Input
135 {
136 public:
140  InputIface(size_t nElements) : daal::algorithms::Input(nElements) {}
141  InputIface(const InputIface& other);
142  virtual ~InputIface() {}
143 };
144 
149 class DAAL_EXPORT Input : public InputIface
150 {
151 public:
156  Input(size_t nElements = lastInputLayerDataId + 1);
157  Input(const Input& other);
158 
159  virtual ~Input() {}
160 
166  data_management::TensorPtr get(forward::InputId id) const;
167 
173  void set(InputId id, const data_management::TensorPtr &ptr);
174 
180  LayerDataPtr get(forward::InputLayerDataId id) const;
181 
187  void set(InputLayerDataId id, const LayerDataPtr &ptr);
188 
196  services::Status check(const daal::algorithms::Parameter *par, int method) const DAAL_C11_OVERRIDE;
197 
202  virtual LayerInputLayout getLayout();
203 
208  virtual const services::Collection<size_t> getWeightsSizes(const layers::Parameter *parameter) const;
209 
214  virtual const services::Collection<size_t> getBiasesSizes(const layers::Parameter *parameter) const;
215 
223  virtual services::Status addData(const data_management::TensorPtr &dataTensor, size_t index);
224 
230  virtual services::Status eraseInputData()
231  {
232  set(layers::forward::data, data_management::TensorPtr());
233  return services::Status();
234  }
235 };
236 
241 class DAAL_EXPORT Result : public daal::algorithms::Result
242 {
243  DECLARE_SERIALIZABLE_IMPL();
244 public:
245  DAAL_CAST_OPERATOR(Result);
247  Result();
248 
249  virtual ~Result() {};
250 
259  template <typename algorithmFPType>
260  services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *par, const int method)
261  {
262  return services::Status();
263  }
264 
272  virtual const services::Collection<size_t> getValueSize(const services::Collection<size_t> &inputSize,
273  const daal::algorithms::Parameter *par, const int method) const = 0;
274 
282  virtual services::Collection<size_t> getValueSize(const services::Collection< services::Collection<size_t> > &inputSize,
283  const daal::algorithms::Parameter *par, const int method);
284 
292  virtual services::Collection< services::Collection<size_t> > getValueCollectionSize(const services::Collection<size_t> &inputSize,
293  const daal::algorithms::Parameter *par, const int method);
294 
300  data_management::TensorPtr get(ResultId id) const;
301 
307  LayerDataPtr get(ResultLayerDataId id) const;
308 
314  void set(ResultId id, const data_management::TensorPtr &ptr);
315 
321  void set(ResultLayerDataId id, const LayerDataPtr &ptr);
322 
326  int getSerializationTag() const DAAL_C11_OVERRIDE { return SERIALIZATION_NEURAL_NETWORKS_LAYERS_FORWARD_RESULT_ID; }
327 
336  virtual services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
337  int method) const DAAL_C11_OVERRIDE;
338 
343  virtual LayerResultLayout getLayout();
344 
351  virtual services::Status setResultForBackward(const daal::algorithms::Input *input)
352  {
353  return services::Status();
354  }
355 
361  virtual data_management::TensorPtr getValue(size_t index) const;
362 
363 protected:
365  template<typename Archive, bool onDeserialize>
366  services::Status serialImpl(Archive *arch)
367  {
368  return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
369  }
370 };
371 typedef services::SharedPtr<Result> ResultPtr;
372 } // interface1
373 using interface1::InputIface;
374 using interface1::Input;
375 using interface1::Result;
376 using interface1::ResultPtr;
377 } // forward
379 } // namespace layer
380 } // namespace neural_networks
381 } // namespace algorithm
382 } // namespace daal
383 #endif
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:260
daal::algorithms::neural_networks::layers::forward::InputId
InputId
Definition: layer_forward_types.h:87
daal::algorithms::neural_networks::layers::forward::ResultId
ResultId
Definition: layer_forward_types.h:109
daal
Definition: algorithm_base_common.h:57
daal::algorithms::interface1::Result
Base class to represent final results of the computation. Algorithm-specific final results are repres...
Definition: algorithm_types.h:331
daal::algorithms::neural_networks::layers::forward::ResultLayerDataId
ResultLayerDataId
Definition: layer_forward_types.h:119
daal::algorithms::neural_networks::layers::forward::resultForBackward
Definition: layer_forward_types.h:121
daal_defines.h
daal::algorithms::neural_networks::layers::LayerInputLayout
LayerInputLayout
Definition: layer_types.h:83
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:241
daal::algorithms::neural_networks::layers::forward::interface1::Result::setResultForBackward
virtual services::Status setResultForBackward(const daal::algorithms::Input *input)
Definition: layer_forward_types.h:351
daal::algorithms::neural_networks::layers::forward::value
Definition: layer_forward_types.h:111
daal::algorithms::neural_networks::layers::forward::interface1::Input::eraseInputData
virtual services::Status eraseInputData()
Definition: layer_forward_types.h:230
daal::algorithms::neural_networks::layers::forward::data
Definition: layer_forward_types.h:89
daal::algorithms::neural_networks::layers::LayerResultLayout
LayerResultLayout
Definition: layer_types.h:94
daal::algorithms::neural_networks::layers::forward::interface1::InputIface
Abstract class that specifies interface of the input objects for the neural network layer algorithm...
Definition: layer_forward_types.h:134
daal::algorithms::neural_networks::layers::forward::interface1::Input
Input objects for layer algorithm
Definition: layer_forward_types.h:149
daal::algorithms::neural_networks::layers::forward::interface1::Result::getSerializationTag
int getSerializationTag() const DAAL_C11_OVERRIDE
Definition: layer_forward_types.h:326
daal::algorithms::neural_networks::layers::forward::interface1::InputIface::InputIface
InputIface(size_t nElements)
Constructor.
Definition: layer_forward_types.h:140
daal::algorithms::interface1::Input
Base class to represent computation input arguments. Algorithm-specific input arguments are represent...
Definition: algorithm_types.h:217
daal::algorithms::neural_networks::layers::forward::InputLayerDataId
InputLayerDataId
Definition: layer_forward_types.h:99

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