-
Notifications
You must be signed in to change notification settings - Fork 110
/
NormalizationOptions.go
160 lines (142 loc) · 4.24 KB
/
NormalizationOptions.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
// Code generated by the FlatBuffers compiler. DO NOT EDIT.
package tflite_metadata
import (
flatbuffers "github.com/google/flatbuffers/go"
)
type NormalizationOptionsT struct {
Mean []float32
Std []float32
}
func (t *NormalizationOptionsT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
if t == nil {
return 0
}
meanOffset := flatbuffers.UOffsetT(0)
if t.Mean != nil {
meanLength := len(t.Mean)
NormalizationOptionsStartMeanVector(builder, meanLength)
for j := meanLength - 1; j >= 0; j-- {
builder.PrependFloat32(t.Mean[j])
}
meanOffset = builder.EndVector(meanLength)
}
stdOffset := flatbuffers.UOffsetT(0)
if t.Std != nil {
stdLength := len(t.Std)
NormalizationOptionsStartStdVector(builder, stdLength)
for j := stdLength - 1; j >= 0; j-- {
builder.PrependFloat32(t.Std[j])
}
stdOffset = builder.EndVector(stdLength)
}
NormalizationOptionsStart(builder)
NormalizationOptionsAddMean(builder, meanOffset)
NormalizationOptionsAddStd(builder, stdOffset)
return NormalizationOptionsEnd(builder)
}
func (rcv *NormalizationOptions) UnPackTo(t *NormalizationOptionsT) {
meanLength := rcv.MeanLength()
t.Mean = make([]float32, meanLength)
for j := 0; j < meanLength; j++ {
t.Mean[j] = rcv.Mean(j)
}
stdLength := rcv.StdLength()
t.Std = make([]float32, stdLength)
for j := 0; j < stdLength; j++ {
t.Std[j] = rcv.Std(j)
}
}
func (rcv *NormalizationOptions) UnPack() *NormalizationOptionsT {
if rcv == nil {
return nil
}
t := &NormalizationOptionsT{}
rcv.UnPackTo(t)
return t
}
type NormalizationOptions struct {
_tab flatbuffers.Table
}
func GetRootAsNormalizationOptions(buf []byte, offset flatbuffers.UOffsetT) *NormalizationOptions {
n := flatbuffers.GetUOffsetT(buf[offset:])
x := &NormalizationOptions{}
x.Init(buf, n+offset)
return x
}
func GetSizePrefixedRootAsNormalizationOptions(buf []byte, offset flatbuffers.UOffsetT) *NormalizationOptions {
n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:])
x := &NormalizationOptions{}
x.Init(buf, n+offset+flatbuffers.SizeUint32)
return x
}
func (rcv *NormalizationOptions) Init(buf []byte, i flatbuffers.UOffsetT) {
rcv._tab.Bytes = buf
rcv._tab.Pos = i
}
func (rcv *NormalizationOptions) Table() flatbuffers.Table {
return rcv._tab
}
func (rcv *NormalizationOptions) Mean(j int) float32 {
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
if o != 0 {
a := rcv._tab.Vector(o)
return rcv._tab.GetFloat32(a + flatbuffers.UOffsetT(j*4))
}
return 0
}
func (rcv *NormalizationOptions) MeanLength() int {
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
if o != 0 {
return rcv._tab.VectorLen(o)
}
return 0
}
func (rcv *NormalizationOptions) MutateMean(j int, n float32) bool {
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
if o != 0 {
a := rcv._tab.Vector(o)
return rcv._tab.MutateFloat32(a+flatbuffers.UOffsetT(j*4), n)
}
return false
}
func (rcv *NormalizationOptions) Std(j int) float32 {
o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
if o != 0 {
a := rcv._tab.Vector(o)
return rcv._tab.GetFloat32(a + flatbuffers.UOffsetT(j*4))
}
return 0
}
func (rcv *NormalizationOptions) StdLength() int {
o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
if o != 0 {
return rcv._tab.VectorLen(o)
}
return 0
}
func (rcv *NormalizationOptions) MutateStd(j int, n float32) bool {
o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
if o != 0 {
a := rcv._tab.Vector(o)
return rcv._tab.MutateFloat32(a+flatbuffers.UOffsetT(j*4), n)
}
return false
}
func NormalizationOptionsStart(builder *flatbuffers.Builder) {
builder.StartObject(2)
}
func NormalizationOptionsAddMean(builder *flatbuffers.Builder, mean flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(mean), 0)
}
func NormalizationOptionsStartMeanVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT {
return builder.StartVector(4, numElems, 4)
}
func NormalizationOptionsAddStd(builder *flatbuffers.Builder, std flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(std), 0)
}
func NormalizationOptionsStartStdVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT {
return builder.StartVector(4, numElems, 4)
}
func NormalizationOptionsEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
return builder.EndObject()
}