PetaVision  Alpha
ANNSquaredLayer.cpp
1 /*
2  * ANNSquaredLayer.cpp
3  *
4  * Created on: Sep 21, 2011
5  * Author: kpeterson
6  */
7 
8 #include "ANNSquaredLayer.hpp"
9 
10 void ANNSquaredLayer_update_state(
11  const int nbatch,
12  const int numNeurons,
13  const int nx,
14  const int ny,
15  const int nf,
16  const int lt,
17  const int rt,
18  const int dn,
19  const int up,
20 
21  float *V,
22  float *GSynHead,
23  float *activity);
24 
25 namespace PV {
26 
27 ANNSquaredLayer::ANNSquaredLayer() { initialize_base(); }
28 
29 ANNSquaredLayer::ANNSquaredLayer(const char *name, HyPerCol *hc) {
30  initialize_base();
31  initialize(name, hc);
32 }
33 
34 ANNSquaredLayer::~ANNSquaredLayer() {}
35 
36 int ANNSquaredLayer::initialize_base() {
37  numChannels = 1; // ANNSquaredLayer only takes input on the excitatory channel
38  return PV_SUCCESS;
39 }
40 
41 int ANNSquaredLayer::initialize(const char *name, HyPerCol *hc) {
42  int status = ANNLayer::initialize(name, hc);
43  assert(numChannels == 1);
44  return status;
45 }
46 
47 Response::Status ANNSquaredLayer::updateState(double time, double dt) {
48  const int nx = clayer->loc.nx;
49  const int ny = clayer->loc.ny;
50  const int nf = clayer->loc.nf;
51  const int nbatch = clayer->loc.nbatch;
52 
53  float *GSynHead = GSyn[0];
54  float *V = getV();
55  float *activity = clayer->activity->data;
56 
57  ANNSquaredLayer_update_state(
58  nbatch,
59  getNumNeurons(),
60  nx,
61  ny,
62  nf,
63  clayer->loc.halo.lt,
64  clayer->loc.halo.rt,
65  clayer->loc.halo.dn,
66  clayer->loc.halo.up,
67  V,
68  GSynHead,
69  activity);
70  return Response::SUCCESS;
71 }
72 
73 } /* namespace PV */
74 
76 //
77 // implementation of ANNLayer kernels
78 
79 void ANNSquaredLayer_update_state(
80  const int nbatch,
81  const int numNeurons,
82  const int nx,
83  const int ny,
84  const int nf,
85  const int lt,
86  const int rt,
87  const int dn,
88  const int up,
89 
90  float *V,
91  float *GSynHead,
92  float *activity) {
93 
94  updateV_ANNSquaredLayer(nbatch, numNeurons, V, GSynHead);
95  setActivity_HyPerLayer(nbatch, numNeurons, activity, V, nx, ny, nf, lt, rt, dn, up);
96 }