Skip to content

Commit

Permalink
[doc] Add note about torch.flip returning new tensor and not view. (#…
Browse files Browse the repository at this point in the history
…50041)

Summary:
Reference: #38271

Pull Request resolved: #50041

Reviewed By: izdeby

Differential Revision: D25883870

Pulled By: mruberry

fbshipit-source-id: 33cc28a2176e98f2f29077958782291609c7999b
  • Loading branch information
kshitij12345 authored and facebook-github-bot committed Jan 13, 2021
1 parent b54240d commit 057be23
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions torch/_torch_docs.py
Expand Up @@ -8477,6 +8477,11 @@ def merge_dicts(*dicts):
Reverse the order of a n-D tensor along given axis in dims.
.. note::
`torch.flip` makes a copy of :attr:`input`'s data. This is different from NumPy's `np.flip`,
which returns a view in constant time. Since copying a tensor's data is more work than viewing that data,
`torch.flip` is expected to be slower than `np.flip`.
Args:
{input}
dims (a list or tuple): axis to flip on
Expand All @@ -8502,13 +8507,18 @@ def merge_dicts(*dicts):
r"""
fliplr(input) -> Tensor
Flip array in the left/right direction, returning a new tensor.
Flip tensor in the left/right direction, returning a new tensor.
Flip the entries in each row in the left/right direction.
Columns are preserved, but appear in a different order than before.
Note:
Equivalent to input[:,::-1]. Requires the array to be at least 2-D.
Requires the tensor to be at least 2-D.
.. note::
`torch.fliplr` makes a copy of :attr:`input`'s data. This is different from NumPy's `np.fliplr`,
which returns a view in constant time. Since copying a tensor's data is more work than viewing that data,
`torch.fliplr` is expected to be slower than `np.fliplr`.
Args:
input (Tensor): Must be at least 2-dimensional.
Expand All @@ -8528,13 +8538,18 @@ def merge_dicts(*dicts):
r"""
flipud(input) -> Tensor
Flip array in the up/down direction, returning a new tensor.
Flip tensor in the up/down direction, returning a new tensor.
Flip the entries in each column in the up/down direction.
Rows are preserved, but appear in a different order than before.
Note:
Equivalent to input[::-1,...]. Requires the array to be at least 1-D.
Requires the tensor to be at least 1-D.
.. note::
`torch.flipud` makes a copy of :attr:`input`'s data. This is different from NumPy's `np.flipud`,
which returns a view in constant time. Since copying a tensor's data is more work than viewing that data,
`torch.flipud` is expected to be slower than `np.flipud`.
Args:
input (Tensor): Must be at least 1-dimensional.
Expand Down

0 comments on commit 057be23

Please sign in to comment.