8 #include "PostsynapticPerspectiveConvolveDelivery.hpp" 9 #include "columns/HyPerCol.hpp" 13 PostsynapticPerspectiveConvolveDelivery::PostsynapticPerspectiveConvolveDelivery(
19 PostsynapticPerspectiveConvolveDelivery::PostsynapticPerspectiveConvolveDelivery() {}
21 PostsynapticPerspectiveConvolveDelivery::~PostsynapticPerspectiveConvolveDelivery() {}
23 int PostsynapticPerspectiveConvolveDelivery::initialize(
char const *name, HyPerCol *hc) {
24 return BaseObject::initialize(name, hc);
27 void PostsynapticPerspectiveConvolveDelivery::setObjectType() {
28 mObjectType =
"PostsynapticPerspectiveConvolveDelivery";
40 Response::Status PostsynapticPerspectiveConvolveDelivery::communicateInitInfo(
41 std::shared_ptr<CommunicateInitInfoMessage const> message) {
42 auto status = HyPerDelivery::communicateInitInfo(message);
49 return Response::POSTPONE;
52 return Response::SUCCESS;
55 Response::Status PostsynapticPerspectiveConvolveDelivery::allocateDataStructures() {
56 auto status = HyPerDelivery::allocateDataStructures();
62 if (getChannelCode() == CHANNEL_NOUPDATE) {
65 float *postChannel = mPostLayer->getChannel(getChannelCode());
66 pvAssert(postChannel);
69 for (
int arbor = 0; arbor < numAxonalArbors; arbor++) {
70 int delay = mArborList->getDelay(arbor);
74 const int numPostRestricted = mPostLayer->getNumNeurons();
76 const PVLayerLoc *sourceLoc = mPreLayer->getLayerLoc();
77 const PVLayerLoc *targetLoc = mPostLayer->getLayerLoc();
79 const int sourceNx = sourceLoc->nx;
80 const int sourceNy = sourceLoc->ny;
81 const int sourceNf = sourceLoc->nf;
82 const int targetNx = targetLoc->nx;
83 const int targetNy = targetLoc->ny;
84 const int targetNf = targetLoc->nf;
85 const int nbatch = targetLoc->nbatch;
87 const PVHalo *sourceHalo = &sourceLoc->halo;
88 const PVHalo *targetHalo = &targetLoc->halo;
91 int sy = (sourceNx + sourceHalo->lt + sourceHalo->rt) * sourceNf;
94 float *gSynPatchHead = mPostLayer->getChannel(getChannelCode());
97 Weights *postWeights = mWeightsPair->getPostWeights();
101 int neuronIndexStride = targetNf < 4 ? 1 : targetNf / 4;
103 for (
int b = 0; b < nbatch; b++) {
104 int sourceNxExt = sourceNx + sourceHalo->rt + sourceHalo->lt;
105 int sourceNyExt = sourceNy + sourceHalo->dn + sourceHalo->up;
106 int sourceNumExtended = sourceNxExt * sourceNyExt * sourceNf;
108 float *activityBatch = activityCube.data + b * sourceNumExtended;
109 float *gSynPatchHeadBatch = gSynPatchHead + b * numPostRestricted;
112 for (
int ky = 0; ky < yPatchSize; ky++) {
115 #ifdef PV_USE_OPENMP_THREADS 116 #pragma omp parallel for schedule(static) 118 for (
int feature = 0; feature < neuronIndexStride; feature++) {
119 for (
int idx = feature; idx < numPostRestricted; idx += neuronIndexStride) {
120 float *gSyn = gSynPatchHeadBatch + idx;
122 int idxExtended = kIndexExtended(
131 int startSourceExt = postWeights->
getGeometry()->getUnshrunkenStart(idxExtended);
132 float *a = activityBatch + startSourceExt + ky * sy;
134 int kTargetExt = kIndexExtended(
144 float *weightValues = weightBuf + ky * syp;
147 for (
int k = 0; k < numPerStride; ++k) {
148 dv += a[k] * weightValues[k];
150 *gSyn += mDeltaTimeFactor * dv;
158 mPostLayer->setUpdatedDeviceGSynFlag(
true);
159 #endif // PV_USE_CUDA 162 void PostsynapticPerspectiveConvolveDelivery::deliverUnitInput(
166 const int numPostRestricted = mPostLayer->getNumNeurons();
168 const PVLayerLoc *targetLoc = mPostLayer->getLayerLoc();
170 const int targetNx = targetLoc->nx;
171 const int targetNy = targetLoc->ny;
172 const int targetNf = targetLoc->nf;
173 const int nbatch = targetLoc->nbatch;
175 const PVHalo *targetHalo = &targetLoc->halo;
178 Weights *postWeights = mWeightsPair->getPostWeights();
182 int neuronIndexStride = targetNf < 4 ? 1 : targetNf / 4;
185 for (
int arbor = 0; arbor < numAxonalArbors; arbor++) {
186 for (
int b = 0; b < nbatch; b++) {
187 float *recvBatch = recvBuffer + b * numPostRestricted;
190 for (
int ky = 0; ky < yPatchSize; ky++) {
193 #ifdef PV_USE_OPENMP_THREADS 194 #pragma omp parallel for schedule(static) 196 for (
int feature = 0; feature < neuronIndexStride; feature++) {
197 for (
int idx = feature; idx < numPostRestricted; idx += neuronIndexStride) {
198 float *recvLocation = recvBatch + idx;
200 int kTargetExt = kIndexExtended(
210 float *weightValues = weightBuf + ky * syp;
213 for (
int k = 0; k < numPerStride; ++k) {
214 dv += weightValues[k];
216 *recvLocation += mDeltaTimeFactor * dv;
int getPatchSizeX() const
PVLayerCube createCube(int delay=0)
static bool completed(Status &a)
int getPatchSizeY() const
std::shared_ptr< PatchGeometry > getGeometry() const
int getPatchStrideY() const
int getNumAxonalArbors() const
float * getDataFromPatchIndex(int arbor, int patchIndex)
virtual void deliver() override
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
virtual void ioParam_receiveGpu(enum ParamsIOFlag ioFlag) override
receiveGpu: PostsynapticPerspectiveConvolveDelivery always sets receiveGpu to false. The receiveGpu=true case is handled by the PostsynapticPerspectiveGPUDelivery class.
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
int getPatchSizeF() const
bool getInitInfoCommunicatedFlag() const