8 #include "CloneWeightsPair.hpp" 9 #include "columns/HyPerCol.hpp" 10 #include "columns/ObjectMapComponent.hpp" 11 #include "components/OriginalConnNameParam.hpp" 12 #include "utils/MapLookupByType.hpp" 16 CloneWeightsPair::CloneWeightsPair(
char const *name, HyPerCol *hc) { initialize(name, hc); }
18 CloneWeightsPair::~CloneWeightsPair() {
19 mPreWeights =
nullptr;
20 mPostWeights =
nullptr;
23 int CloneWeightsPair::initialize(
char const *name, HyPerCol *hc) {
24 return WeightsPair::initialize(name, hc);
27 void CloneWeightsPair::setObjectType() { mObjectType =
"CloneWeightsPair"; }
35 if (ioFlag == PARAMS_IO_READ) {
36 parent->parameters()->handleUnnecessaryParameter(name,
"writeStep");
43 if (ioFlag == PARAMS_IO_READ) {
44 mWriteCompressedCheckpoints =
false;
45 parent->parameters()->handleUnnecessaryParameter(name,
"writeCompressedCheckpoints");
51 CloneWeightsPair::communicateInitInfo(std::shared_ptr<CommunicateInitInfoMessage const> message) {
52 if (mOriginalConn ==
nullptr) {
54 mapLookupByType<OriginalConnNameParam>(message->mHierarchy, getDescription());
56 originalConnNameParam ==
nullptr,
57 "%s requires an OriginalConnNameParam component.\n",
61 if (parent->getCommunicator()->globalCommRank() == 0) {
63 "%s must wait until the OriginalConnNameParam component has finished its " 64 "communicateInitInfo stage.\n",
67 return Response::POSTPONE;
69 char const *originalConnName = originalConnNameParam->getOriginalConnName();
71 auto hierarchy = message->mHierarchy;
73 mapLookupByType<ObjectMapComponent>(hierarchy, getDescription());
74 pvAssert(objectMapComponent);
75 mOriginalConn = objectMapComponent->lookup<
HyPerConn>(std::string(originalConnName));
76 if (mOriginalConn ==
nullptr) {
77 if (parent->getCommunicator()->globalCommRank() == 0) {
79 "%s: originalConnName \"%s\" does not correspond to a HyPerConn in the column.\n",
83 MPI_Barrier(parent->getCommunicator()->globalCommunicator());
87 mOriginalWeightsPair = mOriginalConn->getComponentByType<
WeightsPair>();
88 pvAssert(mOriginalWeightsPair);
91 if (parent->getCommunicator()->globalCommRank() == 0) {
93 "%s must wait until original connection \"%s\" has finished its communicateInitInfo " 96 mOriginalWeightsPair->getName());
98 return Response::POSTPONE;
101 Response::Status status = WeightsPair::communicateInitInfo(message);
110 return Response::SUCCESS;
114 int status = PV_SUCCESS;
116 pvAssert(mConnectionData);
117 auto *thisPre = mConnectionData->
getPre();
118 if (thisPre ==
nullptr) {
120 "synchronzedMarginsPre called for %s, but this connection has not set its " 121 "presynaptic layer yet.\n",
127 if (mOriginalConn ==
nullptr) {
129 "synchronzedMarginsPre called for %s, but this connection has not set its " 130 "original connection yet.\n",
135 origPre = mOriginalConn->getPre();
136 if (origPre ==
nullptr) {
138 "synchronzedMarginsPre called for %s, but the original connection has not set its " 139 "presynaptic layer yet.\n",
144 if (status != PV_SUCCESS) {
147 thisPre->synchronizeMarginWidth(origPre);
148 origPre->synchronizeMarginWidth(thisPre);
152 int status = PV_SUCCESS;
154 pvAssert(mConnectionData);
155 auto *thisPost = mConnectionData->
getPost();
156 if (thisPost ==
nullptr) {
158 "synchronzedMarginsPost called for %s, but this connection has not set its " 159 "postsynaptic layer yet.\n",
165 if (mOriginalConn ==
nullptr) {
167 "synchronzedMarginsPre called for %s, but this connection has not set its " 168 "original connection yet.\n",
173 origPost = mOriginalConn->getPost();
174 if (origPost ==
nullptr) {
176 "synchronzedMarginsPost called for %s, but the original connection has not set its " 177 "postsynaptic layer yet.\n",
182 if (status != PV_SUCCESS) {
185 thisPost->synchronizeMarginWidth(origPost);
186 origPost->synchronizeMarginWidth(thisPost);
190 mOriginalWeightsPair->
needPre();
191 mPreWeights = mOriginalWeightsPair->getPreWeights();
196 mPostWeights = mOriginalWeightsPair->getPostWeights();
199 Response::Status CloneWeightsPair::allocateDataStructures() {
return Response::SUCCESS; }
201 Response::Status CloneWeightsPair::registerData(
Checkpointer *checkpointer) {
202 return Response::NO_ACTION;
205 void CloneWeightsPair::finalizeUpdate(
double timestamp,
double deltaTime) {}
207 void CloneWeightsPair::outputState(
double timestamp) {
return; }
int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
virtual void ioParam_writeCompressedCheckpoints(enum ParamsIOFlag ioFlag) override
writeStep: CloneWeightsPair does not checkpoint, so writeCompressedCheckpoints is always set to false...
static bool completed(Status &a)
void synchronizeMarginsPost()
virtual void createPostWeights(std::string const &weightsName) override
virtual void createPreWeights(std::string const &weightsName) override
void synchronizeMarginsPre()
virtual void ioParam_writeStep(enum ParamsIOFlag ioFlag) override
writeStep: CloneWeightsPair never writes output, always sets writeStep to -1.
bool getInitInfoCommunicatedFlag() const