8 #include "CloneVLayer.hpp" 12 CloneVLayer::CloneVLayer(
const char *name, HyPerCol *hc) {
17 CloneVLayer::CloneVLayer() {
22 int CloneVLayer::initialize_base() {
24 originalLayerName = NULL;
29 int CloneVLayer::initialize(
const char *name, HyPerCol *hc) {
36 ioParam_originalLayerName(ioFlag);
40 void CloneVLayer::ioParam_originalLayerName(
enum ParamsIOFlag ioFlag) {
41 parent->parameters()->ioParamStringRequired(
42 ioFlag, name,
"originalLayerName", &originalLayerName);
46 if (ioFlag == PARAMS_IO_READ) {
47 parent->parameters()->handleUnnecessaryParameter(name,
"InitVType");
52 CloneVLayer::communicateInitInfo(std::shared_ptr<CommunicateInitInfoMessage const> message) {
53 auto status = HyPerLayer::communicateInitInfo(message);
57 originalLayer = message->lookup<
HyPerLayer>(std::string(originalLayerName));
58 if (originalLayer == NULL) {
59 if (parent->columnId() == 0) {
61 "%s: originalLayerName \"%s\" is not a layer in the HyPerCol.\n",
65 MPI_Barrier(parent->getCommunicator()->communicator());
68 const PVLayerLoc *srcLoc = originalLayer->getLayerLoc();
70 assert(srcLoc != NULL && loc != NULL);
71 if (srcLoc->nxGlobal != loc->nxGlobal || srcLoc->nyGlobal != loc->nyGlobal
72 || srcLoc->nf != loc->nf) {
73 if (parent->columnId() == 0) {
74 ErrorLog(errorMessage);
76 "%s: originalLayerName \"%s\" does not have the same dimensions.\n",
80 " original (nx=%d, ny=%d, nf=%d) versus (nx=%d, ny=%d, nf=%d)\n",
88 MPI_Barrier(parent->getCommunicator()->communicator());
91 assert(srcLoc->nx == loc->nx && srcLoc->ny == loc->ny);
92 return Response::SUCCESS;
95 int CloneVLayer::requireMarginWidth(
int marginWidthNeeded,
int *marginWidthResult,
char axis) {
96 HyPerLayer::requireMarginWidth(marginWidthNeeded, marginWidthResult, axis);
97 assert(*marginWidthResult >= marginWidthNeeded);
101 Response::Status CloneVLayer::allocateDataStructures() {
102 assert(originalLayer);
103 auto status = Response::SUCCESS;
107 status = HyPerLayer::allocateDataStructures();
110 status = Response::POSTPONE;
115 void CloneVLayer::allocateV() {
116 assert(originalLayer && originalLayer->getCLayer());
117 clayer->V = originalLayer->getV();
118 if (getV() == NULL) {
120 "%s: originalLayer \"%s\" has a null V buffer in rank %d process.\n",
127 int CloneVLayer::requireChannel(
int channelNeeded,
int *numChannelsResult) {
128 if (parent->columnId() == 0) {
130 "%s: layers derived from CloneVLayer do not have GSyn channels (requireChannel called " 131 "with channel %d)\n",
138 void CloneVLayer::allocateGSyn() { pvAssert(GSyn ==
nullptr); }
140 void CloneVLayer::initializeV() {}
142 void CloneVLayer::readVFromCheckpoint(
Checkpointer *checkpointer) {
147 Response::Status CloneVLayer::registerData(
Checkpointer *checkpointer) {
148 float *V = clayer->V;
150 auto status = HyPerLayer::registerData(checkpointer);
155 Response::Status CloneVLayer::updateState(
double timed,
double dt) {
157 float *A = clayer->activity->data;
159 int num_channels = getNumChannels();
160 float *gSynHead = GSyn == NULL ? NULL : GSyn[0];
164 int num_neurons = nx * ny * nf;
165 int nbatch = loc->nbatch;
166 setActivity_HyPerLayer(
178 return Response::SUCCESS;
181 CloneVLayer::~CloneVLayer() {
182 free(originalLayerName);
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
virtual void ioParam_InitVType(enum ParamsIOFlag ioFlag) override
initVType: Specifies how to initialize the V buffer.
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
bool getDataStructuresAllocatedFlag() const
static bool completed(Status &a)
int initialize(const char *name, HyPerCol *hc)