chainer.functions.sparse_matmul

chainer.functions.sparse_matmul(a, b, transa=False, transb=False)[source]

Computes the batched multiplication of sparse and dense matrix.

The following use cases are supported:

  1. C (dense) = A (sparse) * B (dense)
  2. C (dense) = A (dense) * B (sparse)
Parameters:
  • a (Variable or CooMatrix) – The left operand of matrix multiplication.
  • b (Variable or CooMatrix) – The right operand of matrix multiplication.
  • transa (bool) – If True, each matrix in a will be transposed.
  • transb (bool) – If True, each matrix in b will be transposed.
Returns:

Result of batched mat-mul.

Return type:

Variable

See also

See to_coo() for how to construct a COO matrix from an array.

Note

Performance of this function on GPU can be improved by using the order argument of CooMatrix when the sparse matrix is created.