github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/col/colserde/arrowserde/tensor_generated.go (about) 1 // Code generated by the FlatBuffers compiler. DO NOT EDIT. 2 3 package arrowserde 4 5 import flatbuffers "github.com/google/flatbuffers/go" 6 7 type SparseTensorIndex = byte 8 9 const ( 10 SparseTensorIndexNONE SparseTensorIndex = 0 11 SparseTensorIndexSparseTensorIndexCOO SparseTensorIndex = 1 12 SparseTensorIndexSparseMatrixIndexCSR SparseTensorIndex = 2 13 ) 14 15 var EnumNamesSparseTensorIndex = map[SparseTensorIndex]string{ 16 SparseTensorIndexNONE: "NONE", 17 SparseTensorIndexSparseTensorIndexCOO: "SparseTensorIndexCOO", 18 SparseTensorIndexSparseMatrixIndexCSR: "SparseMatrixIndexCSR", 19 } 20 21 /// ---------------------------------------------------------------------- 22 /// Data structures for dense tensors 23 /// Shape data for a single axis in a tensor 24 type TensorDim struct { 25 _tab flatbuffers.Table 26 } 27 28 func GetRootAsTensorDim(buf []byte, offset flatbuffers.UOffsetT) *TensorDim { 29 n := flatbuffers.GetUOffsetT(buf[offset:]) 30 x := &TensorDim{} 31 x.Init(buf, n+offset) 32 return x 33 } 34 35 func (rcv *TensorDim) Init(buf []byte, i flatbuffers.UOffsetT) { 36 rcv._tab.Bytes = buf 37 rcv._tab.Pos = i 38 } 39 40 func (rcv *TensorDim) Table() flatbuffers.Table { 41 return rcv._tab 42 } 43 44 /// Length of dimension 45 func (rcv *TensorDim) Size() int64 { 46 o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) 47 if o != 0 { 48 return rcv._tab.GetInt64(o + rcv._tab.Pos) 49 } 50 return 0 51 } 52 53 /// Length of dimension 54 func (rcv *TensorDim) MutateSize(n int64) bool { 55 return rcv._tab.MutateInt64Slot(4, n) 56 } 57 58 /// Name of the dimension, optional 59 func (rcv *TensorDim) Name() []byte { 60 o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) 61 if o != 0 { 62 return rcv._tab.ByteVector(o + rcv._tab.Pos) 63 } 64 return nil 65 } 66 67 /// Name of the dimension, optional 68 func TensorDimStart(builder *flatbuffers.Builder) { 69 builder.StartObject(2) 70 } 71 func TensorDimAddSize(builder *flatbuffers.Builder, size int64) { 72 builder.PrependInt64Slot(0, size, 0) 73 } 74 func TensorDimAddName(builder *flatbuffers.Builder, name flatbuffers.UOffsetT) { 75 builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(name), 0) 76 } 77 func TensorDimEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { 78 return builder.EndObject() 79 } 80 81 type Tensor struct { 82 _tab flatbuffers.Table 83 } 84 85 func GetRootAsTensor(buf []byte, offset flatbuffers.UOffsetT) *Tensor { 86 n := flatbuffers.GetUOffsetT(buf[offset:]) 87 x := &Tensor{} 88 x.Init(buf, n+offset) 89 return x 90 } 91 92 func (rcv *Tensor) Init(buf []byte, i flatbuffers.UOffsetT) { 93 rcv._tab.Bytes = buf 94 rcv._tab.Pos = i 95 } 96 97 func (rcv *Tensor) Table() flatbuffers.Table { 98 return rcv._tab 99 } 100 101 func (rcv *Tensor) TypeType() byte { 102 o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) 103 if o != 0 { 104 return rcv._tab.GetByte(o + rcv._tab.Pos) 105 } 106 return 0 107 } 108 109 func (rcv *Tensor) MutateTypeType(n byte) bool { 110 return rcv._tab.MutateByteSlot(4, n) 111 } 112 113 /// The type of data contained in a value cell. Currently only fixed-width 114 /// value types are supported, no strings or nested types 115 func (rcv *Tensor) Type(obj *flatbuffers.Table) bool { 116 o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) 117 if o != 0 { 118 rcv._tab.Union(obj, o) 119 return true 120 } 121 return false 122 } 123 124 /// The type of data contained in a value cell. Currently only fixed-width 125 /// value types are supported, no strings or nested types 126 /// The dimensions of the tensor, optionally named 127 func (rcv *Tensor) Shape(obj *TensorDim, j int) bool { 128 o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) 129 if o != 0 { 130 x := rcv._tab.Vector(o) 131 x += flatbuffers.UOffsetT(j) * 4 132 x = rcv._tab.Indirect(x) 133 obj.Init(rcv._tab.Bytes, x) 134 return true 135 } 136 return false 137 } 138 139 func (rcv *Tensor) ShapeLength() int { 140 o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) 141 if o != 0 { 142 return rcv._tab.VectorLen(o) 143 } 144 return 0 145 } 146 147 /// The dimensions of the tensor, optionally named 148 /// Non-negative byte offsets to advance one value cell along each dimension 149 func (rcv *Tensor) Strides(j int) int64 { 150 o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) 151 if o != 0 { 152 a := rcv._tab.Vector(o) 153 return rcv._tab.GetInt64(a + flatbuffers.UOffsetT(j*8)) 154 } 155 return 0 156 } 157 158 func (rcv *Tensor) StridesLength() int { 159 o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) 160 if o != 0 { 161 return rcv._tab.VectorLen(o) 162 } 163 return 0 164 } 165 166 /// Non-negative byte offsets to advance one value cell along each dimension 167 /// The location and size of the tensor's data 168 func (rcv *Tensor) Data(obj *Buffer) *Buffer { 169 o := flatbuffers.UOffsetT(rcv._tab.Offset(12)) 170 if o != 0 { 171 x := o + rcv._tab.Pos 172 if obj == nil { 173 obj = new(Buffer) 174 } 175 obj.Init(rcv._tab.Bytes, x) 176 return obj 177 } 178 return nil 179 } 180 181 /// The location and size of the tensor's data 182 func TensorStart(builder *flatbuffers.Builder) { 183 builder.StartObject(5) 184 } 185 func TensorAddTypeType(builder *flatbuffers.Builder, typeType byte) { 186 builder.PrependByteSlot(0, typeType, 0) 187 } 188 func TensorAddType(builder *flatbuffers.Builder, type_ flatbuffers.UOffsetT) { 189 builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(type_), 0) 190 } 191 func TensorAddShape(builder *flatbuffers.Builder, shape flatbuffers.UOffsetT) { 192 builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(shape), 0) 193 } 194 func TensorStartShapeVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { 195 return builder.StartVector(4, numElems, 4) 196 } 197 func TensorAddStrides(builder *flatbuffers.Builder, strides flatbuffers.UOffsetT) { 198 builder.PrependUOffsetTSlot(3, flatbuffers.UOffsetT(strides), 0) 199 } 200 func TensorStartStridesVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { 201 return builder.StartVector(8, numElems, 8) 202 } 203 func TensorAddData(builder *flatbuffers.Builder, data flatbuffers.UOffsetT) { 204 builder.PrependStructSlot(4, flatbuffers.UOffsetT(data), 0) 205 } 206 func TensorEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { 207 return builder.EndObject() 208 } 209 210 /// ---------------------------------------------------------------------- 211 /// EXPERIMENTAL: Data structures for sparse tensors 212 /// Coodinate format of sparse tensor index. 213 type SparseTensorIndexCOO struct { 214 _tab flatbuffers.Table 215 } 216 217 func GetRootAsSparseTensorIndexCOO(buf []byte, offset flatbuffers.UOffsetT) *SparseTensorIndexCOO { 218 n := flatbuffers.GetUOffsetT(buf[offset:]) 219 x := &SparseTensorIndexCOO{} 220 x.Init(buf, n+offset) 221 return x 222 } 223 224 func (rcv *SparseTensorIndexCOO) Init(buf []byte, i flatbuffers.UOffsetT) { 225 rcv._tab.Bytes = buf 226 rcv._tab.Pos = i 227 } 228 229 func (rcv *SparseTensorIndexCOO) Table() flatbuffers.Table { 230 return rcv._tab 231 } 232 233 /// COO's index list are represented as a NxM matrix, 234 /// where N is the number of non-zero values, 235 /// and M is the number of dimensions of a sparse tensor. 236 /// indicesBuffer stores the location and size of this index matrix. 237 /// The type of index value is long, so the stride for the index matrix is unnecessary. 238 /// 239 /// For example, let X be a 2x3x4x5 tensor, and it has the following 6 non-zero values: 240 /// 241 /// X[0, 1, 2, 0] := 1 242 /// X[1, 1, 2, 3] := 2 243 /// X[0, 2, 1, 0] := 3 244 /// X[0, 1, 3, 0] := 4 245 /// X[0, 1, 2, 1] := 5 246 /// X[1, 2, 0, 4] := 6 247 /// 248 /// In COO format, the index matrix of X is the following 4x6 matrix: 249 /// 250 /// [[0, 0, 0, 0, 1, 1], 251 /// [1, 1, 1, 2, 1, 2], 252 /// [2, 2, 3, 1, 2, 0], 253 /// [0, 1, 0, 0, 3, 4]] 254 /// 255 /// Note that the indices are sorted in lexcographical order. 256 func (rcv *SparseTensorIndexCOO) IndicesBuffer(obj *Buffer) *Buffer { 257 o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) 258 if o != 0 { 259 x := o + rcv._tab.Pos 260 if obj == nil { 261 obj = new(Buffer) 262 } 263 obj.Init(rcv._tab.Bytes, x) 264 return obj 265 } 266 return nil 267 } 268 269 /// COO's index list are represented as a NxM matrix, 270 /// where N is the number of non-zero values, 271 /// and M is the number of dimensions of a sparse tensor. 272 /// indicesBuffer stores the location and size of this index matrix. 273 /// The type of index value is long, so the stride for the index matrix is unnecessary. 274 /// 275 /// For example, let X be a 2x3x4x5 tensor, and it has the following 6 non-zero values: 276 /// 277 /// X[0, 1, 2, 0] := 1 278 /// X[1, 1, 2, 3] := 2 279 /// X[0, 2, 1, 0] := 3 280 /// X[0, 1, 3, 0] := 4 281 /// X[0, 1, 2, 1] := 5 282 /// X[1, 2, 0, 4] := 6 283 /// 284 /// In COO format, the index matrix of X is the following 4x6 matrix: 285 /// 286 /// [[0, 0, 0, 0, 1, 1], 287 /// [1, 1, 1, 2, 1, 2], 288 /// [2, 2, 3, 1, 2, 0], 289 /// [0, 1, 0, 0, 3, 4]] 290 /// 291 /// Note that the indices are sorted in lexcographical order. 292 func SparseTensorIndexCOOStart(builder *flatbuffers.Builder) { 293 builder.StartObject(1) 294 } 295 func SparseTensorIndexCOOAddIndicesBuffer( 296 builder *flatbuffers.Builder, indicesBuffer flatbuffers.UOffsetT, 297 ) { 298 builder.PrependStructSlot(0, flatbuffers.UOffsetT(indicesBuffer), 0) 299 } 300 func SparseTensorIndexCOOEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { 301 return builder.EndObject() 302 } 303 304 /// Compressed Sparse Row format, that is matrix-specific. 305 type SparseMatrixIndexCSR struct { 306 _tab flatbuffers.Table 307 } 308 309 func GetRootAsSparseMatrixIndexCSR(buf []byte, offset flatbuffers.UOffsetT) *SparseMatrixIndexCSR { 310 n := flatbuffers.GetUOffsetT(buf[offset:]) 311 x := &SparseMatrixIndexCSR{} 312 x.Init(buf, n+offset) 313 return x 314 } 315 316 func (rcv *SparseMatrixIndexCSR) Init(buf []byte, i flatbuffers.UOffsetT) { 317 rcv._tab.Bytes = buf 318 rcv._tab.Pos = i 319 } 320 321 func (rcv *SparseMatrixIndexCSR) Table() flatbuffers.Table { 322 return rcv._tab 323 } 324 325 /// indptrBuffer stores the location and size of indptr array that 326 /// represents the range of the rows. 327 /// The i-th row spans from indptr[i] to indptr[i+1] in the data. 328 /// The length of this array is 1 + (the number of rows), and the type 329 /// of index value is long. 330 /// 331 /// For example, let X be the following 6x4 matrix: 332 /// 333 /// X := [[0, 1, 2, 0], 334 /// [0, 0, 3, 0], 335 /// [0, 4, 0, 5], 336 /// [0, 0, 0, 0], 337 /// [6, 0, 7, 8], 338 /// [0, 9, 0, 0]]. 339 /// 340 /// The array of non-zero values in X is: 341 /// 342 /// values(X) = [1, 2, 3, 4, 5, 6, 7, 8, 9]. 343 /// 344 /// And the indptr of X is: 345 /// 346 /// indptr(X) = [0, 2, 3, 5, 5, 8, 10]. 347 func (rcv *SparseMatrixIndexCSR) IndptrBuffer(obj *Buffer) *Buffer { 348 o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) 349 if o != 0 { 350 x := o + rcv._tab.Pos 351 if obj == nil { 352 obj = new(Buffer) 353 } 354 obj.Init(rcv._tab.Bytes, x) 355 return obj 356 } 357 return nil 358 } 359 360 /// indptrBuffer stores the location and size of indptr array that 361 /// represents the range of the rows. 362 /// The i-th row spans from indptr[i] to indptr[i+1] in the data. 363 /// The length of this array is 1 + (the number of rows), and the type 364 /// of index value is long. 365 /// 366 /// For example, let X be the following 6x4 matrix: 367 /// 368 /// X := [[0, 1, 2, 0], 369 /// [0, 0, 3, 0], 370 /// [0, 4, 0, 5], 371 /// [0, 0, 0, 0], 372 /// [6, 0, 7, 8], 373 /// [0, 9, 0, 0]]. 374 /// 375 /// The array of non-zero values in X is: 376 /// 377 /// values(X) = [1, 2, 3, 4, 5, 6, 7, 8, 9]. 378 /// 379 /// And the indptr of X is: 380 /// 381 /// indptr(X) = [0, 2, 3, 5, 5, 8, 10]. 382 /// indicesBuffer stores the location and size of the array that 383 /// contains the column indices of the corresponding non-zero values. 384 /// The type of index value is long. 385 /// 386 /// For example, the indices of the above X is: 387 /// 388 /// indices(X) = [1, 2, 2, 1, 3, 0, 2, 3, 1]. 389 func (rcv *SparseMatrixIndexCSR) IndicesBuffer(obj *Buffer) *Buffer { 390 o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) 391 if o != 0 { 392 x := o + rcv._tab.Pos 393 if obj == nil { 394 obj = new(Buffer) 395 } 396 obj.Init(rcv._tab.Bytes, x) 397 return obj 398 } 399 return nil 400 } 401 402 /// indicesBuffer stores the location and size of the array that 403 /// contains the column indices of the corresponding non-zero values. 404 /// The type of index value is long. 405 /// 406 /// For example, the indices of the above X is: 407 /// 408 /// indices(X) = [1, 2, 2, 1, 3, 0, 2, 3, 1]. 409 func SparseMatrixIndexCSRStart(builder *flatbuffers.Builder) { 410 builder.StartObject(2) 411 } 412 func SparseMatrixIndexCSRAddIndptrBuffer( 413 builder *flatbuffers.Builder, indptrBuffer flatbuffers.UOffsetT, 414 ) { 415 builder.PrependStructSlot(0, flatbuffers.UOffsetT(indptrBuffer), 0) 416 } 417 func SparseMatrixIndexCSRAddIndicesBuffer( 418 builder *flatbuffers.Builder, indicesBuffer flatbuffers.UOffsetT, 419 ) { 420 builder.PrependStructSlot(1, flatbuffers.UOffsetT(indicesBuffer), 0) 421 } 422 func SparseMatrixIndexCSREnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { 423 return builder.EndObject() 424 } 425 426 type SparseTensor struct { 427 _tab flatbuffers.Table 428 } 429 430 func GetRootAsSparseTensor(buf []byte, offset flatbuffers.UOffsetT) *SparseTensor { 431 n := flatbuffers.GetUOffsetT(buf[offset:]) 432 x := &SparseTensor{} 433 x.Init(buf, n+offset) 434 return x 435 } 436 437 func (rcv *SparseTensor) Init(buf []byte, i flatbuffers.UOffsetT) { 438 rcv._tab.Bytes = buf 439 rcv._tab.Pos = i 440 } 441 442 func (rcv *SparseTensor) Table() flatbuffers.Table { 443 return rcv._tab 444 } 445 446 func (rcv *SparseTensor) TypeType() byte { 447 o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) 448 if o != 0 { 449 return rcv._tab.GetByte(o + rcv._tab.Pos) 450 } 451 return 0 452 } 453 454 func (rcv *SparseTensor) MutateTypeType(n byte) bool { 455 return rcv._tab.MutateByteSlot(4, n) 456 } 457 458 /// The type of data contained in a value cell. 459 /// Currently only fixed-width value types are supported, 460 /// no strings or nested types. 461 func (rcv *SparseTensor) Type(obj *flatbuffers.Table) bool { 462 o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) 463 if o != 0 { 464 rcv._tab.Union(obj, o) 465 return true 466 } 467 return false 468 } 469 470 /// The type of data contained in a value cell. 471 /// Currently only fixed-width value types are supported, 472 /// no strings or nested types. 473 /// The dimensions of the tensor, optionally named. 474 func (rcv *SparseTensor) Shape(obj *TensorDim, j int) bool { 475 o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) 476 if o != 0 { 477 x := rcv._tab.Vector(o) 478 x += flatbuffers.UOffsetT(j) * 4 479 x = rcv._tab.Indirect(x) 480 obj.Init(rcv._tab.Bytes, x) 481 return true 482 } 483 return false 484 } 485 486 func (rcv *SparseTensor) ShapeLength() int { 487 o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) 488 if o != 0 { 489 return rcv._tab.VectorLen(o) 490 } 491 return 0 492 } 493 494 /// The dimensions of the tensor, optionally named. 495 /// The number of non-zero values in a sparse tensor. 496 func (rcv *SparseTensor) NonZeroLength() int64 { 497 o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) 498 if o != 0 { 499 return rcv._tab.GetInt64(o + rcv._tab.Pos) 500 } 501 return 0 502 } 503 504 /// The number of non-zero values in a sparse tensor. 505 func (rcv *SparseTensor) MutateNonZeroLength(n int64) bool { 506 return rcv._tab.MutateInt64Slot(10, n) 507 } 508 509 func (rcv *SparseTensor) SparseIndexType() byte { 510 o := flatbuffers.UOffsetT(rcv._tab.Offset(12)) 511 if o != 0 { 512 return rcv._tab.GetByte(o + rcv._tab.Pos) 513 } 514 return 0 515 } 516 517 func (rcv *SparseTensor) MutateSparseIndexType(n byte) bool { 518 return rcv._tab.MutateByteSlot(12, n) 519 } 520 521 /// Sparse tensor index 522 func (rcv *SparseTensor) SparseIndex(obj *flatbuffers.Table) bool { 523 o := flatbuffers.UOffsetT(rcv._tab.Offset(14)) 524 if o != 0 { 525 rcv._tab.Union(obj, o) 526 return true 527 } 528 return false 529 } 530 531 /// Sparse tensor index 532 /// The location and size of the tensor's data 533 func (rcv *SparseTensor) Data(obj *Buffer) *Buffer { 534 o := flatbuffers.UOffsetT(rcv._tab.Offset(16)) 535 if o != 0 { 536 x := o + rcv._tab.Pos 537 if obj == nil { 538 obj = new(Buffer) 539 } 540 obj.Init(rcv._tab.Bytes, x) 541 return obj 542 } 543 return nil 544 } 545 546 /// The location and size of the tensor's data 547 func SparseTensorStart(builder *flatbuffers.Builder) { 548 builder.StartObject(7) 549 } 550 func SparseTensorAddTypeType(builder *flatbuffers.Builder, typeType byte) { 551 builder.PrependByteSlot(0, typeType, 0) 552 } 553 func SparseTensorAddType(builder *flatbuffers.Builder, type_ flatbuffers.UOffsetT) { 554 builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(type_), 0) 555 } 556 func SparseTensorAddShape(builder *flatbuffers.Builder, shape flatbuffers.UOffsetT) { 557 builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(shape), 0) 558 } 559 func SparseTensorStartShapeVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { 560 return builder.StartVector(4, numElems, 4) 561 } 562 func SparseTensorAddNonZeroLength(builder *flatbuffers.Builder, nonZeroLength int64) { 563 builder.PrependInt64Slot(3, nonZeroLength, 0) 564 } 565 func SparseTensorAddSparseIndexType(builder *flatbuffers.Builder, sparseIndexType byte) { 566 builder.PrependByteSlot(4, sparseIndexType, 0) 567 } 568 func SparseTensorAddSparseIndex(builder *flatbuffers.Builder, sparseIndex flatbuffers.UOffsetT) { 569 builder.PrependUOffsetTSlot(5, flatbuffers.UOffsetT(sparseIndex), 0) 570 } 571 func SparseTensorAddData(builder *flatbuffers.Builder, data flatbuffers.UOffsetT) { 572 builder.PrependStructSlot(6, flatbuffers.UOffsetT(data), 0) 573 } 574 func SparseTensorEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { 575 return builder.EndObject() 576 }