PetaVision  Alpha
CudaPoolingDeliverKernel.hpp
1 /*
2  * CudaPoolingRecvPost.hpp
3  *
4  * Created on: Aug 2, 2016
5  * Author: pschultz
6  */
7 
8 #ifndef CUDAPOOLINGDELIVERKERNEL_HPP_
9 #define CUDAPOOLINGDELIVERKERNEL_HPP_
10 
11 #include "arch/cuda/CudaKernel.hpp"
12 #include "include/PVLayerLoc.h"
13 
14 namespace PVCuda {
15 
16 class CudaPoolingDeliverKernel : public CudaKernel {
17  struct Params {
18  PVLayerLoc const *preLoc;
19  PVLayerLoc const *postLoc;
20  int diffX;
21  int diffY;
22  cudnnPoolingMode_t poolingMode;
23  float multiplier;
24  void *poolingDescriptor;
25  void *dataStoreDescriptor;
26  float *dataStore;
27  void *gSynDescriptor;
28  float *gSyn;
29  };
30 
31  public:
32  CudaPoolingDeliverKernel(CudaDevice *inDevice);
33  virtual ~CudaPoolingDeliverKernel();
34  void setArgs(
35  PVLayerLoc const *preLoc,
36  PVLayerLoc const *postLoc,
37  int nxpPost,
38  int nypPost,
39  cudnnPoolingMode_t poolingMode,
40  int multiplier,
41  CudaBuffer *inputBuffer,
42  CudaBuffer *outputBuffer,
43  int channel);
44  static int calcStride(int preRestricted, int postRestricted);
45 
46  protected:
47  virtual int do_run() override;
48  int calcBorderExcess(
49  int preRestricted,
50  int postRestricted,
51  int border,
52  int patchSizePostPerspective);
53  int calcManyScale(int preRestricted, int postRestricted);
54 
55  protected:
56  PVLayerLoc const *mPreLoc = nullptr;
57  PVLayerLoc const *mPostLoc = nullptr;
58  int mBorderExcessX = 0;
59  int mBorderExcessY = 0;
60  cudnnPoolingMode_t mPoolingMode = CUDNN_POOLING_MAX;
61  float mMultiplier = 1.0f;
62  cudnnPoolingDescriptor_t mPoolingDescriptor = nullptr;
63  cudnnTensorDescriptor_t mDataStoreDescriptor = nullptr;
64  float *mDataStore = nullptr;
65  CudaBuffer *mCudnnDataStore = nullptr;
66 
67  cudnnTensorDescriptor_t mGSynDescriptor = nullptr;
68  float *mGSyn = nullptr;
69  CudaBuffer *mCudnnGSyn = nullptr;
70 };
71 
72 } /* namespace PVCuda */
73 
74 #endif /* CUDAPOOLINGDELIVERKERNEL_HPP_ */