diff --git a/torch/_tensor_docs.py b/torch/_tensor_docs.py index 9e195676324265..ded6ec887f4838 100644 --- a/torch/_tensor_docs.py +++ b/torch/_tensor_docs.py @@ -3185,6 +3185,15 @@ def callable(a, b) -> number Args: mask (BoolTensor): the boolean mask value (float): the value to fill in with + +Example: + >>> self = torch.tensor([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]) + >>> mask = torch.tensor([[0, 1, 0, 1, 0], [1, 0, 1, 0, 1]], dtype=torch.bool) + >>> self.masked_fill_(mask, -1) + >>> self + tensor([[ 1, -1, 3, -1, 5], + [-1, 7, -1, 9, -1]]) + """, ) @@ -6587,6 +6596,14 @@ def callable(a, b) -> number masked_fill(mask, value) -> Tensor Out-of-place version of :meth:`torch.Tensor.masked_fill_` + +Example: + >>> self = torch.tensor([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]) + >>> mask = torch.tensor([[0, 1, 0, 1, 0], [1, 0, 1, 0, 1]], dtype=torch.bool) + >>> self.masked_fill(mask, -1) + tensor([[ 1, -1, 3, -1, 5], + [-1, 7, -1, 9, -1]]) + """, )