NumPy
import numpy as np

# NumPy arrays
a = np.random.random((1000, 10000))
b = np.random.random((10000, 1000))

c = np.matmul(a, b)
# Run-time: 450 ms
PyTorch
import torch

# PyTorch tensors
a = torch.randn((1000, 10000))
b = torch.randn((10000, 1000))

c = torch.matmul(a, b)
# Run-time: 139 ms

PyTorch est 3x plus rapide que NumPy