PetaVision  Alpha
PtwiseProductLayer.cpp
1 /*
2  * PtwiseProductLayer.cpp
3  *
4  * The output V is the pointwise product of GSynExc and 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 on: Apr 25, 2011
10  * Author: peteschultz
11  */
12 
13 #include "PtwiseProductLayer.hpp"
14 
15 namespace PV {
16 
17 PtwiseProductLayer::PtwiseProductLayer() { initialize_base(); }
18 
19 PtwiseProductLayer::PtwiseProductLayer(const char *name, HyPerCol *hc) {
20  initialize_base();
21  initialize(name, hc);
22 } // end PtwiseProductLayer::PtwiseProductLayer(const char *, HyPerCol *)
23 
24 PtwiseProductLayer::~PtwiseProductLayer() {}
25 
26 int PtwiseProductLayer::initialize_base() {
27  numChannels = 2;
28  return PV_SUCCESS;
29 }
30 
31 int PtwiseProductLayer::initialize(const char *name, HyPerCol *hc) {
32  return ANNLayer::initialize(name, hc);
33 }
34 
35 Response::Status PtwiseProductLayer::allocateDataStructures() {
36  auto status = ANNLayer::allocateDataStructures();
37  pvAssert(numChannels >= 2);
38  return status;
39 }
40 
41 Response::Status PtwiseProductLayer::updateState(double timef, double dt) {
42  const PVLayerLoc *loc = getLayerLoc();
43  float *A = clayer->activity->data;
44  float *V = getV();
45  int num_channels = getNumChannels();
46  float *gSynHead = GSyn == NULL ? NULL : GSyn[0];
47  int nx = loc->nx;
48  int ny = loc->ny;
49  int nf = loc->nf;
50  int num_neurons = nx * ny * nf;
51  int nbatch = loc->nbatch;
52  updateV_PtwiseProductLayer(nbatch, num_neurons, V, gSynHead);
53  setActivity_HyPerLayer(
54  nbatch,
55  num_neurons,
56  A,
57  V,
58  nx,
59  ny,
60  nf,
61  loc->halo.lt,
62  loc->halo.rt,
63  loc->halo.dn,
64  loc->halo.up);
65  return Response::SUCCESS;
66 }
67 
68 } // end namespace PV