From 990864ef79ef32dc2c6663db1810abc5a246c031 Mon Sep 17 00:00:00 2001 From: Danni Li Date: Tue, 25 Jul 2023 14:02:10 -0700 Subject: [PATCH] [Doc] Add `Tensor.Shape` (#104750) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/104750 Add `Tensor.Shape` doc. Ref: - https://github.com/pytorch/pytorch/issues/5544 - https://github.com/pytorch/pytorch/issues/1980 Differential Revision: D47278630 fbshipit-source-id: aa2466cba60b21860338e1ea6b8850f4395b6255 --- docs/source/tensors.rst | 1 + torch/_tensor_docs.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/docs/source/tensors.rst b/docs/source/tensors.rst index 941f8136cf5b..fc9f93b454f5 100644 --- a/docs/source/tensors.rst +++ b/docs/source/tensors.rst @@ -622,6 +622,7 @@ Tensor class reference Tensor.asinh_ Tensor.arcsinh Tensor.arcsinh_ + Tensor.shape Tensor.size Tensor.slogdet Tensor.slice_scatter diff --git a/torch/_tensor_docs.py b/torch/_tensor_docs.py index bdd635629259..7961099169e8 100644 --- a/torch/_tensor_docs.py +++ b/torch/_tensor_docs.py @@ -4727,6 +4727,26 @@ def callable(a, b) -> number """, ) +add_docstr_all( + "shape", + r""" +shape() -> torch.Size + +Returns the size of the :attr:`self` tensor. Alias for :attr:`size`. + +See also :meth:`Tensor.size`. + +Example:: + + >>> t = torch.empty(3, 4, 5) + >>> t.size() + torch.Size([3, 4, 5]) + >>> t.shape + torch.Size([3, 4, 5]) + +""", +) + add_docstr_all( "sort", r"""