8 #include "DependentPatchSize.hpp" 9 #include "columns/HyPerCol.hpp" 10 #include "columns/ObjectMapComponent.hpp" 11 #include "components/OriginalConnNameParam.hpp" 12 #include "connections/BaseConnection.hpp" 13 #include "utils/MapLookupByType.hpp" 17 DependentPatchSize::DependentPatchSize(
char const *name, HyPerCol *hc) { initialize(name, hc); }
19 DependentPatchSize::DependentPatchSize() {}
21 DependentPatchSize::~DependentPatchSize() {}
23 int DependentPatchSize::initialize(
char const *name, HyPerCol *hc) {
24 return PatchSize::initialize(name, hc);
27 void DependentPatchSize::setObjectType() { mObjectType =
"DependentPatchSize"; }
34 if (ioFlag == PARAMS_IO_READ) {
35 parent->parameters()->handleUnnecessaryParameter(name,
"nxp");
41 if (ioFlag == PARAMS_IO_READ) {
42 parent->parameters()->handleUnnecessaryParameter(name,
"nyp");
48 if (ioFlag == PARAMS_IO_READ) {
49 parent->parameters()->handleUnnecessaryParameter(name,
"nfp");
56 auto hierarchy = message->mHierarchy;
58 char const *originalConnName = getOriginalConnName(hierarchy);
59 pvAssert(originalConnName);
61 auto *originalPatchSize = getOriginalPatchSize(hierarchy, originalConnName);
62 pvAssert(originalPatchSize);
64 if (!originalPatchSize->getInitInfoCommunicatedFlag()) {
65 if (parent->getCommunicator()->globalCommRank() == 0) {
67 "%s must wait until original connection \"%s\" has finished its communicateInitInfo " 72 return Response::POSTPONE;
75 setPatchSize(originalPatchSize);
76 parent->parameters()->handleUnnecessaryParameter(name,
"nxp", mPatchSizeX);
77 parent->parameters()->handleUnnecessaryParameter(name,
"nyp", mPatchSizeY);
78 parent->parameters()->handleUnnecessaryParameter(name,
"nfp", mPatchSizeF);
84 void DependentPatchSize::setPatchSize(
PatchSize *originalPatchSize) {
85 mPatchSizeX = originalPatchSize->getPatchSizeX();
86 mPatchSizeY = originalPatchSize->getPatchSizeY();
87 mPatchSizeF = originalPatchSize->getPatchSizeF();
91 DependentPatchSize::getOriginalConnName(std::map<std::string, Observer *>
const hierarchy)
const {
93 mapLookupByType<OriginalConnNameParam>(hierarchy, getDescription());
95 originalConnNameParam ==
nullptr,
96 "%s requires an OriginalConnNameParam component.\n",
98 char const *originalConnName = originalConnNameParam->getOriginalConnName();
99 return originalConnName;
102 PatchSize *DependentPatchSize::getOriginalPatchSize(
103 std::map<std::string, Observer *>
const hierarchy,
104 char const *originalConnName)
const {
106 mapLookupByType<ObjectMapComponent>(hierarchy, getDescription());
107 pvAssert(objectMapComponent);
109 objectMapComponent->lookup<
BaseConnection>(std::string(originalConnName));
110 if (originalConn ==
nullptr) {
111 if (parent->getCommunicator()->globalCommRank() == 0) {
113 "%s: originalConnName \"%s\" does not correspond to a BaseConnection in the " 118 MPI_Barrier(parent->getCommunicator()->globalCommunicator());
122 auto *originalPatchSize = originalConn->getComponentByType<
PatchSize>();
124 originalPatchSize ==
nullptr,
125 "%s original connection \"%s\" does not have an PatchSize.\n",
128 return originalPatchSize;
virtual void ioParam_nxp(enum ParamsIOFlag ioFlag) override
nxp: DependentPatchSize does not read the nxp parameter, but copies it from the original connection...
virtual Response::Status communicateInitInfo(std::shared_ptr< CommunicateInitInfoMessage const > message) override
If nfp was set to a negative number in params, set it here to the postsynaptic layer's nf...
int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
virtual void ioParam_nfp(enum ParamsIOFlag ioFlag) override
nfp: DependentPatchSize does not read the nfp parameter, but copies it from the original connection...
virtual void ioParam_nyp(enum ParamsIOFlag ioFlag) override
nyp: DependentPatchSize does not read the nyp parameter, but copies it from the original connection...
virtual Response::Status communicateInitInfo(std::shared_ptr< CommunicateInitInfoMessage const > message) override
If nfp was set to a negative number in params, set it here to the postsynaptic layer's nf...