Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] Add note about torch.flip returning new tensor and not view. #50041

Closed
Closed
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions torch/_torch_docs.py
Expand Up @@ -8472,6 +8472,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 Down Expand Up @@ -8503,7 +8508,12 @@ def merge_dicts(*dicts):
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 array 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 @@ -8529,7 +8539,12 @@ def merge_dicts(*dicts):
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 array 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