PetaVision  Alpha
PtwiseQuotientLayer.cpp
1 /*
2  * PtwiseQuotientLayer.cpp
3  *
4  * The output V is the pointwise division of GSynExc by GSynInh
5  *
6  * "Exc" and "Inh" are really misnomers for this class, but the
7  * terminology is inherited from the base class.
8  *
9  * created by gkenyon, 06/2016g
10  * based on PtwiseProductLayer Created on: Apr 25, 2011
11  * Author: peteschultz
12  */
13 
14 #include "PtwiseQuotientLayer.hpp"
15 
16 namespace PV {
17 
18 PtwiseQuotientLayer::PtwiseQuotientLayer() { initialize_base(); }
19 
20 PtwiseQuotientLayer::PtwiseQuotientLayer(const char *name, HyPerCol *hc) {
21  initialize_base();
22  initialize(name, hc);
23 } // end PtwiseQuotientLayer::PtwiseQuotientLayer(const char *, HyPerCol *)
24 
25 PtwiseQuotientLayer::~PtwiseQuotientLayer() {}
26 
27 int PtwiseQuotientLayer::initialize_base() {
28  numChannels = 2;
29  return PV_SUCCESS;
30 }
31 
32 int PtwiseQuotientLayer::initialize(const char *name, HyPerCol *hc) {
33  return ANNLayer::initialize(name, hc);
34 }
35 
36 Response::Status PtwiseQuotientLayer::allocateDataStructures() {
37  auto status = ANNLayer::allocateDataStructures();
38  pvAssert(numChannels >= 2);
39  return status;
40 }
41 
42 Response::Status PtwiseQuotientLayer::updateState(double timef, double dt) {
43  doUpdateState(
44  timef, dt, getLayerLoc(), getCLayer()->activity->data, getV(), getNumChannels(), GSyn[0]);
45  return Response::SUCCESS;
46 }
47 
48 void PtwiseQuotientLayer::doUpdateState(
49  double timef,
50  double dt,
51  const PVLayerLoc *loc,
52  float *A,
53  float *V,
54  int num_channels,
55  float *gSynHead) {
56  int nx = loc->nx;
57  int ny = loc->ny;
58  int nf = loc->nf;
59  int num_neurons = nx * ny * nf;
60  int nbatch = loc->nbatch;
61  updateV_PtwiseQuotientLayer(nbatch, num_neurons, V, gSynHead);
62  setActivity_HyPerLayer(
63  nbatch,
64  num_neurons,
65  A,
66  V,
67  nx,
68  ny,
69  nf,
70  loc->halo.lt,
71  loc->halo.rt,
72  loc->halo.dn,
73  loc->halo.up);
74 }
75 
76 } // end namespace PV