PetaVision  Alpha
TransposePoolingDelivery.hpp
1 /*
2  * TransposePoolingDelivery.hpp
3  *
4  * Created on: Jan 9, 2018
5  * Author: Pete Schultz
6  */
7 
8 #ifndef TRANSPOSEPOOLINGDELIVERY_HPP_
9 #define TRANSPOSEPOOLINGDELIVERY_HPP_
10 
11 #include "components/DependentPatchSize.hpp"
12 #include "components/ImpliedWeightsPair.hpp"
13 #include "delivery/BaseDelivery.hpp"
14 #include "delivery/PoolingDelivery.hpp"
15 #include "layers/PoolingIndexLayer.hpp"
16 #ifdef PV_USE_CUDA
17 #include "cudakernels/CudaTransposePoolingDeliverKernel.hpp"
18 #endif // PV_USE_CUDA
19 
20 namespace PV {
21 
26  protected:
37  virtual void ioParam_receiveGpu(enum ParamsIOFlag ioFlag) override;
38 
53  virtual void ioParam_updateGSynFromPostPerspective(enum ParamsIOFlag ioFlag);
54 
55  public:
56  TransposePoolingDelivery(char const *name, HyPerCol *hc);
57 
58  virtual ~TransposePoolingDelivery();
59 
60  void setConnectionData(ConnectionData *connectionData);
61 
62  virtual void deliver() override;
63 
64  virtual bool isAllInputReady() override;
65 
66  protected:
68 
69  int initialize(char const *name, HyPerCol *hc);
70 
71  virtual void setObjectType() override;
72 
73  virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override;
74 
75  virtual Response::Status
76  communicateInitInfo(std::shared_ptr<CommunicateInitInfoMessage const> message) override;
77 
78 #ifdef PV_USE_CUDA
79  virtual Response::Status
80  setCudaDevice(std::shared_ptr<SetCudaDeviceMessage const> message) override;
81 #endif // PV_USE_CUDA
82 
83  virtual Response::Status allocateDataStructures() override;
84 
85 #ifdef PV_USE_CUDA
86  void initializeDeliverKernelArgs();
87 #endif // PV_USE_CUDA
88 
89  void allocateThreadGSyn();
90 
91  void deliverPostsynapticPerspective();
92 
93  void deliverPresynapticPerspective();
94 
95 #ifdef PV_USE_CUDA
96  void deliverGPU();
97 #endif // PV_USE_CUDA
98 
99  // Data members
100  protected:
101  PoolingDelivery::AccumulateType mAccumulateType = PoolingDelivery::UNDEFINED;
102  bool mUpdateGSynFromPostPerspective = false;
103 
104  DependentPatchSize *mPatchSize = nullptr;
105  ImpliedWeightsPair *mWeightsPair = nullptr;
106  PoolingIndexLayer *mOriginalPostIndexLayer = nullptr; // Used by deliverPresynapticPerspective
107  HyPerLayer *mOriginalPreLayer = nullptr; // Used by deliverGPU
108  HyPerLayer *mOriginalPostLayer = nullptr; // Used by deliverGPU
109 
110 #ifdef PV_USE_CUDA
111  PVCuda::CudaTransposePoolingDeliverKernel *mDeliverKernel = nullptr;
112 #endif // PV_USE_CUDA
113 
114  std::vector<std::vector<float>> mThreadGSyn;
115 
116 }; // end class TransposePoolingDelivery
117 
118 } // end namespace PV
119 
120 #endif // TRANSPOSEPOOLINGDELIVERY_HPP_
virtual void ioParam_updateGSynFromPostPerspective(enum ParamsIOFlag ioFlag)
updateGSynFromPostPerspective: Specifies if the connection should push from pre or pull from post...
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
virtual void ioParam_receiveGpu(enum ParamsIOFlag ioFlag) override