8 #include "DependentSharedWeights.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 DependentSharedWeights::DependentSharedWeights(
char const *name, HyPerCol *hc) {
21 DependentSharedWeights::DependentSharedWeights() {}
23 DependentSharedWeights::~DependentSharedWeights() {}
25 int DependentSharedWeights::initialize(
char const *name, HyPerCol *hc) {
26 return SharedWeights::initialize(name, hc);
29 void DependentSharedWeights::setObjectType() { mObjectType =
"DependentSharedWeights"; }
36 if (ioFlag == PARAMS_IO_READ) {
37 parent->parameters()->handleUnnecessaryParameter(name,
"sharedWeights");
42 Response::Status DependentSharedWeights::communicateInitInfo(
43 std::shared_ptr<CommunicateInitInfoMessage const> message) {
44 auto hierarchy = message->mHierarchy;
46 char const *originalConnName = getOriginalConnName(hierarchy);
47 pvAssert(originalConnName);
49 auto *originalSharedWeights = getOriginalSharedWeights(hierarchy, originalConnName);
50 pvAssert(originalSharedWeights);
52 if (!originalSharedWeights->getInitInfoCommunicatedFlag()) {
53 if (parent->getCommunicator()->globalCommRank() == 0) {
55 "%s must wait until original connection \"%s\" has finished its communicateInitInfo " 60 return Response::POSTPONE;
62 mSharedWeights = originalSharedWeights->getSharedWeights();
63 parent->parameters()->handleUnnecessaryParameter(name,
"sharedWeights", mSharedWeights);
65 auto status = SharedWeights::communicateInitInfo(message);
69 return Response::SUCCESS;
72 char const *DependentSharedWeights::getOriginalConnName(
73 std::map<std::string, Observer *>
const hierarchy)
const {
75 mapLookupByType<OriginalConnNameParam>(hierarchy, getDescription());
77 originalConnNameParam ==
nullptr,
78 "%s requires an OriginalConnNameParam component.\n",
80 char const *originalConnName = originalConnNameParam->getOriginalConnName();
81 return originalConnName;
84 SharedWeights *DependentSharedWeights::getOriginalSharedWeights(
85 std::map<std::string, Observer *>
const hierarchy,
86 char const *originalConnName)
const {
88 mapLookupByType<ObjectMapComponent>(hierarchy, getDescription());
89 pvAssert(objectMapComponent);
91 objectMapComponent->lookup<
BaseConnection>(std::string(originalConnName));
92 if (originalConn ==
nullptr) {
93 if (parent->getCommunicator()->globalCommRank() == 0) {
95 "%s: originalConnName \"%s\" does not correspond to a BaseConnection in the " 100 MPI_Barrier(parent->getCommunicator()->globalCommunicator());
104 auto *originalSharedWeights = originalConn->getComponentByType<
SharedWeights>();
106 originalSharedWeights ==
nullptr,
107 "%s original connection \"%s\" does not have an SharedWeights.\n",
110 return originalSharedWeights;
int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
static bool completed(Status &a)
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
virtual void ioParam_sharedWeights(enum ParamsIOFlag ioFlag) override
shareeWeihgts: DependentSharedWeightss does not use the sharedWeights parameter, but uses the same se...