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 19package flatbuf 20 21import ( 22 flatbuffers "github.com/google/flatbuffers/go" 23) 24 25type SparseTensor struct { 26 _tab flatbuffers.Table 27} 28 29func GetRootAsSparseTensor(buf []byte, offset flatbuffers.UOffsetT) *SparseTensor { 30 n := flatbuffers.GetUOffsetT(buf[offset:]) 31 x := &SparseTensor{} 32 x.Init(buf, n+offset) 33 return x 34} 35 36func (rcv *SparseTensor) Init(buf []byte, i flatbuffers.UOffsetT) { 37 rcv._tab.Bytes = buf 38 rcv._tab.Pos = i 39} 40 41func (rcv *SparseTensor) Table() flatbuffers.Table { 42 return rcv._tab 43} 44 45func (rcv *SparseTensor) TypeType() Type { 46 o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) 47 if o != 0 { 48 return Type(rcv._tab.GetByte(o + rcv._tab.Pos)) 49 } 50 return 0 51} 52 53func (rcv *SparseTensor) MutateTypeType(n Type) bool { 54 return rcv._tab.MutateByteSlot(4, byte(n)) 55} 56 57/// The type of data contained in a value cell. 58/// Currently only fixed-width value types are supported, 59/// no strings or nested types. 60func (rcv *SparseTensor) Type(obj *flatbuffers.Table) bool { 61 o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) 62 if o != 0 { 63 rcv._tab.Union(obj, o) 64 return true 65 } 66 return false 67} 68 69/// The type of data contained in a value cell. 70/// Currently only fixed-width value types are supported, 71/// no strings or nested types. 72/// The dimensions of the tensor, optionally named. 73func (rcv *SparseTensor) Shape(obj *TensorDim, j int) bool { 74 o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) 75 if o != 0 { 76 x := rcv._tab.Vector(o) 77 x += flatbuffers.UOffsetT(j) * 4 78 x = rcv._tab.Indirect(x) 79 obj.Init(rcv._tab.Bytes, x) 80 return true 81 } 82 return false 83} 84 85func (rcv *SparseTensor) ShapeLength() int { 86 o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) 87 if o != 0 { 88 return rcv._tab.VectorLen(o) 89 } 90 return 0 91} 92 93/// The dimensions of the tensor, optionally named. 94/// The number of non-zero values in a sparse tensor. 95func (rcv *SparseTensor) NonZeroLength() int64 { 96 o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) 97 if o != 0 { 98 return rcv._tab.GetInt64(o + rcv._tab.Pos) 99 } 100 return 0 101} 102 103/// The number of non-zero values in a sparse tensor. 104func (rcv *SparseTensor) MutateNonZeroLength(n int64) bool { 105 return rcv._tab.MutateInt64Slot(10, n) 106} 107 108func (rcv *SparseTensor) SparseIndexType() SparseTensorIndex { 109 o := flatbuffers.UOffsetT(rcv._tab.Offset(12)) 110 if o != 0 { 111 return SparseTensorIndex(rcv._tab.GetByte(o + rcv._tab.Pos)) 112 } 113 return 0 114} 115 116func (rcv *SparseTensor) MutateSparseIndexType(n SparseTensorIndex) bool { 117 return rcv._tab.MutateByteSlot(12, byte(n)) 118} 119 120/// Sparse tensor index 121func (rcv *SparseTensor) SparseIndex(obj *flatbuffers.Table) bool { 122 o := flatbuffers.UOffsetT(rcv._tab.Offset(14)) 123 if o != 0 { 124 rcv._tab.Union(obj, o) 125 return true 126 } 127 return false 128} 129 130/// Sparse tensor index 131/// The location and size of the tensor's data 132func (rcv *SparseTensor) Data(obj *Buffer) *Buffer { 133 o := flatbuffers.UOffsetT(rcv._tab.Offset(16)) 134 if o != 0 { 135 x := o + rcv._tab.Pos 136 if obj == nil { 137 obj = new(Buffer) 138 } 139 obj.Init(rcv._tab.Bytes, x) 140 return obj 141 } 142 return nil 143} 144 145/// The location and size of the tensor's data 146func SparseTensorStart(builder *flatbuffers.Builder) { 147 builder.StartObject(7) 148} 149func SparseTensorAddTypeType(builder *flatbuffers.Builder, typeType Type) { 150 builder.PrependByteSlot(0, byte(typeType), 0) 151} 152func SparseTensorAddType(builder *flatbuffers.Builder, type_ flatbuffers.UOffsetT) { 153 builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(type_), 0) 154} 155func SparseTensorAddShape(builder *flatbuffers.Builder, shape flatbuffers.UOffsetT) { 156 builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(shape), 0) 157} 158func SparseTensorStartShapeVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { 159 return builder.StartVector(4, numElems, 4) 160} 161func SparseTensorAddNonZeroLength(builder *flatbuffers.Builder, nonZeroLength int64) { 162 builder.PrependInt64Slot(3, nonZeroLength, 0) 163} 164func SparseTensorAddSparseIndexType(builder *flatbuffers.Builder, sparseIndexType SparseTensorIndex) { 165 builder.PrependByteSlot(4, byte(sparseIndexType), 0) 166} 167func SparseTensorAddSparseIndex(builder *flatbuffers.Builder, sparseIndex flatbuffers.UOffsetT) { 168 builder.PrependUOffsetTSlot(5, flatbuffers.UOffsetT(sparseIndex), 0) 169} 170func SparseTensorAddData(builder *flatbuffers.Builder, data flatbuffers.UOffsetT) { 171 builder.PrependStructSlot(6, flatbuffers.UOffsetT(data), 0) 172} 173func SparseTensorEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { 174 return builder.EndObject() 175} 176