-
Notifications
You must be signed in to change notification settings - Fork 1
/
flags.go
353 lines (296 loc) · 7.84 KB
/
flags.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
package gocunets
import (
act "github.com/dereklstinson/gocunets/devices/gpu/nvidia/cudnn/activation"
gocudnn "github.com/dereklstinson/gocudnn"
)
//DataType struct wrapper for gocudnn.Datatype. Look up methods in gocudnn.
type DataType struct {
gocudnn.DataType
}
//Float sets and returns the Float flag
func (d *DataType) Float() DataType {
d.DataType.Float()
return *d
}
//Half sets and returns the Half flag
func (d *DataType) Half() DataType {
d.DataType.Half()
return *d
}
//Double sets and returns the Double flag
func (d *DataType) Double() DataType {
d.DataType.Double()
return *d
}
//UInt8 sets and returns the Uint8 flag
func (d *DataType) UInt8() DataType {
d.DataType.UInt8()
return *d
}
//Int8 sets and returns the Int8 flag
func (d *DataType) Int8() DataType {
d.DataType.Int8()
return *d
}
//Int8x32 sets and returns the Int32 flag
func (d *DataType) Int8x32() DataType {
d.DataType.Int8x32()
return *d
}
//Int8x4 sets and returns the Int32 flag
func (d *DataType) Int8x4() DataType {
d.DataType.Int8x4()
return *d
}
//UInt8x4 sets and returns the Int32 flag
func (d *DataType) UInt8x4() DataType {
d.DataType.UInt8x4()
return *d
}
//Int32 sets and returns the Int32 flag
func (d *DataType) Int32() DataType {
d.DataType.Int32()
return *d
}
//TensorFormat struct wrapper for gocudnn.TensorFormat. Look up methods in gocudnn.
type TensorFormat struct {
gocudnn.TensorFormat
}
//NCHW sets and returns the NCHW flag
func (t *TensorFormat) NCHW() TensorFormat {
t.TensorFormat.NCHW()
return *t
}
//NHWC sets and returns the NHWC flag
func (t *TensorFormat) NHWC() TensorFormat {
t.TensorFormat.NHWC()
return *t
}
//NCHWvectC sets and returns the NHWC flag
func (t *TensorFormat) NCHWvectC() TensorFormat {
t.TensorFormat.NCHWvectC()
return *t
}
//Unknown sets and returns the NHWC flag
func (t *TensorFormat) Unknown() TensorFormat {
t.TensorFormat.Unknown()
return *t
}
//ConvolutionMode struct wrapper for gocudnn.ConvolutionMode. Look up methods in gocudnn.
type ConvolutionMode struct {
gocudnn.ConvolutionMode
}
//Convolution sets and returns the Convolution flag
func (c *ConvolutionMode) Convolution() ConvolutionMode {
c.ConvolutionMode.Convolution()
return *c
}
//CrossCorrelation sets and returns the CrossCorrelation flag
func (c *ConvolutionMode) CrossCorrelation() ConvolutionMode {
c.ConvolutionMode.CrossCorrelation()
return *c
}
//NanProp struct wrapper for gocudnn.NanProp. Look up methods in gocudnn.
type NanProp struct {
gocudnn.NANProp
}
//Propigate sets and returns the Propigate flag
func (n *NanProp) Propigate() NanProp {
n.NANProp.Propigate()
return *n
}
//NotPropigate sets and returns the NotPropigate flag
func (n *NanProp) NotPropigate() NanProp {
n.NANProp.NotPropigate()
return *n
}
//BatchNormMode struct wrapper for gocudnn.BatchNormMode. Look up methods in gocudnn.
type BatchNormMode struct {
gocudnn.BatchNormMode
}
//PerActivation sets and returns the PerActivation flag
func (b *BatchNormMode) PerActivation() BatchNormMode {
b.BatchNormMode.PerActivation()
return *b
}
//Spatial sets and returns the Spatial flag
func (b *BatchNormMode) Spatial() BatchNormMode {
b.BatchNormMode.Spatial()
return *b
}
//SpatialPersistent sets and returns the SpatialPersistent flag
func (b *BatchNormMode) SpatialPersistent() BatchNormMode {
b.BatchNormMode.SpatialPersistent()
return *b
}
//BatchNormOps struct wrapper for gocudnn.BatchNormOps. Look up methods in gocudnn.
type BatchNormOps struct {
gocudnn.BatchNormOps
}
//Activation sets and returns the Activation flag
func (b *BatchNormOps) Activation() BatchNormOps {
b.BatchNormOps.Activation()
return *b
}
//Normal sets and returns the Normal flag
func (b *BatchNormOps) Normal() BatchNormOps {
b.BatchNormOps.Normal()
return *b
}
//AddActivation sets and returns the AddActivation flag
func (b *BatchNormOps) AddActivation() BatchNormOps {
b.BatchNormOps.AddActivation()
return *b
}
//PoolingMode struct wrapper for gocudnn.PoolingMode. Look up methods in gocudnn.
type PoolingMode struct {
gocudnn.PoolingMode
}
//AverageCountExcludePadding sets and returns the AverageCountExcludePadding flag
func (p *PoolingMode) AverageCountExcludePadding() PoolingMode {
p.PoolingMode.AverageCountExcludePadding()
return *p
}
//AverageCountIncludePadding sets and returns the AverageCountIncludePadding flag
func (p *PoolingMode) AverageCountIncludePadding() PoolingMode {
p.PoolingMode.AverageCountIncludePadding()
return *p
}
//Max sets and returns the Max flag
func (p *PoolingMode) Max() PoolingMode {
p.PoolingMode.Max()
return *p
}
//MaxDeterministic sets and returns the MaxDeterministic flag
func (p *PoolingMode) MaxDeterministic() PoolingMode {
p.PoolingMode.MaxDeterministic()
return *p
}
//ActivationMode struct wrapper for gocudnn.ActivationMode. Look up methods in gocudnn.
type ActivationMode struct {
act.Mode
}
//ClippedRelu sets and returns the ClippedRelu flag
func (a *ActivationMode) ClippedRelu() ActivationMode {
a.Mode.ClippedRelu()
return *a
}
//Elu sets and returns the Elu flag
func (a *ActivationMode) Elu() ActivationMode {
a.Mode.Elu()
return *a
}
//Identity sets and returns the Identity flag
func (a *ActivationMode) Identity() ActivationMode {
a.Mode.Identity()
return *a
}
//Leaky sets and returns the Leaky flag
func (a *ActivationMode) Leaky() ActivationMode {
a.Mode.Leaky()
return *a
}
//PRelu sets and returns the PRelu flag
func (a *ActivationMode) PRelu() ActivationMode {
a.Mode.PRelu()
return *a
}
//Relu sets and returns the Relu flag
func (a *ActivationMode) Relu() ActivationMode {
a.Mode.Relu()
return *a
}
//Sigmoid sets and returns the Sigmoid flag
func (a *ActivationMode) Sigmoid() ActivationMode {
a.Mode.Sigmoid()
return *a
}
//Tanh sets and returns the Tanh flag
func (a *ActivationMode) Tanh() ActivationMode {
a.Mode.Tanh()
return *a
}
//Threshhold sets and returns the Threshhold flag
func (a *ActivationMode) Threshhold() ActivationMode {
a.Mode.Threshhold()
return *a
}
//SoftmaxAlgo determins what algo to use for softmax
type SoftmaxAlgo struct {
gocudnn.SoftMaxAlgorithm
}
//Accurate sets and returns the Accurate flag
func (s *SoftmaxAlgo) Accurate() SoftmaxAlgo {
s.SoftMaxAlgorithm.Accurate()
return *s
}
//Fast sets and returns the Fast flag
func (s *SoftmaxAlgo) Fast() SoftmaxAlgo {
s.SoftMaxAlgorithm.Fast()
return *s
}
//Log sets and returns the Log flag
func (s *SoftmaxAlgo) Log() SoftmaxAlgo {
s.SoftMaxAlgorithm.Log()
return *s
}
//SoftmaxMode determins what mode to use for softmax
type SoftmaxMode struct {
gocudnn.SoftMaxMode
}
//Channel sets and returns the Channel flag
func (s *SoftmaxMode) Channel() SoftmaxMode {
s.SoftMaxMode.Channel()
return *s
}
//Instance sets and returns the Instance flag
func (s *SoftmaxMode) Instance() SoftmaxMode {
s.SoftMaxMode.Instance()
return *s
}
//MathType is math type for tensor cores
type MathType struct {
gocudnn.MathType
}
//AllowConversion sets and returns the AllowConversion flag
func (m *MathType) AllowConversion() MathType {
m.MathType.AllowConversion()
return *m
}
//Default sets and returns the Default flag
func (m *MathType) Default() MathType {
m.MathType.Default()
return *m
}
//TensorOpMath sets and returns the TensorOpMath flag
func (m *MathType) TensorOpMath() MathType {
m.MathType.TensorOpMath()
return *m
}
//Flags is a struct that should only be used for passing flags.
var Flags struct {
Format TensorFormat
Dtype DataType
Nan NanProp
CMode ConvolutionMode
BNMode BatchNormMode
BNOps BatchNormOps
PMode PoolingMode
AMode ActivationMode
SMMode SoftmaxMode
SMAlgo SoftmaxAlgo
MType MathType
//EleOp ElementwiseOp
}
var pflags struct {
Format gocudnn.TensorFormat
Dtype gocudnn.DataType
Nan gocudnn.NANProp
CMode gocudnn.ConvolutionMode
BNMode gocudnn.BatchNormMode
BNOps gocudnn.BatchNormOps
PMode gocudnn.PoolingMode
AMode act.Mode
SMmode gocudnn.SoftMaxMode
SMAlgo gocudnn.SoftMaxAlgorithm
}