dot

abstract infix fun Tensor<T>.dot(other: Tensor<T>): Tensor<T>

Matrix product of two tensors.

The behavior depends on the dimensionality of the tensors as follows:

  1. If both tensors are 1-dimensional, the dot product (scalar) is returned.

  2. If both arguments are 2-dimensional, the matrix-matrix product is returned.

  3. If the first argument is 1-dimensional and the second argument is 2-dimensional, a 1 is prepended to its dimension for the purpose of the matrix multiply. After the matrix multiply, the prepended dimension is removed.

  4. If the first argument is 2-dimensional and the second argument is 1-dimensional, the matrix-vector product is returned.

  5. If both arguments are at least 1-dimensional and at least one argument is N-dimensional (where N 2), then a batched matrix multiply is returned. If the first argument is 1-dimensional, a 1 is prepended to its dimension for the purpose of the batched matrix multiply and removed after. If the second argument is 1-dimensional, a 1 is appended to its dimension for the purpose of the batched matrix multiple and removed after. The non-matrix (i.e., batch) dimensions are broadcast (and thus must be broadcastable). For example, if input is a (j &times; 1 &times; n &times; n) tensor and other is a (k &times; n &times; n) tensor, out will be a (j &times; k &times; n &times; n) tensor.

For more information: https://pytorch.org/docs/stable/generated/torch.matmul.html

Return

a mathematical product of two tensors.

Parameters

other

tensor to be multiplied.

Sources

common source
Link copied to clipboard