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

layer_backward_types.h
1 /* file: layer_backward_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__BACKWARD__TYPES__H__
49 #define __LAYERS__BACKWARD__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 #include "algorithms/neural_networks/layers/layer_forward_types.h"
58 
59 namespace daal
60 {
61 namespace algorithms
62 {
66 namespace neural_networks
67 {
71 namespace layers
72 {
82 namespace backward
83 {
88 enum InputId
89 {
90  inputGradient,
91  lastInputId = inputGradient
92 };
93 
98 enum InputLayerDataId
99 {
100  inputFromForward = lastInputId + 1,
101  lastInputLayerDataId = inputFromForward
102 };
103 
108 enum ResultId
109 {
110  gradient,
111  weightDerivatives,
112  biasDerivatives,
113  lastResultId = biasDerivatives
114 };
115 
120 enum ResultLayerDataId
121 {
122  resultLayerData = lastResultId + 1,
123  lastResultLayerDataId = resultLayerData
124 };
125 
129 namespace interface1
130 {
135 class DAAL_EXPORT InputIface : public daal::algorithms::Input
136 {
137 public:
141  InputIface(size_t nElements) : daal::algorithms::Input(nElements) {}
142  InputIface(const InputIface& other);
143  virtual ~InputIface() {}
144 };
145 
150 class DAAL_EXPORT Input : public InputIface
151 {
152 public:
154  Input();
155  Input(const Input& other);
156 
157  virtual ~Input() {}
158 
164  data_management::TensorPtr get(InputId id) const;
165 
171  LayerDataPtr get(InputLayerDataId id) const;
172 
178  void set(InputId id, const data_management::TensorPtr &ptr);
179 
185  void set(InputLayerDataId id, const LayerDataPtr &ptr);
186 
194  virtual services::Status addInputGradient(const data_management::TensorPtr &igTensor, size_t index);
195 
202  virtual services::Status setInputFromForward(forward::ResultPtr result);
203 
211  services::Status check(const daal::algorithms::Parameter *par, int method) const DAAL_C11_OVERRIDE;
212 
217  virtual LayerInputLayout getLayout() const;
218 };
219 
224 class DAAL_EXPORT Result : public daal::algorithms::Result
225 {
226  DECLARE_SERIALIZABLE_IMPL();
227 public:
228  DAAL_CAST_OPERATOR(Result);
230  Result();
231 
232  virtual ~Result() {};
233 
242  template <typename algorithmFPType>
243  services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *par, const int method)
244  {
245  return services::Status();
246  }
247 
253  data_management::TensorPtr get(ResultId id) const;
254 
260  void set(ResultId id, const data_management::TensorPtr &ptr);
261 
267  LayerDataPtr get(backward::ResultLayerDataId id) const;
268 
274  void set(ResultLayerDataId id, const LayerDataPtr &ptr);
275 
279  int getSerializationTag() const DAAL_C11_OVERRIDE { return SERIALIZATION_NEURAL_NETWORKS_LAYERS_BACKWARD_RESULT_ID; }
280 
289  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter,
290  int method) const DAAL_C11_OVERRIDE;
291 
296  virtual LayerResultLayout getLayout() const;
297 
303  virtual data_management::TensorPtr getGradient(size_t index) const;
304 protected:
306  template<typename Archive, bool onDeserialize>
307  services::Status serialImpl(Archive *arch)
308  {
309  return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
310  }
311 };
312 typedef services::SharedPtr<Result> ResultPtr;
313 } // namespace interface1
314 using interface1::InputIface;
315 using interface1::Input;
316 using interface1::Result;
317 using interface1::ResultPtr;
318 } // backward
319 
321 } // namespace layer
322 } // namespace neural_networks
323 } // namespace algorithm
324 } // namespace daal
325 #endif
daal::algorithms::neural_networks::layers::backward::weightDerivatives
Definition: layer_backward_types.h:111
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::backward::gradient
Definition: layer_backward_types.h:110
daal::algorithms::neural_networks::layers::backward::InputId
InputId
Definition: layer_backward_types.h:88
daal::algorithms::neural_networks::layers::backward::inputFromForward
Definition: layer_backward_types.h:100
daal::algorithms::neural_networks::layers::backward::biasDerivatives
Definition: layer_backward_types.h:112
daal_defines.h
daal::algorithms::neural_networks::layers::backward::InputLayerDataId
InputLayerDataId
Definition: layer_backward_types.h:98
daal::algorithms::neural_networks::layers::backward::interface1::Result::allocate
services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *par, const int method)
Definition: layer_backward_types.h:243
daal::algorithms::neural_networks::layers::LayerInputLayout
LayerInputLayout
Definition: layer_types.h:83
daal::algorithms::neural_networks::layers::backward::ResultLayerDataId
ResultLayerDataId
Definition: layer_backward_types.h:120
daal::algorithms::neural_networks::layers::backward::interface1::InputIface
Abstract class that specifies interface of the input objects for the neural network layer algorithm...
Definition: layer_backward_types.h:135
daal::algorithms::neural_networks::layers::backward::inputGradient
Definition: layer_backward_types.h:90
daal::algorithms::neural_networks::layers::LayerResultLayout
LayerResultLayout
Definition: layer_types.h:94
daal::algorithms::neural_networks::layers::backward::interface1::Result
Provides methods to access the result obtained with the compute() method of the layer algorithm...
Definition: layer_backward_types.h:224
daal::algorithms::neural_networks::layers::backward::ResultId
ResultId
Definition: layer_backward_types.h:108
daal::algorithms::neural_networks::layers::backward::interface1::InputIface::InputIface
InputIface(size_t nElements)
Constructor.
Definition: layer_backward_types.h:141
daal::algorithms::neural_networks::layers::backward::interface1::Result::getSerializationTag
int getSerializationTag() const DAAL_C11_OVERRIDE
Definition: layer_backward_types.h:279
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::backward::interface1::Input
Input parameters for the layer algorithm
Definition: layer_backward_types.h:150

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