4

Can I always replace torch.matmul with python's built-in @ operator to do the matrix multiplication? Please assume that I know the difference between torch.matmul, torch.mm and many others. I just want to make sure how many of them can be safely replaced by @ operator without sacrificing speed or some native support from torch.

If it does no harm, I would like to extensively use them in the future.

LyWang
  • 79
  • 1
  • 3

1 Answers1

1

yes you can always use @ in place of .matmul. You can also do the same in numpy. Also see PyTorch mapping operators to functions

Umang Gupta
  • 15,022
  • 6
  • 48
  • 66