# Perform addbmm
result = torch.addbmm(input, batch1, batch2)
print("Input matrix shape:",input.shape)
print("Batch Matrix 1 Shape:", batch1.shape)
print("Batch Matrix 2 Shape:", batch2.shape)
print("Result Shape:", result.shape)
print(result)
Output:
Input matrix shape: torch.Size([3, 3])Batch Matrix 1 Shape: torch.Size([10, 3, 4])Batch Matrix 2 Shape: torch.Size([10, 4, 3])Result Shape: torch.Size([3, 3]) tensor([[-0.2875, -0.6518, 0.1207], [-0.2746, 0.5563, -0.2281], [ 0.3315, 0.1649, 0.2145]])
Pytorch torch Reference Manual