From c0c208516b02d776858ace697e052d6db6036e8f Mon Sep 17 00:00:00 2001 From: Danni Li Date: Wed, 26 Jul 2023 16:30:15 +0000 Subject: [PATCH] [Doc] Add `Tensor.Shape` (#104750) Summary: Add `Tensor.Shape` doc. Fix: #104038 Ref: - https://github.com/pytorch/pytorch/issues/5544 - https://github.com/pytorch/pytorch/issues/1980 Differential Revision: D47278630 CC: @svekars @carljparker Pull Request resolved: https://github.com/pytorch/pytorch/pull/104750 Approved by: https://github.com/mikaylagawarecki --- 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 941f8136cf5..fc9f93b454f 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 bdd63562925..7961099169e 100644 --- a/torch/_tensor_docs.py +++ b/torch/_tensor_docs.py @@ -4727,6 +4727,26 @@ Example:: """, ) +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"""