8 #include "InputRegionLayer.hpp" 12 InputRegionLayer::InputRegionLayer(
const char *name, HyPerCol *hc) {
17 InputRegionLayer::InputRegionLayer() {
22 int InputRegionLayer::initialize_base() {
24 originalLayerName =
nullptr;
25 originalLayer =
nullptr;
29 int InputRegionLayer::initialize(
const char *name, HyPerCol *hc) {
36 ioParam_originalLayerName(ioFlag);
40 void InputRegionLayer::ioParam_originalLayerName(
enum ParamsIOFlag ioFlag) {
41 parent->parameters()->ioParamStringRequired(
42 ioFlag, name,
"originalLayerName", &originalLayerName);
46 if (ioFlag == PARAMS_IO_READ) {
49 parent->parameters()->handleUnnecessaryParameter(name,
"phase");
54 if (ioFlag == PARAMS_IO_READ) {
56 parent->parameters()->handleUnnecessaryParameter(name,
"mirrorBCflag");
61 if (ioFlag == PARAMS_IO_READ) {
63 parent->parameters()->handleUnnecessaryParameter(name,
"valueBC");
68 if (ioFlag == PARAMS_IO_READ) {
69 initVTypeString =
nullptr;
70 parent->parameters()->handleUnnecessaryParameter(name,
"InitVType");
75 if (ioFlag == PARAMS_IO_READ) {
76 triggerLayerName =
nullptr;
78 parent->parameters()->handleUnnecessaryParameter(name,
"triggerLayerName");
83 if (ioFlag == PARAMS_IO_READ) {
85 parent->parameters()->handleUnnecessaryParameter(name,
"sparseLayer");
91 if (ioFlag == PARAMS_IO_READ) {
93 parent->parameters()->handleUnnecessaryParameter(name,
"updateGpu");
99 InputRegionLayer::communicateInitInfo(std::shared_ptr<CommunicateInitInfoMessage const> message) {
100 auto status = HyPerLayer::communicateInitInfo(message);
104 setOriginalLayer(message->lookup<
HyPerLayer>(std::string(originalLayerName)));
105 pvAssert(originalLayer);
107 return Response::POSTPONE;
109 phase = originalLayer->getPhase();
110 mirrorBCflag = originalLayer->useMirrorBCs();
111 valueBC = originalLayer->getValueBC();
112 checkLayerDimensions();
113 synchronizeMarginWidth(originalLayer);
114 originalLayer->synchronizeMarginWidth(
this);
115 return Response::SUCCESS;
118 void InputRegionLayer::setOriginalLayer(
HyPerLayer *layer) {
119 if (layer ==
nullptr) {
120 if (parent->columnId() == 0) {
122 "%s: originalLayerName \"%s\" is not a layer in the HyPerCol.\n",
126 MPI_Barrier(parent->getCommunicator()->communicator());
129 originalLayer =
dynamic_cast<InputLayer *
>(layer);
130 if (originalLayer ==
nullptr) {
131 if (parent->columnId() == 0) {
133 "%s: originalLayerName \"%s\" is not an InputLayer-derived class.\n",
137 MPI_Barrier(parent->getCommunicator()->communicator());
140 originalLayer->makeInputRegionsPointer();
143 void InputRegionLayer::checkLayerDimensions() {
144 pvAssert(originalLayer);
145 const PVLayerLoc *srcLoc = originalLayer->getLayerLoc();
147 pvAssert(srcLoc !=
nullptr && loc !=
nullptr);
148 if (srcLoc->nxGlobal != loc->nxGlobal || srcLoc->nyGlobal != loc->nyGlobal
149 || srcLoc->nf != loc->nf) {
150 if (parent->columnId() == 0) {
151 ErrorLog(errorMessage);
153 "%s: originalLayerName \"%s\" does not have the same dimensions.\n",
157 " original (nx=%d, ny=%d, nf=%d) versus (nx=%d, ny=%d, nf=%d)\n",
165 MPI_Barrier(parent->getCommunicator()->communicator());
168 pvAssert(srcLoc->nx == loc->nx && srcLoc->ny == loc->ny);
171 Response::Status InputRegionLayer::allocateDataStructures() {
174 return Response::POSTPONE;
176 return HyPerLayer::allocateDataStructures();
179 void InputRegionLayer::allocateV() { clayer->V =
nullptr; }
181 void InputRegionLayer::allocateActivity() {
182 int const numItems = getNumExtendedAllBatches();
184 FatalIf(cube ==
nullptr,
"Unable to allocate PVLayerCube for %s\n", getDescription_c());
185 cube->size = pvcube_size(numItems);
186 cube->numItems = numItems;
187 cube->loc = *getLayerLoc();
188 cube->data = originalLayer->getInputRegionsAllBatchElements();
189 clayer->activity = cube;
192 int InputRegionLayer::setActivity() {
return PV_SUCCESS; }
194 int InputRegionLayer::requireChannel(
int channelNeeded,
int *numChannelsResult) {
195 if (parent->columnId() == 0) {
197 "%s: layers derived from InputRegionLayer do not have GSyn channels (requireChannel " 199 "with channel %d)\n",
206 void InputRegionLayer::allocateGSyn() { pvAssert(GSyn ==
nullptr); }
210 InputRegionLayer::~InputRegionLayer() { free(originalLayerName); }
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
bool getDataStructuresAllocatedFlag() const
static bool completed(Status &a)
int initialize(const char *name, HyPerCol *hc)
bool getInitInfoCommunicatedFlag() const