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 msimport torch
# PyTorch tensors
a = torch.randn((1000, 10000))
b = torch.randn((10000, 1000))
c = torch.matmul(a, b)
# Run-time: 139 msPyTorch est 3x plus rapide que NumPy