Class SparseMatrix

java.lang.Object
ai.beestream.jitnn.SparseMatrix

public final class SparseMatrix extends Object
The structure of a sparse matrix (which entries are stored), built once on the host from coordinate lists; the values are a separate tensor, in the order the coordinates were given, so they can be learned. The structure is kept on the device in CSR form and, for the gradient with respect to the dense operand, in CSR form of the transpose.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    A structure with fixed values.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    The number of columns.
    fromCoo(int rows, int cols, int[] rowIndex, int[] colIndex)
    A rows x cols structure with entries at (rowIndex[e], colIndex[e]); duplicates add up.
    gcn(int n, int[] src, int[] dst)
    The normalised adjacency of a graph convolutional network (Kipf and Welling, 2017), D^-1/2 (A + I) D^-1/2 for the directed edges src[e] -> dst[e] of an n-node graph (messages flow from source to destination, as in PyTorch Geometric's GCNConv).
    mm(Tensor values, Tensor dense)
    A dense with A's stored values values [nnz] (coordinate order); dense [cols, feat] gives [rows, feat].
    int
    nnz()
    The number of stored entries.
    int
    The number of rows.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • fromCoo

      public static SparseMatrix fromCoo(int rows, int cols, int[] rowIndex, int[] colIndex)
      A rows x cols structure with entries at (rowIndex[e], colIndex[e]); duplicates add up.
    • rows

      public int rows()
      The number of rows.
    • cols

      public int cols()
      The number of columns.
    • nnz

      public int nnz()
      The number of stored entries.
    • mm

      public Tensor mm(Tensor values, Tensor dense)
      A dense with A's stored values values [nnz] (coordinate order); dense [cols, feat] gives [rows, feat].
    • gcn

      public static SparseMatrix.Valued gcn(int n, int[] src, int[] dst)
      The normalised adjacency of a graph convolutional network (Kipf and Welling, 2017), D^-1/2 (A + I) D^-1/2 for the directed edges src[e] -> dst[e] of an n-node graph (messages flow from source to destination, as in PyTorch Geometric's GCNConv).