2using System.Collections.Generic;
22 [TypeConverter(typeof(ExpandableObjectConverter))]
25 uint m_nNumOutput = 0;
26 bool m_bBiasTerm =
true;
31 bool m_bForceNDIm2Col =
false;
32 int m_nCudnnWorkspaceLimit = 1024 * 1024;
33 bool m_bCudnnWorkspaceAllowOnGroups =
false;
34 bool m_bCudnnEnableTensorCores =
false;
48 return "The engine setting is set on CAFFE.";
50 if (nNumSpatialAxes != 2)
51 return "Currently only 2 spatial axes (ht x wd) are supported by cuDnn.";
66 if (nNumSpatialAxes != 2)
80 [Description(
"Specifies whether or not (default) worspaces are used when the group > 1. Currently using workspaces on groups > 1 can cause cuDnn errors and for this reason defaults to false.")]
83 get {
return m_bCudnnWorkspaceAllowOnGroups; }
84 set { m_bCudnnWorkspaceAllowOnGroups = value; }
90 [Description(
"Specifies the cuDnn workspace limit to use.\n\n - A positive value, greater than zero, directs cuDnn to use the most efficient algorithm within the memory limit specified.\n - A value equal to zero directs cuDnn to use the most memory efficient algorithm.\n\n The default for this value is 1,048,576 (i.e 1024 * 1024 which is then multiplied by 8 internally). This value is only used by the CUDNN and DEFAULT engines.")]
94 get {
return m_nCudnnWorkspaceLimit; }
95 set { m_nCudnnWorkspaceLimit = value; }
104 [Description(
"Specifies to enable CUDA tensor cores when performing the convolution which is faster but not supported by all GPU's. When not supported, the default math is used.")]
107 get {
return m_bCudnnEnableTensorCores; }
108 set { m_bCudnnEnableTensorCores = value; }
114 [Description(
"Specifies the number of outputs for the layer.")]
117 get {
return m_nNumOutput; }
118 set { m_nNumOutput = value; }
124 [Description(
"Specifies the whether to have bias terms or not.")]
127 get {
return m_bBiasTerm; }
128 set { m_bBiasTerm = value; }
134 [Description(
"Specifies the group size for group convolution.")]
137 get {
return m_nGroup; }
138 set { m_nGroup = value; }
144 [Category(
"Fillers")]
145 [Description(
"Specifies the filler used to initialize the weights.")]
148 get {
return m_fillerParam_weights; }
149 set { m_fillerParam_weights = value; }
155 [Category(
"Fillers")]
156 [Description(
"Specifies the filler used to initialize the bias.")]
159 get {
return m_fillerParam_bias; }
160 set { m_fillerParam_bias = value; }
174 [Description(
"Specifies the axis to interpret as 'channels' when performing convolution The preceding dimensions are treated as independent inputs; succeeding dimensions are treated as 'spatial'. With (N,C,H,W) inputs and axis == 1 (the default), we perform N independent 2D convolutions, sliding C-channel (or C/g-channels, for groups > 1) filters across the spatial axes (H,W) of the input.")]
177 get {
return m_nAxis; }
178 set { m_nAxis = value; }
188 [Description(
"Specifies whether to force use of the general ND convolution, even if a specific implementation for blobs of the appopriate number of spatial dimensions is available. (Currently, there is only a 2D-specific convolution implementation; for input blobs with 'num_axes' != 2, this option is ignored and the ND implementation is used.)")]
191 get {
return m_bForceNDIm2Col; }
192 set { m_bForceNDIm2Col = value; }
196 public override object Load(
System.IO.BinaryReader br,
bool bNewInstance =
true)
215 m_nNumOutput = p.m_nNumOutput;
216 m_bBiasTerm = p.m_bBiasTerm;
217 m_nGroup = p.m_nGroup;
219 if (p.m_fillerParam_bias !=
null)
220 m_fillerParam_bias = p.m_fillerParam_bias.
Clone();
222 if (p.m_fillerParam_weights !=
null)
223 m_fillerParam_weights = p.m_fillerParam_weights.
Clone();
226 m_bForceNDIm2Col = p.m_bForceNDIm2Col;
227 m_nCudnnWorkspaceLimit = p.m_nCudnnWorkspaceLimit;
228 m_bCudnnWorkspaceAllowOnGroups = p.m_bCudnnWorkspaceAllowOnGroups;
229 m_bCudnnEnableTensorCores = p.m_bCudnnEnableTensorCores;
244 RawProto rpBase = base.ToProto(
"kernel");
254 rgChildren.
Add(
"group",
group.ToString());
256 if (m_fillerParam_weights !=
null)
257 rgChildren.
Add(m_fillerParam_weights.
ToProto(
"weight_filler"));
259 if (
bias_term && m_fillerParam_bias !=
null)
260 rgChildren.
Add(m_fillerParam_bias.
ToProto(
"bias_filler"));
263 rgChildren.
Add(
"axis",
axis.ToString());
277 return new RawProto(strName,
"", rgChildren);
288 if ((strVal = rp.
FindValue(
"num_output")) !=
null)
291 if ((strVal = rp.
FindValue(
"bias_term")) !=
null)
294 if ((strVal = rp.
FindValue(
"group")) !=
null)
295 p.
group = uint.Parse(strVal);
298 if (rpWeightFiller !=
null)
302 if (rpBiasFiller !=
null)
305 if ((strVal = rp.
FindValue(
"axis")) !=
null)
306 p.
axis =
int.Parse(strVal);
308 if ((strVal = rp.
FindValue(
"force_nd_im2col")) !=
null)
311 if ((strVal = rp.
FindValue(
"cudnn_workspace_limit")) !=
null)
314 if ((strVal = rp.
FindValue(
"cudnn_worspace_allow_on_groups")) !=
null)
317 if ((strVal = rp.
FindValue(
"cudnn_enable_tensor_cores")) !=
null)
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.
RawProtoCollection Children
Returns a collection of this nodes child nodes.
RawProto FindChild(string strName)
Searches for a given node.
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.
Specifies the parameters for the ConvolutionLayer. The default weight filler is set to the XavierFill...
bool cudnn_enable_tensor_cores
Specifies to enable the CUDA tensor cores when performing the convolution which is faster but not sup...
FillerParameter weight_filler
The filler for the weight. The default is set to use the 'xavier' filler.
static new ConvolutionParameter FromProto(RawProto rp)
Parse a RawProto into a new instance of the parameter.
uint group
The group size for group convolution.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
bool useCudnn(int nNumSpatialAxes=2)
Queries whether or not to use NVIDIA's cuDnn.
bool force_nd_im2col
Whether to force use of the general ND convolution, even if a specific implementation for blobs of th...
int axis
The axis to interpret as 'channels' when performing convolution. Preceding dimensions are treated as ...
FillerParameter bias_filler
The filler for the bias. The default is set to use the 'constant = 0.1' filler.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
bool bias_term
Whether to have bias terms or not.
int cudnn_workspace_limit
Specifies the workspace limit used by cuDnn. A value of 0 directs cuDNN to use the fastest algorithm ...
override void Copy(LayerParameterBase src)
Copy on parameter to another.
string useCaffeReason(int nNumSpatialAxes=2)
Returns the reason that Caffe version was used instead of NVIDIA's cuDnn.
ConvolutionParameter()
Constructor for the parameter.
uint num_output
The number of outputs for the layer.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
bool cudnn_workspace_allow_on_groups
When true, allows workspace usage on groups > 1 (default = false).
Specifies whether to use the NVIDIA cuDnn version or Caffe version of a given forward/backward operat...
Engine engine
Specifies the Engine in use.
Engine
Defines the type of engine to use.
Specifies the filler parameters used to create each Filler.
static FillerParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
FillerParameter Clone()
Creates a new copy of this instance of the parameter.
Specifies the basic kernel parameters (used by convolution and pooling)
static new KernelParameter FromProto(RawProto rp)
Parse a RawProto into a new instance of the parameter.
KernelParameter()
Constructor for the parameter.
The LayerParameterBase is the base class for all other layer specific parameters.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
The MyCaffe.param namespace contains parameters used to create models.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...