2using System.Collections.Generic;
20 [TypeConverter(typeof(ExpandableObjectConverter))]
24 int m_nOrderingMajorAxis = 1;
27 int m_nSrcStartIdx1 = 0;
28 int m_nDstStartIdx1 = 0;
30 int m_nSrcStartIdx2 = 0;
31 int m_nDstStartIdx2 = 0;
32 int m_nSrcSpatialDimStartIdx1 = 0;
33 int m_nDstSpatialDimStartIdx1 = 0;
34 int m_nSrcSpatialDimStartIdx2 = 0;
35 int m_nDstSpatialDimStartIdx2 = 0;
36 int m_nSpatialDimCopyCount = -1;
37 int m_nDstSpatialDim = 0;
50 [Description(
"Specifies axis providing the major ordering (e.g. axis=1 uses axis 1 as the major ordering with axis 0 following).")]
53 get {
return m_nOrderingMajorAxis; }
63 [Description(
"Specifies axis providing the major ordering (e.g. axis=1 uses axis 1 as the major ordering with axis 0 following).")]
66 get {
return m_nCopyAxis; }
73 [Description(
"Specifies the number of skip copies along the copy_axis to copy (e.g. this is the number of skips to perform and is usually = the batch size).")]
76 get {
return m_nCopyCount; }
77 set { m_nCopyCount = value; }
83 [Description(
"Specifies the src start index where copying begins in the first blob in bottom(0).")]
86 get {
return m_nSrcStartIdx1; }
87 set { m_nSrcStartIdx1 = value; }
93 [Description(
"Specifies the dst start index where copying begins in the destination blob in top(0).")]
96 get {
return m_nDstStartIdx1; }
97 set { m_nDstStartIdx1 = value; }
103 [Description(
"Specifies the src1 spatial dim start index (only used when > 0)")]
106 get {
return m_nSrcSpatialDimStartIdx1; }
107 set { m_nSrcSpatialDimStartIdx1 = value; }
113 [Description(
"Specifies the dst1 spatial dim start index (only used when > 0)")]
116 get {
return m_nDstSpatialDimStartIdx1; }
117 set { m_nDstSpatialDimStartIdx1 = value; }
123 [Description(
"Specifies the src2 spatial dim start index (only used when > 0)")]
126 get {
return m_nSrcSpatialDimStartIdx2; }
127 set { m_nSrcSpatialDimStartIdx2 = value; }
133 [Description(
"Specifies the dst2 spatial dim start index (only used when > 0)")]
136 get {
return m_nDstSpatialDimStartIdx2; }
137 set { m_nDstSpatialDimStartIdx2 = value; }
143 [Description(
"Specifies the spatial dim copy count, used when less than the entire spatial dim is to be copied.")]
146 get {
return m_nSpatialDimCopyCount; }
147 set { m_nSpatialDimCopyCount = value; }
153 [Description(
"Specifies the dst spatial dim which if not copied into is set to zero.")]
156 get {
return m_nDstSpatialDim; }
157 set { m_nDstSpatialDim = value; }
163 [Description(
"Specifies the dimension (sans the spatial dimension) to be copied from bottom(0) (the full copy size = copy_dim1 * spatial_dim which is calculated using axis dims after the copy axis).")]
166 get {
return m_nCopyDim1; }
167 set { m_nCopyDim1 = value; }
173 [Description(
"Specifies src the start index where copying begins in the second input blob in bottom(1).")]
176 get {
return m_nSrcStartIdx2; }
177 set { m_nSrcStartIdx2 = value; }
183 [Description(
"Specifies the dst start index where copying begins for the second copy to dst blob in top(0).")]
186 get {
return m_nDstStartIdx2; }
187 set { m_nDstStartIdx2 = value; }
193 [Description(
"Specifies the dimension (sans the spatial dimension) to be copied from bottom(0) (the full copy size = copy_dim1 * spatial_dim which is calculated using axis dims after the copy axis).")]
196 get {
return m_nCopyDim2; }
197 set { m_nCopyDim2 = value; }
206 public override object Load(
System.IO.BinaryReader br,
bool bNewInstance =
true)
224 m_nCopyAxis = p.m_nCopyAxis;
225 m_nOrderingMajorAxis = p.m_nOrderingMajorAxis;
226 m_nCopyCount = p.m_nCopyCount;
227 m_nSrcStartIdx1 = p.m_nSrcStartIdx1;
228 m_nSrcStartIdx2 = p.m_nSrcStartIdx2;
229 m_nDstStartIdx1 = p.m_nDstStartIdx1;
230 m_nDstStartIdx2 = p.m_nDstStartIdx2;
231 m_nCopyDim1 = p.m_nCopyDim1;
232 m_nCopyDim2 = p.m_nCopyDim2;
233 m_nSrcSpatialDimStartIdx1 = p.m_nSrcSpatialDimStartIdx1;
234 m_nDstSpatialDimStartIdx1 = p.m_nDstSpatialDimStartIdx1;
235 m_nSrcSpatialDimStartIdx2 = p.m_nSrcSpatialDimStartIdx2;
236 m_nDstSpatialDimStartIdx2 = p.m_nDstSpatialDimStartIdx2;
237 m_nSpatialDimCopyCount = p.m_nSpatialDimCopyCount;
238 m_nDstSpatialDim = p.m_nDstSpatialDim;
277 return new RawProto(strName,
"", rgChildren);
296 if ((strVal = rp.
FindValue(
"copy_count")) !=
null)
299 if ((strVal = rp.
FindValue(
"src_start_idx1")) !=
null)
302 if ((strVal = rp.
FindValue(
"dst_start_idx1")) !=
null)
305 if ((strVal = rp.
FindValue(
"copy_dim1")) !=
null)
308 if ((strVal = rp.
FindValue(
"src_start_idx2")) !=
null)
311 if ((strVal = rp.
FindValue(
"dst_start_idx2")) !=
null)
314 if ((strVal = rp.
FindValue(
"copy_dim2")) !=
null)
317 if ((strVal = rp.
FindValue(
"src_spatialdim_start_idx1")) !=
null)
320 if ((strVal = rp.
FindValue(
"dst_spatialdim_start_idx1")) !=
null)
323 if ((strVal = rp.
FindValue(
"src_spatialdim_start_idx2")) !=
null)
326 if ((strVal = rp.
FindValue(
"dst_spatialdim_start_idx2")) !=
null)
329 if ((strVal = rp.
FindValue(
"spatialdim_copy_count")) !=
null)
332 if ((strVal = rp.
FindValue(
"dst_spatialdim")) !=
null)
348 while (rgShape2.Count > rgShape1.Count && rgShape2.Count > 0)
350 if (rgShape2[rgShape2.Count - 1] == 1)
351 rgShape2.RemoveAt(rgShape2.Count - 1);
354 while (rgShape1.Count > rgShape2.Count && rgShape1.Count > 0)
356 if (rgShape1[rgShape1.Count - 1] == 1)
357 rgShape1.RemoveAt(rgShape1.Count - 1);
360 log.
CHECK_EQ(rgShape1.Count, rgShape2.Count,
"The inputs must have the same number of axes.");
361 log.
CHECK_LT(p.
copy_axis, rgShape1.Count,
"There must be more axes than the copy axis!");
368 List<int> rgNewShape =
new List<int>();
369 for (
int i = 0; i < rgShape1.Count; i++)
376 log.
CHECK_EQ(rgShape1[i], rgShape2[i],
"Inputs must have the same dimensions up to the copy axis.");
377 rgNewShape[i] = rgShape1[i];
384 rgNewShape[nIdx] = nCopy1 + nCopy2;
386 rgNewShape[nIdx] = rgShape1[nIdx];
389 for (
int i = nIdx; i < rgNewShape.Count; i++)
391 if (p.m_nDstSpatialDim > 0)
393 rgNewShape[i] = p.m_nDstSpatialDim;
399 log.
CHECK_EQ(rgShape1[i], rgShape2[i],
"Inputs must have the same dimensions after the copy axis.");
400 rgNewShape[i] = rgShape1[i];
The Log class provides general output in text form.
void CHECK_EQ(double df1, double df2, string str)
Test whether one number is equal to another.
void CHECK_LT(double df1, double df2, string str)
Test whether one number is less than another.
The RawProtoCollection class is a list of RawProto objects.
void Add(RawProto p)
Adds a RawProto to the collection.
The RawProto class is used to parse and output Google prototxt file data.
static RawProto Parse(string str)
Parses a prototxt and places it in a new RawProto.
string FindValue(string strName)
Searches for a falue of a node within this nodes children.
The Utility class provides general utility funtions.
static int CanonicalAxisIndex(int nIdx, int nNumAxes)
Returns the 'canonical' version of a (usually) user-specified axis, allowing for negative indexing (e...
The LayerParameterBase is the base class for all other layer specific parameters.
Specifies the parameters for the MergeLayer.
static List< int > Reshape(Log log, MergeParameter p, List< int > rgShape1, List< int > rgShape2)
Calculate the new shape based on the merge parameter settings and the specified input shapes.
int dst_spatialdim_start_idx1
Specifies the dst1 spatial dim start index (only used when > 0).
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
int dst_start_idx2
Specifies the dst start index where copying begins for the second copy to dst blob in top(0).
int dst_spatialdim_start_idx2
Specifies the dst2 spatial dim start index (only used when > 0).
static MergeParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
int src_spatialdim_start_idx2
Specifies the src2 spatial dim start index (only used when > 0).
int order_major_axis
Specifies axis providing the major ordering (e.g. axis=1 uses axis 1 as the major ordering with axis ...
int spatialdim_copy_count
Specifies the spatial dim copy count, used when less than the entire spatial dim is to be copied.
int copy_dim1
Specifies the dimension (sans the spatial dimension) to be copied (the full copy size = copy_dim * sp...
int src_start_idx2
Specifies the src start index where copying begins in the second input blob in bottom(1).
override void Copy(LayerParameterBase src)
Copy on parameter to another.
int src_start_idx1
Specifies the src start index where copying begins in the first blob in bottom(0).
int copy_dim2
Specifies the dimension (sans the spatial dimension) to be copied (the full copy size = copy_dim * sp...
int copy_axis
Specifies axis along which the indexing is applied when copying.
MergeParameter()
Constructor for the parameter.
int dst_start_idx1
Specifies the dst start index where copying begins in the destination blob in top(0).
int copy_count
Specifies the number of skip copies along the copy_axis to copy (e.g. this is the number of skips to ...
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
int dst_spatialdim
Specifies the dst spatial dim which if not copied into is set to zero.
int src_spatialdim_start_idx1
Specifies the src1 spatial dim start index (only used when > 0).
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
The MyCaffe.param.beta parameters are used by the MyCaffe.layer.beta layers.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...