In-place operations and mypy

In-place operations on tensors is reported by mypy as an error.


import torch

t = torch.zeros(3)
t.add_(1) error: "Tensor" has no attribute "add_"; maybe "addr_", "addmv_", or "addmm_"?
  • PyTorch Version: 1.3.1
  • OS: Ubuntu 16.04
  • How you installed PyTorch: conda
  • Python version: 3.7.4

Is this an error or intended?

Definitely unintended, please file an issue at if there isn’t one already

I opened an issue and also added all the other errors I found with typing in pytorch. Cheers!