matmul

Graph.matmul(x, y, *, name=None)

Calculate the matrix multiplication between np.ndarrays, Tensors, Pwcs, or Stfs. You can also use the arithmetic operator @ to calculate their matrix multiplication.

If any of the inputs is a Pwc or Stf, the output is also a Pwc or Stf (mixing Pwcs and Stfs is not supported). Otherwise, the output is a Tensor.

This operation supports broadcasting between the batch dimensions of the two input objects. All the dimensions with the exception of the two innermost ones (where the matrix multiplication is performed) are considered batch dimensions.

When operating a tensor-like object with an Stf or a Pwc, the time dimension of the latter is ignored.

Parameters

  • x (np.ndarray or Tensor or Pwc or Stf) – The left multiplicand. It must be a matrix (or batch of matrices) and its last dimension must be the same as the second-to-last dimension of y.
  • y (np.ndarray or Tensor or Pwc or Stf) – The right multiplicand. It must be a matrix (or batch of matrices) and its second-to-last dimension must be the same as the last dimension of x.
  • name (str or None , optional) – The name of the node. You can only provide a name if neither x nor y are Stfs.

Returns

The matrix product of the input objects. If any of the input objects is a Pwc or Stf, the returned objects has the same type. Otherwise, it is a Tensor.

Return type

Tensor or Pwc or Stf

SEE ALSO

Graph.einsum : Tensor contraction via Einstein summation convention.

Was this useful?