8 #include "PatchSize.hpp"     9 #include "columns/HyPerCol.hpp"    10 #include "utils/MapLookupByType.hpp"    14 PatchSize::PatchSize(
char const *name, HyPerCol *hc) { initialize(name, hc); }
    16 PatchSize::~PatchSize() {}
    18 int PatchSize::initialize(
char const *name, HyPerCol *hc) {
    19    return BaseObject::initialize(name, hc);
    22 void PatchSize::setObjectType() { mObjectType = 
"PatchSize"; }
    32    parent->parameters()->ioParamValue(ioFlag, name, 
"nxp", &mPatchSizeX, mPatchSizeX);
    36    parent->parameters()->ioParamValue(ioFlag, name, 
"nyp", &mPatchSizeY, mPatchSizeY);
    40    parent->parameters()->ioParamValue(ioFlag, name, 
"nfp", &mPatchSizeF, mPatchSizeF, 
false);
    41    if (ioFlag == PARAMS_IO_READ && mPatchSizeF < 0 && !parent->parameters()->present(name, 
"nfp")
    42        && parent->getCommunicator()->globalCommRank() == 0) {
    44             "%s: nfp will be set in the communicateInitInfo() stage.\n", getDescription_c());
    50    auto status = BaseObject::communicateInitInfo(message);
    54    mConnectionData = mapLookupByType<ConnectionData>(message->mHierarchy, getDescription());
    56          mConnectionData == 
nullptr,
    57          "%s received CommunicateInitInfo message without a ConnectionData component.\n",
    61       if (parent->getCommunicator()->globalCommRank() == 0) {
    63                "%s must wait until the ConnectionData component has finished its "    64                "communicateInitInfo stage.\n",
    67       return Response::POSTPONE;
    71    int const nfPost = post->getLayerLoc()->nf;
    73    if (mPatchSizeF < 0) {
    75       if (mWarnDefaultNfp && parent->getCommunicator()->globalCommRank() == 0) {
    77                "%s setting nfp to number of postsynaptic features = %d.\n",
    82    if (mPatchSizeF != nfPost) {
    83       if (parent->getCommunicator()->globalCommRank() == 0) {
    84          ErrorLog(errorMessage);
    86                "Params file specifies %d features for %s,\n", mPatchSizeF, getDescription_c());
    88                "but %d features for post-synaptic layer %s\n", nfPost, post->getName());
    90       MPI_Barrier(parent->getCommunicator()->globalCommunicator());
    98    return Response::SUCCESS;
   102    if (numNeuronsPre == numNeuronsPost) {
   105    else if (numNeuronsPre > numNeuronsPost) {
   106       std::div_t scaleDivision = div(numNeuronsPre, numNeuronsPost);
   108             scaleDivision.rem != 0,
   109             "calcPostPatchSize called with numNeuronsPre (%d) greater than numNeuronsPost (%d), "   110             "but not an integer multiple.\n",
   113       return prePatchSize * scaleDivision.quot;
   116       std::div_t 
const scaleDivision = div(numNeuronsPost, numNeuronsPre);
   118             scaleDivision.rem != 0,
   119             "calcPostPatchSize called with numNeuronsPost (%d) greater than numNeuronsPre (%d), "   120             "but not an integer multiple.\n",
   123       int const scaleFactor         = scaleDivision.quot;
   124       std::div_t 
const newPatchSize = div(prePatchSize, scaleFactor);
   126             newPatchSize.rem != 0,
   127             "calcPostPatchSize called with scale factor of numNeuronsPost/numNeuronsPre = %d, "   128             "but prePatchSize (%d) is not an integer multiple of the scale factor.\n",
   131       return prePatchSize / scaleFactor;
 virtual void ioParam_nyp(enum ParamsIOFlag ioFlag)
nyp: Specifies the y patch size 
static bool completed(Status &a)
virtual void ioParam_nxp(enum ParamsIOFlag ioFlag)
nxp: Specifies the x patch size 
int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
virtual void ioParam_nfp(enum ParamsIOFlag ioFlag)
nfp: Specifies the post feature patch size. If negative, it can be set during the CommunicateInitInfo...
static int calcPostPatchSize(int prePatchSize, int numNeuronsPre, int numNeuronsPost)
bool getInitInfoCommunicatedFlag() const 
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...