PetaVision
Alpha
|
#include <PatchGeometry.hpp>
Public Member Functions | |
PatchGeometry (std::string const &name, int patchSizeX, int patchSizeY, int patchSizeF, PVLayerLoc const *preLoc, PVLayerLoc const *postLoc) | |
~PatchGeometry () | |
void | allocateDataStructures () |
std::size_t | getAPostOffset (int patchIndex) const |
std::vector< std::size_t > const & | getAPostOffset () const |
std::size_t | getGSynPatchStart (int patchIndex) const |
std::vector< std::size_t > const & | getGSynPatchStart () const |
int | getLog2ScaleDiffX () const |
int | getLog2ScaleDiffY () const |
int | getNumKernels () const |
int | getNumKernelsF () const |
int | getNumKernelsX () const |
int | getNumKernelsY () const |
int | getNumPatches () const |
int | getNumPatchesF () const |
int | getNumPatchesX () const |
int | getNumPatchesY () const |
Patch const & | getPatch (int patchIndex) const |
int | getPatchSizeF () const |
int | getPatchSizeOverall () const |
int | getPatchSizeX () const |
int | getPatchSizeY () const |
int | getPatchStrideF () const |
int | getPatchStrideX () const |
int | getPatchStrideY () const |
PVLayerLoc const & | getPostLoc () const |
PVLayerLoc const & | getPreLoc () const |
bool | getSelfConnectionFlag () const |
std::size_t | getTransposeItemIndex (int kernelIndex, int itemInPatch) const |
long | getUnshrunkenStart (int patchIndex) const |
void | setMargins (PVHalo const &preHalo, PVHalo const &postHalo) |
Static Public Member Functions | |
static int | calcPatchStartInPost (int indexRestrictedPre, int patchSize, int numNeuronsPre, int numNeuronsPost) |
Private Member Functions | |
void | initialize (std::string const &name, int patchSizeX, int patchSizeY, int patchSizeF, PVLayerLoc const *preLoc, PVLayerLoc const *postLoc) |
void | setPatchGeometry () |
void | setTransposeItemIndices () |
void | verifyPatchSize () |
Static Private Member Functions | |
static void | calcPatchData (int index, int numPreRestricted, int preStartBorder, int preEndBorder, int numPostRestricted, int postStartBorder, int postEndBorder, int patchSize, int *patchDim, int *patchStart, int *postPatchStartRestricted, int *postPatchStartExtended, int *postPatchUnshrunkenStart) |
static int | verifyPatchSize (int numPreRestricted, int numPostRestricted, int patchSize) |
Private Attributes | |
std::vector< std::size_t > | mAPostOffset |
std::vector< std::size_t > | mGSynPatchStart |
int | mLog2ScaleDiffX |
int | mLog2ScaleDiffY |
int | mNumKernelsF |
int | mNumKernelsX |
int | mNumKernelsY |
int | mNumPatchesF |
int | mNumPatchesX |
int | mNumPatchesY |
int | mPatchSizeF |
int | mPatchSizeX |
int | mPatchSizeY |
int | mPatchStrideF |
int | mPatchStrideX |
int | mPatchStrideY |
std::vector< Patch > | mPatchVector |
PVLayerLoc | mPostLoc |
PVLayerLoc | mPreLoc |
bool | mSelfConnectionFlag |
std::vector< std::vector< int > > | mTransposeItemIndex |
std::vector< long > | mUnshrunkenStart |
PatchGeometry encapsulates the patch geometry of a HyPerConn.
Instantiate with the size of the patch in postsynaptic space that is affected by one presynaptic neuron, and the pre- and post-synaptic PVLayerLocs. Then call the allocateDataStructures() method.
The PatchGeometry object defines a connectivity betwee the pre- and post- synaptic layers. Each pre-synaptic neuron maps to a 3D block in the postsynaptic layer, whose dimensions are specified by the patchSizeX, patchSizeY, and patchSizeF arguments of the constructor. However, the full 3D block is not always generated, because the block may extend off the edge of the restricted post-synaptic layer.
There is a patch for each pre-synaptic neuron in extended space, and the patches are indexed the same way as a layer's neurons are indexed: feature index spins fastest, then the x-dimension index, and finally the y-dimension index spins slowest. The patch tries to influence a PatchSizeX-by-PatchSizeY-by-PatchSizeF region of the restricted postsynaptic layer, but because of the edge of the layer, the resulting region may be smaller than this.
The getPatch(index) method returns information on the active part of the patch. The nx and ny fields give the dimensions of this portion; and the offset field gives the index of the start of this portion into a PatchSizeX-by-PatchSizeY-by-PatchSizeF block of memory, indexed in the usual PetaVision way.
The getGSynPatchStart(index) method returns the index, in restricted postsynaptic space, of the start of the active region.
The getAPostOffset(index) method returns the extended postsynaptic index of the neuron whose restricted index is GSynPatchStart.
Note that the PatchGeometry object defines which pre- and post-synaptic neurons are connected, but does not provide any data structures for defining the strengths of the connections. For HyPerConn (both shared and nonshared weights), these structures are provided by the Weights class.
Definition at line 53 of file PatchGeometry.hpp.
PV::PatchGeometry::PatchGeometry | ( | std::string const & | name, |
int | patchSizeX, | ||
int | patchSizeY, | ||
int | patchSizeF, | ||
PVLayerLoc const * | preLoc, | ||
PVLayerLoc const * | postLoc | ||
) |
The constructor for the PatchGeometry object. Note that it sets member variables, but does not allocate the data structures used by getPatch(), getGSynPatchStart(), or getAPostOffset. Note that it is necessary to call the public method allocateDataStructures() to complete the initialization.
The constructor makes copies of the pre- and post-synaptic PVLayerLoc objects. It also records whether the pointers to preLoc and postLoc point to the same memory location: see getSelfConnectionFlag().
Definition at line 18 of file PatchGeometry.cpp.
|
inline |
The destructor for the PatchGeometry object.
Definition at line 75 of file PatchGeometry.hpp.
void PV::PatchGeometry::allocateDataStructures | ( | ) |
Allocates the vectors for the patch data, GSynPatchStart, and APostOffset structures. The PatchGeometry object is not completely initialized until this method is called. Once allocateDataStructures() is called once, subsequent calls return immediately and have no effect.
Definition at line 82 of file PatchGeometry.cpp.
|
inline |
Returns the APostOffset value for the indicated patch index
Definition at line 174 of file PatchGeometry.hpp.
|
inline |
Returns a nonmutable reference to the vector of APostOffset values.
Definition at line 187 of file PatchGeometry.hpp.
|
inline |
Returns the GSynPatchStart value for the indicated patch index
Definition at line 168 of file PatchGeometry.hpp.
|
inline |
Returns a nonmutable reference to the vector of GSynPatchStart values.
Definition at line 171 of file PatchGeometry.hpp.
|
inline |
Returns log_2(preLoc.nx / postLoc.nx), using floating-point division. The PatchGeometry class requires that this quantity be an integer.
Definition at line 197 of file PatchGeometry.hpp.
|
inline |
Returns log_2(preLoc.ny / postLoc.ny), using floating-point division. The PatchGeometry class requires that this quantity be an integer.
Definition at line 203 of file PatchGeometry.hpp.
|
inline |
Returns the overall number of patches in the patch geometry
Definition at line 162 of file PatchGeometry.hpp.
|
inline |
Returns the number of kernels in the feature direction. This quantity is equal to getPreLoc().nf
Definition at line 159 of file PatchGeometry.hpp.
|
inline |
Returns the number of kernels in the x-direction. This quantity is equal to getPreLoc().nx / getPostLoc().nx if that quotient is greater than 1; 1 otherwise.
Definition at line 147 of file PatchGeometry.hpp.
|
inline |
Returns the number of patches in the y-direction. This quantity is equal to getPreLoc().ny / getPostLoc().ny if that quotient is greater than 1; 1 otherwise.
Definition at line 153 of file PatchGeometry.hpp.
|
inline |
Returns the overall number of patches in the patch geometry
Definition at line 141 of file PatchGeometry.hpp.
|
inline |
Returns the number of patches in the feature direction. This quantity is equal to getPreLoc().nf
Definition at line 138 of file PatchGeometry.hpp.
|
inline |
Returns the number of patches in the x-direction. This quantity is equal to getPreLoc().nx + getPreLoc().halo.lt + getPreLoc().halo.rt
Definition at line 126 of file PatchGeometry.hpp.
|
inline |
Returns the number of patches in the y-direction. This quantity is equal to getPreLoc().ny + getPreLoc().halo.dn + getPreLoc().halo.up
Definition at line 132 of file PatchGeometry.hpp.
|
inline |
Returns a nonmutable reference to the patch info for the given patch index.
Definition at line 165 of file PatchGeometry.hpp.
|
inline |
get-method for PatchSizeF, the number of features in post-synaptic space that are affected by one pre-synaptic neuron. Currently, PatchSizeF is always equal to PostLoc.nf. That is, in the feature dimension the connection is all-to-all.
Definition at line 108 of file PatchGeometry.hpp.
|
inline |
Returns getPatchSizeX() * getPatchSizeY() * getPatchSizeF(), the overall number of items in a patch.
Definition at line 114 of file PatchGeometry.hpp.
|
inline |
get-method for PatchSizeX, the size in the x-direction of the patch from one pre-synaptic neuron into post-synaptic space.
Definition at line 95 of file PatchGeometry.hpp.
|
inline |
get-method for PatchSizeY, the size in the y-direction of the patch from one pre-synaptic neuron into post-synaptic space.
Definition at line 101 of file PatchGeometry.hpp.
|
inline |
get-method to retrieve a constant reference to the pre-synaptic PVLayerLoc.
Definition at line 120 of file PatchGeometry.hpp.
|
inline |
get-method to retrieve a constant reference to the pre-synaptic PVLayerLoc.
Definition at line 117 of file PatchGeometry.hpp.
|
inline |
Returns true if the PatchGeometry object was instantiated with pre- and post- synaptic PVLayerLoc pointing to the same memory location. Returns false otherwise, even if the values of the PVLayerLoc fields are all equal.
Definition at line 210 of file PatchGeometry.hpp.
|
inline |
Returns the item index of the postsynaptic-perspective patch corresponding to the the given item index of the presynaptic-perspective patch with the given kernel index.
Definition at line 182 of file PatchGeometry.hpp.
|
inline |
Returns the UnshrunkenStart value for the indicated patch index
Definition at line 177 of file PatchGeometry.hpp.
|
private |
Called internally by the constructor
Definition at line 28 of file PatchGeometry.cpp.
Copies the given halos into the halos of the presynaptic and postsynaptic PVLayerLoc objects It is an error to call this method after allocateDataStructures method.
Definition at line 65 of file PatchGeometry.cpp.
|
private |
Called internally by allocateDataStructures, to compute the vectors of Patch objects, GSynPatchStart values, and APostOffset values.
Definition at line 179 of file PatchGeometry.cpp.
|
private |
Called internally by allocateDataStructures, to compute the TransposeItemIndex vectors.
Definition at line 264 of file PatchGeometry.cpp.
|
staticprivate |
Checks that the given pre- and post-synaptic dimensions are multiples of powers of two of each other, and that the patch size is consistent with the quotient. Returns log2(numPostRestricted/numPreRestricted)
Definition at line 90 of file PatchGeometry.cpp.
|
private |
Checks the patch size in the x- and y-directions, and that the PatchSizeF argument agrees with the postLoc.nf argument.
Definition at line 148 of file PatchGeometry.cpp.