Binary#
add#
def add(x: 'Tensor', y: 'Tensor | float | int') -> 'Tensor':
Add x and y element-wise, with broadcasting.
sub#
def sub(x: 'Tensor', y: 'Tensor | float | int') -> 'Tensor':
Subtract y from x element-wise, with broadcasting.
mul#
def mul(x: 'Tensor', y: 'Tensor | float | int') -> 'Tensor':
Multiply x and y element-wise, with broadcasting.
div#
def div(x: 'Tensor', y: 'Tensor | float | int') -> 'Tensor':
Divide x by y element-wise, with broadcasting.
matmul#
def matmul(x: 'Tensor', y: 'Tensor') -> 'Tensor':
Matrix multiplication of x and y.
Supports batched inputs with arbitrary-rank batch prefixes.
1-D inputs are automatically promoted: a vector of shape (N,) becomes
(1, N) or (N, 1) for the left/right operand respectively, and the
added dimension is squeezed from the result.
Parameters
x– Tensor of shape(*, M, K)or(K,).y– Tensor of shape(*, K, N)or(K,).
Returns
Tensor of shape (*, M, N) (or scalar for vector × vector).
mod#
def mod(x: 'Tensor', y: 'Tensor | float | int') -> 'Tensor':
Compute the element-wise remainder x % y, with broadcasting.
pow#
def pow(x: 'Tensor', y: 'Tensor | float | int') -> 'Tensor':
Compute the element-wise power x ** y, with broadcasting.
outer#
def outer(x: 'Tensor', y: 'Tensor') -> 'Tensor':
Compute the outer product of vectors x and y.
For 1-D inputs of shapes (M,) and (N,), returns an (M, N)
matrix. Under vmap, operates on the non-batched trailing dimensions.
Parameters
x– Vector of shape(M,).y– Vector of shape(N,).
Returns
Tensor of shape (M, N).