Logo ROOT   master
Reference Guide
ContextHandles.h
Go to the documentation of this file.
1 // @(#)root/tmva/tmva/dnn:$Id$
2 // Author: Simon Pfreundschuh 20/06/16
3 
4 /*************************************************************************
5  * Copyright (C) 2016, Simon Pfreundschuh *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /////////////////////////////////////////////////////////////////////
13 // Contains function enums for activation and output functions, as //
14 // well as generic evaluation functions, that delegate the call to //
15 // the corresponding evaluation kernel. //
16 /////////////////////////////////////////////////////////////////////
17 
18 #ifndef TMVA_DNN_CNN_DESCRIPTORS
19 #define TMVA_DNN_CNN_DESCRIPTORS
20 
21 #include <stddef.h>
22 #include <vector>
23 
24 namespace TMVA
25 {
26 namespace DNN
27 {
28 
29 struct TDescriptors {
30  virtual ~TDescriptors() {}
31 };
32 struct TWorkspace {
33  virtual ~TWorkspace() {}
34 };
35 
36 template <typename Layer_t>
38  using HelperDescriptor_t = typename Layer_t::HelperDescriptor_t;
39 
41 };
42 
43 namespace CNN {
44 
45 //______________________________________________________________________________
46 //
47 // Keeps the descriptors for the CNN
48 //______________________________________________________________________________
49 
50 template <typename Layer_t>
52  using LayerDescriptor_t = typename Layer_t::LayerDescriptor_t; // Main layer operation
53  using HelperDescriptor_t = typename Layer_t::HelperDescriptor_t; // Used to define possible helpers for the layers (e.g. activations)
54  using WeightsDescriptor_t = typename Layer_t::WeightsDescriptor_t; // The weights that are modified (e.g filters)
55 
59 };
60 
61 template <typename Layer_t>
63  using AlgorithmForward_t = typename Layer_t::AlgorithmForward_t; // Forward layer operation
64  using AlgorithmBackward_t = typename Layer_t::AlgorithmBackward_t; // Backward layer operation
65  using AlgorithmHelper_t = typename Layer_t::AlgorithmHelper_t; // Used for weight grad backward pass
66 
67  using ReduceTensorDescriptor_t = typename Layer_t::ReduceTensorDescriptor_t;
68 
69  using AlgorithmDataType_t = typename Layer_t::AlgorithmDataType_t;
70 
74 
76 
79  size_t *HelperWorkspace;
80 
81  void *fReductionWorkspace = nullptr;
82 
87 
89 };
90 
91 } // namespace CNN
92 
93 namespace RNN {
94 template <typename Architecture_t>
96 
97  using LayerDescriptor_t = typename Architecture_t::RecurrentDescriptor_t; // Main layer operation
98  using WeightsDescriptor_t = typename Architecture_t::FilterDescriptor_t; // The weights that are modified (e.g filters)
99  using TensorDescriptor_t = typename Architecture_t::TensorDescriptor_t; // the vector of tensor descriptors
100  using HelperDescriptor_t = typename Architecture_t::DropoutDescriptor_t; // use for dropout
101 
106 
107  // for RNN need 4 vectors of tensor descriptors
108 
109  std::vector<TensorDescriptor_t> xDesc;
110  std::vector<TensorDescriptor_t> yDesc;
111  std::vector<TensorDescriptor_t> dxDesc;
112  std::vector<TensorDescriptor_t> dyDesc;
113 };
114 
115 template <typename Layer_t>
117 
118  void *ForwardWorkspace = nullptr;
119  void *HelperWorkspace = nullptr;
120 
121 
124 };
125 
126 } // end namespace RNN
127 
128 
129 } // namespace DNN
130 } // namespace TMVA
131 
132 #endif
typename Layer_t::LayerDescriptor_t LayerDescriptor_t
WeightsDescriptor_t WeightsGradDescriptor
HelperDescriptor_t HelperDescriptor
std::vector< TensorDescriptor_t > dyDesc
WeightsDescriptor_t WeightsDescriptor
WeightsDescriptor_t WeightsDescriptor
typename Layer_t::AlgorithmBackward_t AlgorithmBackward_t
std::vector< TensorDescriptor_t > yDesc
AlgorithmForward_t AlgorithmForward
typename Architecture_t::TensorDescriptor_t TensorDescriptor_t
std::vector< TensorDescriptor_t > xDesc
typename Layer_t::AlgorithmDataType_t AlgorithmDataType_t
HelperDescriptor_t HelperDescriptor
std::vector< TensorDescriptor_t > dxDesc
ReduceTensorDescriptor_t fReduceTensorDesc
LayerDescriptor_t LayerDescriptor
typename Layer_t::HelperDescriptor_t HelperDescriptor_t
HelperDescriptor_t HelperDescriptor
typename Layer_t::ReduceTensorDescriptor_t ReduceTensorDescriptor_t
typename Architecture_t::FilterDescriptor_t WeightsDescriptor_t
typename Layer_t::HelperDescriptor_t HelperDescriptor_t
typename Architecture_t::RecurrentDescriptor_t LayerDescriptor_t
AlgorithmHelper_t HelperAlgorithm
create variable transformations
typename Layer_t::WeightsDescriptor_t WeightsDescriptor_t
AlgorithmDataType_t DataType
AlgorithmBackward_t AlgorithmBackward
typename Architecture_t::DropoutDescriptor_t HelperDescriptor_t
typename Layer_t::AlgorithmForward_t AlgorithmForward_t
typename Layer_t::AlgorithmHelper_t AlgorithmHelper_t