PetaVision  Alpha
L0NormLCAProbe.cpp
1 /*
2  * L0NormLCAProbe.cpp
3  *
4  * Created on: Oct 9, 2015
5  * Author: pschultz
6  */
7 
8 #include "L0NormLCAProbe.hpp"
9 #include "../layers/HyPerLCALayer.hpp"
10 
11 namespace PV {
12 
13 L0NormLCAProbe::L0NormLCAProbe(const char *name, HyPerCol *hc) {
14  initialize_base();
15  initialize(name, hc);
16 }
17 
18 L0NormLCAProbe::L0NormLCAProbe() { initialize_base(); }
19 
20 Response::Status
21 L0NormLCAProbe::communicateInitInfo(std::shared_ptr<CommunicateInitInfoMessage const> message) {
22  auto status = L0NormProbe::communicateInitInfo(message);
23  if (!Response::completed(status)) {
24  return status;
25  }
26  assert(targetLayer);
27  HyPerLCALayer *targetLCALayer = dynamic_cast<HyPerLCALayer *>(targetLayer);
28  if (targetLCALayer == NULL) {
29  if (parent->columnId() == 0) {
30  ErrorLog().printf(
31  "%s: targetLayer \"%s\" is not an LCA layer.\n",
32  getDescription_c(),
33  getTargetName());
34  }
35  MPI_Barrier(parent->getCommunicator()->communicator());
36  exit(EXIT_FAILURE);
37  }
38  if (targetLCALayer->layerListsVerticesInParams() == true) {
39  if (parent->columnId() == 0) {
40  ErrorLog().printf(
41  "%s: LCAProbes require targetLayer \"%s\" to use "
42  "VThresh etc. instead of "
43  "verticesV/verticesV.\n",
44  getDescription_c(),
45  getTargetName());
46  }
47  MPI_Barrier(parent->getCommunicator()->communicator());
48  exit(EXIT_FAILURE);
49  }
50  float vThresh = targetLCALayer->getVThresh();
51  coefficient = vThresh * vThresh / 2.0f;
52  return Response::SUCCESS;
53 }
54 
55 } /* namespace PV */
bool layerListsVerticesInParams() const
Definition: ANNLayer.hpp:30
virtual Response::Status communicateInitInfo(std::shared_ptr< CommunicateInitInfoMessage const > message) override
const char * getTargetName()
Definition: BaseProbe.hpp:83
virtual Response::Status communicateInitInfo(std::shared_ptr< CommunicateInitInfoMessage const > message) override
static bool completed(Status &a)
Definition: Response.hpp:49