espnet2.enh.layers.ncsnpp_utils.layers.contract_inner
Less than 1 minute
espnet2.enh.layers.ncsnpp_utils.layers.contract_inner
espnet2.enh.layers.ncsnpp_utils.layers.contract_inner(x, y)
Compute the inner product of two tensors along the last axis of x and the first axis of y.
This function utilizes Einstein summation convention to compute the inner product, effectively performing a tensordot operation with the specified axes.
- Parameters:
- x (torch.Tensor) – The first input tensor of shape (N, …, M).
- y (torch.Tensor) – The second input tensor of shape (N, …, P).
- Returns: The result of the inner product of x and y, with shape (N, …, P).
- Return type: torch.Tensor
Examples
>>> x = torch.randn(2, 3, 4)
>>> y = torch.randn(2, 4, 5)
>>> result = contract_inner(x, y)
>>> result.shape
torch.Size([2, 3, 5])
NOTE
- The function assumes that the last dimension of x and the first dimension of y are compatible for the inner product.