xref: /aosp_15_r20/external/pytorch/docs/source/size.rst (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1torch.Size
2===================================
3
4:class:`torch.Size` is the result type of a call to :func:`torch.Tensor.size`. It describes the size of all dimensions
5of the original tensor. As a subclass of :class:`tuple`, it supports common sequence operations like indexing and
6length.
7
8
9Example::
10
11    >>> x = torch.ones(10, 20, 30)
12    >>> s = x.size()
13    >>> s
14    torch.Size([10, 20, 30])
15    >>> s[1]
16    20
17    >>> len(s)
18    3
19
20
21
22.. autoclass:: torch.Size
23   :members:
24   :undoc-members:
25   :inherited-members:
26