Benchmark Operator

This OP benchmarks against the matmul operator in the Torch library, but its functions are slightly different. For details about functions, see the examples in the torch.matmul document.

# batched matrix x batched matrix
tensor1 = torch.randn(10, 3, 4)
tensor2 = torch.randn(10, 4, 5)
torch.matmul(tensor1, tensor2).size() # torch.Size([10, 3, 5])
# batched matrix x broadcasted matrix
tensor1 = torch.randn(10, 3, 4)
tensor2 = torch.randn(4, 5)
torch.matmul(tensor1, tensor2).size() # torch.Size([10, 3, 5])