8 #include "RescaleDelivery.hpp" 9 #include "columns/HyPerCol.hpp" 13 RescaleDelivery::RescaleDelivery(
char const *name, HyPerCol *hc) { initialize(name, hc); }
15 int RescaleDelivery::initialize(
char const *name, HyPerCol *hc) {
16 return IdentDelivery::initialize(name, hc);
19 void RescaleDelivery::setObjectType() { mObjectType =
"RescaleDelivery"; }
28 parent->parameters()->ioParamValue(
29 ioFlag, name,
"scale", &mScale, mScale ,
true );
37 void RescaleDelivery::deliver() {
38 if (mChannelCode == CHANNEL_NOUPDATE) {
42 int delay = mSingleArbor->getDelay(0);
44 PVLayerLoc const &preLoc = preActivityCube.loc;
45 PVLayerLoc const &postLoc = *mPostLayer->getLayerLoc();
47 int const nx = preLoc.nx;
48 int const ny = preLoc.ny;
49 int const nf = preLoc.nf;
50 int nxPreExtended = nx + preLoc.halo.lt + preLoc.halo.rt;
51 int nyPreExtended = ny + preLoc.halo.dn + preLoc.halo.up;
52 int numPreExtended = nxPreExtended * nyPreExtended * nf;
53 pvAssert(numPreExtended * preLoc.nbatch == preActivityCube.numItems);
54 int numPostRestricted = nx * ny * nf;
56 float *postChannel = mPostLayer->getChannel(mChannelCode);
57 for (
int b = 0; b < parent->getNBatch(); b++) {
58 float const *preActivityBuffer = preActivityCube.data + b * numPreExtended;
59 float *postGSynBuffer = postChannel + b * numPostRestricted;
60 if (preActivityCube.isSparse) {
63 int numActive = preActivityCube.numActive[b];
64 #ifdef PV_USE_OPENMP_THREADS
65 #pragma omp parallel
for 67 for (
int loopIndex = 0; loopIndex < numActive; loopIndex++) {
68 int kPre = activeIndices[loopIndex].index;
69 int kx = kxPos(kPre, nxPreExtended, nyPreExtended, nf) - preLoc.halo.lt;
70 int ky = kyPos(kPre, nxPreExtended, nyPreExtended, nf) - preLoc.halo.up;
71 if (kx < 0 or kx >= nx or ky < 0 or ky >= ny) {
74 int kf = featureIndex(kPre, nxPreExtended, nyPreExtended, nf);
75 int kPost = kIndex(kx, ky, kf, nx, ny, nf);
76 pvAssert(kPost >= 0 and kPost < numPostRestricted);
77 float a = activeIndices[loopIndex].value;
78 postGSynBuffer[kPost] += mScale * a;
82 int const nk = postLoc.nx * postLoc.nf;
83 #ifdef PV_USE_OPENMP_THREADS 84 #pragma omp parallel for 86 for (
int y = 0; y < ny; y++) {
88 kIndex(preLoc.halo.lt, y + preLoc.halo.up, 0, nxPreExtended, nyPreExtended, nf);
90 float const *preActivityLine = &preActivityBuffer[preLineIndex];
91 int postLineIndex = kIndex(0, y, 0, postLoc.nx, ny, postLoc.nf);
92 float *postGSynLine = &postGSynBuffer[postLineIndex];
93 for (
int k = 0; k < nk; k++) {
94 postGSynLine[k] += mScale * preActivityLine[k];
100 mPostLayer->setUpdatedDeviceGSynFlag(!mReceiveGpu);
101 #endif // PV_USE_CUDA 104 void RescaleDelivery::deliverUnitInput(
float *recvBuffer) {
105 const int numNeuronsPost = mPostLayer->getNumNeuronsAllBatches();
106 #ifdef PV_USE_OPENMP_THREADS 107 #pragma omp parallel for 109 for (
int k = 0; k < numNeuronsPost; k++) {
110 recvBuffer[k] += mScale;
void ioParam_scale(enum ParamsIOFlag ioFlag)
PVLayerCube createCube(int delay=0)
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override