base = sum(np.array([(p[m] * A[m]) for m in range(M)]))
einsum1 = sum(np.einsum('ij...,i->ij...', A, p))
einsum2 = np.einsum('ijk,i->jk', A, p)
einsum3 = np.einsum('ij...,i->j...', A, p)
dot = p.dot(A.reshape(A.shape[0], -1)).reshape(A.shape[1], -1)
tensordot = np.tensordot(p, A, (0, 0))
Самый быстрый способ взять