|
| 1 | +include "Tensor.fbs" |
| 2 | + |
| 3 | +namespace org.apache.arrow.flatbuf; |
| 4 | + |
| 5 | +/// Coodinate format. |
| 6 | +table SparseTensorIndexCOO { |
| 7 | + /// COO's index list are represented as a NxM matrix, |
| 8 | + /// where N is the number of non-zero values, |
| 9 | + /// and M is the number of dimensions of a sparse tensor. |
| 10 | + /// indicesBuffer stores the location and size of this index matrix. |
| 11 | + /// The type of index value is long, so the stride for the index matrix is unnecessary. |
| 12 | + indicesBuffer: Buffer |
| 13 | +}; |
| 14 | + |
| 15 | +/// Compressed Sparse Row format, that is matrix-specific. |
| 16 | +table SparseMatrixIndexCSR { |
| 17 | + /// This array represents the range of the rows. |
| 18 | + /// The ith row spans from indptr[i] to indptr[i+1] in the data. |
| 19 | + /// The length of this array is 1 + (the number of rows). |
| 20 | + indptr: [long] |
| 21 | + |
| 22 | + /// indicesBuffer stores the location and size of the array that |
| 23 | + /// contains the column indices of the corresponding non-zero values. |
| 24 | + /// The type of index value is long. |
| 25 | + indicesBuffer: Buffer |
| 26 | +}; |
| 27 | + |
| 28 | +union SparseTensorIndex { |
| 29 | + SparseTensorIndexCOO, |
| 30 | + SparseMatrixIndexCSR |
| 31 | +}; |
| 32 | + |
| 33 | +table SparseTensor { |
| 34 | + /// The type of data contained in a value cell. |
| 35 | + /// Currently only fixed-width value types are supported, |
| 36 | + /// no strings or nested types. |
| 37 | + type: Type; |
| 38 | + |
| 39 | + /// The dimensions of the tensor, optionally named. |
| 40 | + shape: [TensorDim]; |
| 41 | + |
| 42 | + /// The number of non-zero values in a sparse tensor. |
| 43 | + length: long |
| 44 | + |
| 45 | + /// Sparse tensor index |
| 46 | + sparseIndex: SparseTensorIndex; |
| 47 | + |
| 48 | + /// The location and size of the tensor's data |
| 49 | + data: Buffer; |
| 50 | +} |
| 51 | + |
| 52 | +root_type SparseTensor; |
0 commit comments