MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
EngineParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param
9{
14 [Serializable]
15 [TypeConverter(typeof(ExpandableObjectConverter))]
17 {
18 Engine m_engine = Engine.DEFAULT;
19
23 public enum Engine
24 {
28 DEFAULT = 0,
32 CAFFE = 1,
36 CUDNN = 2
37 }
38
41 {
42 }
43
47 [Description("Specifies the engine to use 'CAFFE' or CUDNN. In most instances CUDNN is the default.")]
49 {
50 get { return m_engine; }
51 set { m_engine = value; }
52 }
53
55 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
56 {
57 RawProto proto = RawProto.Parse(br.ReadString());
58 EngineParameter p = FromProto(proto);
59
60 if (!bNewInstance)
61 Copy(p);
62
63 return p;
64 }
65
66
68 public override void Copy(LayerParameterBase src)
69 {
71 m_engine = p.m_engine;
72 }
73
75 public override LayerParameterBase Clone()
76 {
78 p.Copy(this);
79 return p;
80 }
81
87 public override RawProto ToProto(string strName)
88 {
89 RawProtoCollection rgChildren = new RawProtoCollection();
90
91 if (engine != Engine.DEFAULT)
92 rgChildren.Add("engine", engine.ToString());
93
94 return new RawProto(strName, "", rgChildren);
95 }
96
103 {
104 string strVal;
106
107 if ((strVal = rp.FindValue("engine")) != null)
108 {
109 switch (strVal)
110 {
111 case "DEFAULT":
112 p.engine = Engine.DEFAULT;
113 break;
114
115 case "CAFFE":
116 p.engine = Engine.CAFFE;
117 break;
118
119 case "CUDNN":
120 p.engine = Engine.CUDNN;
121 break;
122
123 default:
124 throw new Exception("Unknown 'engine' value: " + strVal);
125 }
126 }
127
128 return p;
129 }
130 }
131}
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.
Definition: RawProto.cs:17
static RawProto Parse(string str)
Parses a prototxt and places it in a new RawProto.
Definition: RawProto.cs:306
string FindValue(string strName)
Searches for a falue of a node within this nodes children.
Definition: RawProto.cs:105
Specifies whether to use the NVIDIA cuDnn version or Caffe version of a given forward/backward operat...
Engine engine
Specifies the Engine in use.
EngineParameter()
Constructor for the parameter.
static EngineParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
Engine
Defines the type of engine to use.
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.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
The LayerParameterBase is the base class for all other layer specific parameters.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
@ DEFAULT
Specifies to use the default data type of the gym used.
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-...
Definition: Annotation.cs:12