Skip to content

Commit

Permalink
Add prototype warning to MaskedTensor constructor (pytorch#87107)
Browse files Browse the repository at this point in the history
When a user constructs a MaskedTensor we should signal its development status to set expecations.
Pull Request resolved: pytorch#87107
Approved by: https://github.com/bhosmer
  • Loading branch information
cpuhrsch authored and pytorchmergebot committed Oct 18, 2022
1 parent 240bba7 commit ecd25df
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions torch/masked/maskedtensor/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ def __new__(cls, data, mask, requires_grad=False):
kwargs["requires_grad"] = requires_grad
kwargs["dispatch_sizes_strides_policy"] = "strides"
kwargs["dispatch_layout"] = True
warnings.warn(("The PyTorch API of MaskedTensors is in prototype stage "
"and will change in the near future. Please open a Github issue "
"for features requests and see our documentation on the torch.masked "
"module for further information about the project."), UserWarning)
if data.requires_grad:
warnings.warn("It is not recommended to create a MaskedTensor with a tensor that requires_grad. "
"To avoid this, you can use data.clone().detach()", UserWarning)
Expand Down

0 comments on commit ecd25df

Please sign in to comment.