]>
Commit | Line | Data |
---|---|---|
1d09f67e TL |
1 | // Licensed to the Apache Software Foundation (ASF) under one |
2 | // or more contributor license agreements. See the NOTICE file | |
3 | // distributed with this work for additional information | |
4 | // regarding copyright ownership. The ASF licenses this file | |
5 | // to you under the Apache License, Version 2.0 (the | |
6 | // "License"); you may not use this file except in compliance | |
7 | // with the License. You may obtain a copy of the License at | |
8 | // | |
9 | // http://www.apache.org/licenses/LICENSE-2.0 | |
10 | // | |
11 | // Unless required by applicable law or agreed to in writing, software | |
12 | // distributed under the License is distributed on an "AS IS" BASIS, | |
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | // See the License for the specific language governing permissions and | |
15 | // limitations under the License. | |
16 | ||
17 | // Code generated by the FlatBuffers compiler. DO NOT EDIT. | |
18 | ||
19 | package flatbuf | |
20 | ||
21 | import ( | |
22 | flatbuffers "github.com/google/flatbuffers/go" | |
23 | ) | |
24 | ||
25 | /// Compressed Sparse Fiber (CSF) sparse tensor index. | |
26 | type SparseTensorIndexCSF struct { | |
27 | _tab flatbuffers.Table | |
28 | } | |
29 | ||
30 | func GetRootAsSparseTensorIndexCSF(buf []byte, offset flatbuffers.UOffsetT) *SparseTensorIndexCSF { | |
31 | n := flatbuffers.GetUOffsetT(buf[offset:]) | |
32 | x := &SparseTensorIndexCSF{} | |
33 | x.Init(buf, n+offset) | |
34 | return x | |
35 | } | |
36 | ||
37 | func (rcv *SparseTensorIndexCSF) Init(buf []byte, i flatbuffers.UOffsetT) { | |
38 | rcv._tab.Bytes = buf | |
39 | rcv._tab.Pos = i | |
40 | } | |
41 | ||
42 | func (rcv *SparseTensorIndexCSF) Table() flatbuffers.Table { | |
43 | return rcv._tab | |
44 | } | |
45 | ||
46 | /// CSF is a generalization of compressed sparse row (CSR) index. | |
47 | /// See [smith2017knl](http://shaden.io/pub-files/smith2017knl.pdf) | |
48 | /// | |
49 | /// CSF index recursively compresses each dimension of a tensor into a set | |
50 | /// of prefix trees. Each path from a root to leaf forms one tensor | |
51 | /// non-zero index. CSF is implemented with two arrays of buffers and one | |
52 | /// arrays of integers. | |
53 | /// | |
54 | /// For example, let X be a 2x3x4x5 tensor and let it have the following | |
55 | /// 8 non-zero values: | |
56 | /// ```text | |
57 | /// X[0, 0, 0, 1] := 1 | |
58 | /// X[0, 0, 0, 2] := 2 | |
59 | /// X[0, 1, 0, 0] := 3 | |
60 | /// X[0, 1, 0, 2] := 4 | |
61 | /// X[0, 1, 1, 0] := 5 | |
62 | /// X[1, 1, 1, 0] := 6 | |
63 | /// X[1, 1, 1, 1] := 7 | |
64 | /// X[1, 1, 1, 2] := 8 | |
65 | /// ``` | |
66 | /// As a prefix tree this would be represented as: | |
67 | /// ```text | |
68 | /// 0 1 | |
69 | /// / \ | | |
70 | /// 0 1 1 | |
71 | /// / / \ | | |
72 | /// 0 0 1 1 | |
73 | /// /| /| | /| | | |
74 | /// 1 2 0 2 0 0 1 2 | |
75 | /// ``` | |
76 | /// The type of values in indptrBuffers | |
77 | func (rcv *SparseTensorIndexCSF) IndptrType(obj *Int) *Int { | |
78 | o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) | |
79 | if o != 0 { | |
80 | x := rcv._tab.Indirect(o + rcv._tab.Pos) | |
81 | if obj == nil { | |
82 | obj = new(Int) | |
83 | } | |
84 | obj.Init(rcv._tab.Bytes, x) | |
85 | return obj | |
86 | } | |
87 | return nil | |
88 | } | |
89 | ||
90 | /// CSF is a generalization of compressed sparse row (CSR) index. | |
91 | /// See [smith2017knl](http://shaden.io/pub-files/smith2017knl.pdf) | |
92 | /// | |
93 | /// CSF index recursively compresses each dimension of a tensor into a set | |
94 | /// of prefix trees. Each path from a root to leaf forms one tensor | |
95 | /// non-zero index. CSF is implemented with two arrays of buffers and one | |
96 | /// arrays of integers. | |
97 | /// | |
98 | /// For example, let X be a 2x3x4x5 tensor and let it have the following | |
99 | /// 8 non-zero values: | |
100 | /// ```text | |
101 | /// X[0, 0, 0, 1] := 1 | |
102 | /// X[0, 0, 0, 2] := 2 | |
103 | /// X[0, 1, 0, 0] := 3 | |
104 | /// X[0, 1, 0, 2] := 4 | |
105 | /// X[0, 1, 1, 0] := 5 | |
106 | /// X[1, 1, 1, 0] := 6 | |
107 | /// X[1, 1, 1, 1] := 7 | |
108 | /// X[1, 1, 1, 2] := 8 | |
109 | /// ``` | |
110 | /// As a prefix tree this would be represented as: | |
111 | /// ```text | |
112 | /// 0 1 | |
113 | /// / \ | | |
114 | /// 0 1 1 | |
115 | /// / / \ | | |
116 | /// 0 0 1 1 | |
117 | /// /| /| | /| | | |
118 | /// 1 2 0 2 0 0 1 2 | |
119 | /// ``` | |
120 | /// The type of values in indptrBuffers | |
121 | /// indptrBuffers stores the sparsity structure. | |
122 | /// Each two consecutive dimensions in a tensor correspond to a buffer in | |
123 | /// indptrBuffers. A pair of consecutive values at `indptrBuffers[dim][i]` | |
124 | /// and `indptrBuffers[dim][i + 1]` signify a range of nodes in | |
125 | /// `indicesBuffers[dim + 1]` who are children of `indicesBuffers[dim][i]` node. | |
126 | /// | |
127 | /// For example, the indptrBuffers for the above X is: | |
128 | /// ```text | |
129 | /// indptrBuffer(X) = [ | |
130 | /// [0, 2, 3], | |
131 | /// [0, 1, 3, 4], | |
132 | /// [0, 2, 4, 5, 8] | |
133 | /// ]. | |
134 | /// ``` | |
135 | func (rcv *SparseTensorIndexCSF) IndptrBuffers(obj *Buffer, j int) bool { | |
136 | o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) | |
137 | if o != 0 { | |
138 | x := rcv._tab.Vector(o) | |
139 | x += flatbuffers.UOffsetT(j) * 16 | |
140 | obj.Init(rcv._tab.Bytes, x) | |
141 | return true | |
142 | } | |
143 | return false | |
144 | } | |
145 | ||
146 | func (rcv *SparseTensorIndexCSF) IndptrBuffersLength() int { | |
147 | o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) | |
148 | if o != 0 { | |
149 | return rcv._tab.VectorLen(o) | |
150 | } | |
151 | return 0 | |
152 | } | |
153 | ||
154 | /// indptrBuffers stores the sparsity structure. | |
155 | /// Each two consecutive dimensions in a tensor correspond to a buffer in | |
156 | /// indptrBuffers. A pair of consecutive values at `indptrBuffers[dim][i]` | |
157 | /// and `indptrBuffers[dim][i + 1]` signify a range of nodes in | |
158 | /// `indicesBuffers[dim + 1]` who are children of `indicesBuffers[dim][i]` node. | |
159 | /// | |
160 | /// For example, the indptrBuffers for the above X is: | |
161 | /// ```text | |
162 | /// indptrBuffer(X) = [ | |
163 | /// [0, 2, 3], | |
164 | /// [0, 1, 3, 4], | |
165 | /// [0, 2, 4, 5, 8] | |
166 | /// ]. | |
167 | /// ``` | |
168 | /// The type of values in indicesBuffers | |
169 | func (rcv *SparseTensorIndexCSF) IndicesType(obj *Int) *Int { | |
170 | o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) | |
171 | if o != 0 { | |
172 | x := rcv._tab.Indirect(o + rcv._tab.Pos) | |
173 | if obj == nil { | |
174 | obj = new(Int) | |
175 | } | |
176 | obj.Init(rcv._tab.Bytes, x) | |
177 | return obj | |
178 | } | |
179 | return nil | |
180 | } | |
181 | ||
182 | /// The type of values in indicesBuffers | |
183 | /// indicesBuffers stores values of nodes. | |
184 | /// Each tensor dimension corresponds to a buffer in indicesBuffers. | |
185 | /// For example, the indicesBuffers for the above X is: | |
186 | /// ```text | |
187 | /// indicesBuffer(X) = [ | |
188 | /// [0, 1], | |
189 | /// [0, 1, 1], | |
190 | /// [0, 0, 1, 1], | |
191 | /// [1, 2, 0, 2, 0, 0, 1, 2] | |
192 | /// ]. | |
193 | /// ``` | |
194 | func (rcv *SparseTensorIndexCSF) IndicesBuffers(obj *Buffer, j int) bool { | |
195 | o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) | |
196 | if o != 0 { | |
197 | x := rcv._tab.Vector(o) | |
198 | x += flatbuffers.UOffsetT(j) * 16 | |
199 | obj.Init(rcv._tab.Bytes, x) | |
200 | return true | |
201 | } | |
202 | return false | |
203 | } | |
204 | ||
205 | func (rcv *SparseTensorIndexCSF) IndicesBuffersLength() int { | |
206 | o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) | |
207 | if o != 0 { | |
208 | return rcv._tab.VectorLen(o) | |
209 | } | |
210 | return 0 | |
211 | } | |
212 | ||
213 | /// indicesBuffers stores values of nodes. | |
214 | /// Each tensor dimension corresponds to a buffer in indicesBuffers. | |
215 | /// For example, the indicesBuffers for the above X is: | |
216 | /// ```text | |
217 | /// indicesBuffer(X) = [ | |
218 | /// [0, 1], | |
219 | /// [0, 1, 1], | |
220 | /// [0, 0, 1, 1], | |
221 | /// [1, 2, 0, 2, 0, 0, 1, 2] | |
222 | /// ]. | |
223 | /// ``` | |
224 | /// axisOrder stores the sequence in which dimensions were traversed to | |
225 | /// produce the prefix tree. | |
226 | /// For example, the axisOrder for the above X is: | |
227 | /// ```text | |
228 | /// axisOrder(X) = [0, 1, 2, 3]. | |
229 | /// ``` | |
230 | func (rcv *SparseTensorIndexCSF) AxisOrder(j int) int32 { | |
231 | o := flatbuffers.UOffsetT(rcv._tab.Offset(12)) | |
232 | if o != 0 { | |
233 | a := rcv._tab.Vector(o) | |
234 | return rcv._tab.GetInt32(a + flatbuffers.UOffsetT(j*4)) | |
235 | } | |
236 | return 0 | |
237 | } | |
238 | ||
239 | func (rcv *SparseTensorIndexCSF) AxisOrderLength() int { | |
240 | o := flatbuffers.UOffsetT(rcv._tab.Offset(12)) | |
241 | if o != 0 { | |
242 | return rcv._tab.VectorLen(o) | |
243 | } | |
244 | return 0 | |
245 | } | |
246 | ||
247 | /// axisOrder stores the sequence in which dimensions were traversed to | |
248 | /// produce the prefix tree. | |
249 | /// For example, the axisOrder for the above X is: | |
250 | /// ```text | |
251 | /// axisOrder(X) = [0, 1, 2, 3]. | |
252 | /// ``` | |
253 | func (rcv *SparseTensorIndexCSF) MutateAxisOrder(j int, n int32) bool { | |
254 | o := flatbuffers.UOffsetT(rcv._tab.Offset(12)) | |
255 | if o != 0 { | |
256 | a := rcv._tab.Vector(o) | |
257 | return rcv._tab.MutateInt32(a+flatbuffers.UOffsetT(j*4), n) | |
258 | } | |
259 | return false | |
260 | } | |
261 | ||
262 | func SparseTensorIndexCSFStart(builder *flatbuffers.Builder) { | |
263 | builder.StartObject(5) | |
264 | } | |
265 | func SparseTensorIndexCSFAddIndptrType(builder *flatbuffers.Builder, indptrType flatbuffers.UOffsetT) { | |
266 | builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(indptrType), 0) | |
267 | } | |
268 | func SparseTensorIndexCSFAddIndptrBuffers(builder *flatbuffers.Builder, indptrBuffers flatbuffers.UOffsetT) { | |
269 | builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(indptrBuffers), 0) | |
270 | } | |
271 | func SparseTensorIndexCSFStartIndptrBuffersVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { | |
272 | return builder.StartVector(16, numElems, 8) | |
273 | } | |
274 | func SparseTensorIndexCSFAddIndicesType(builder *flatbuffers.Builder, indicesType flatbuffers.UOffsetT) { | |
275 | builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(indicesType), 0) | |
276 | } | |
277 | func SparseTensorIndexCSFAddIndicesBuffers(builder *flatbuffers.Builder, indicesBuffers flatbuffers.UOffsetT) { | |
278 | builder.PrependUOffsetTSlot(3, flatbuffers.UOffsetT(indicesBuffers), 0) | |
279 | } | |
280 | func SparseTensorIndexCSFStartIndicesBuffersVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { | |
281 | return builder.StartVector(16, numElems, 8) | |
282 | } | |
283 | func SparseTensorIndexCSFAddAxisOrder(builder *flatbuffers.Builder, axisOrder flatbuffers.UOffsetT) { | |
284 | builder.PrependUOffsetTSlot(4, flatbuffers.UOffsetT(axisOrder), 0) | |
285 | } | |
286 | func SparseTensorIndexCSFStartAxisOrderVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { | |
287 | return builder.StartVector(4, numElems, 4) | |
288 | } | |
289 | func SparseTensorIndexCSFEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { | |
290 | return builder.EndObject() | |
291 | } |