PetaVision  Alpha
CudaTransposePoolingDeliverKernel.hpp
1 /*
2  * CudaTransposePoolingDeliverKernel.hpp
3  *
4  * Created on: Aug 16, 2016
5  * Author: pschultz
6  */
7 
8 #ifndef CUDATRANSPOSEPOOLINGDELIVERKERNEL_HPP_
9 #define CUDATRANSPOSEPOOLINGDELIVERKERNEL_HPP_
10 
11 #include <cudakernels/CudaPoolingDeliverKernel.hpp>
12 
13 namespace PVCuda {
14 
15 class CudaTransposePoolingDeliverKernel : public CudaKernel {
16  public:
17  CudaTransposePoolingDeliverKernel(CudaDevice *inDevice);
19  void setArgs(
20  PVLayerLoc const *preLoc,
21  PVLayerLoc const *postLoc,
22  PVLayerLoc const *origConnPreLoc,
23  PVLayerLoc const *origConnPostLoc,
24  int nxpPost,
25  int nypPost,
26  cudnnPoolingMode_t poolingMode,
27  int multiplier,
28  CudaBuffer *dataStoreBuffer,
29  CudaBuffer *gSynBuffer,
30  CudaBuffer *origConnDataStoreBuffer,
31  CudaBuffer *origConnGSynBuffer,
32  int channel);
33 
34  protected:
35  virtual int do_run() override;
36  int calcBorderExcess(
37  int preRestricted,
38  int postRestricted,
39  int border,
40  int patchSizePostPerspective);
41  int calcManyScale(int preRestricted, int postRestricted);
42  int calcStride(int preRestricted, int postRestricted);
43 
44  // Data members
45  protected:
46  PVLayerLoc const *mPreLoc = nullptr;
47  PVLayerLoc const *mPostLoc = nullptr;
48  int mBorderExcessX = 0;
49  int mBorderExcessY = 0;
50  cudnnPoolingMode_t mPoolingMode = CUDNN_POOLING_MAX;
51  float mMultiplier = 1.0f;
52  cudnnPoolingDescriptor_t mPoolingDescriptor = nullptr;
53  cudnnTensorDescriptor_t mDataStoreDescriptor = nullptr;
54  float *mDataStore = nullptr;
55  CudaBuffer *mCudnnDataStore = nullptr;
56 
57  cudnnTensorDescriptor_t mGSynDescriptor = nullptr;
58  float *mGSyn = nullptr;
59  CudaBuffer *mCudnnGSyn = nullptr;
60 
61  PVLayerLoc const *mOrigConnPreLoc = nullptr;
62  PVLayerLoc const *mOrigConnPostLoc = nullptr;
63  int mOrigConnBorderExcessX = 0;
64  int mOrigConnBorderExcessY = 0;
65 
66  cudnnTensorDescriptor_t mOrigConnDataStoreDescriptor = nullptr;
67  float *mOrigConnDataStore = nullptr;
68  CudaBuffer *mCudnnOrigConnDataStore = nullptr;
69 
70  cudnnTensorDescriptor_t mOrigConnGSynDescriptor = nullptr;
71  float *mOrigConnGSyn = nullptr;
72  CudaBuffer *mCudnnOrigConnGSyn = nullptr;
73 }; // class CudaTransposePoolingDeliverKernel
74 
75 } /* namespace PVCuda */
76 
77 #endif /* CUDATRANSPOSEPOOLINGDELIVERKERNEL_HPP_ */