diff --git a/docs/source/torch.overrides.rst b/docs/source/torch.overrides.md similarity index 65% rename from docs/source/torch.overrides.rst rename to docs/source/torch.overrides.md index 5695372240fe..42e75bab9508 100644 --- a/docs/source/torch.overrides.rst +++ b/docs/source/torch.overrides.md @@ -1,30 +1,49 @@ +```{eval-rst} .. currentmodule:: torch.overrides +``` -torch.overrides ---------------- +# torch.overrides +```{eval-rst} .. py:module:: torch.overrides +``` This module exposes various helper functions for the ``__torch_function__`` -protocol. See :ref:`extending-torch-python` for more details on the +protocol. See {ref}`extending-torch-python` for more details on the ``__torch_function__`` protocol. -Functions -~~~~~~~~~ - +## Functions +```{eval-rst} .. autofunction:: get_ignored_functions +``` +```{eval-rst} .. autofunction:: get_overridable_functions +``` +```{eval-rst} .. autofunction:: resolve_name +``` +```{eval-rst} .. autofunction:: get_testing_overrides +``` +```{eval-rst} .. autofunction:: handle_torch_function +``` +```{eval-rst} .. autofunction:: has_torch_function +``` +```{eval-rst} .. autofunction:: is_tensor_like +``` +```{eval-rst} .. autofunction:: is_tensor_method_or_property +``` +```{eval-rst} .. autofunction:: wrap_torch_function +``` diff --git a/docs/source/type_info.md b/docs/source/type_info.md new file mode 100644 index 000000000000..9fc2ce56c4be --- /dev/null +++ b/docs/source/type_info.md @@ -0,0 +1,61 @@ +```{eval-rst} +.. currentmodule:: torch +``` + +(type-info-doc)= +# Type Info + +The numerical properties of a {class}`torch.dtype` can be accessed through either the {class}`torch.finfo` or the {class}`torch.iinfo`. + +(finfo-doc)= +## torch.finfo + +```{eval-rst} +.. class:: torch.finfo +``` + +A {class}`torch.finfo` is an object that represents the numerical properties of a floating point +{class}`torch.dtype`, (i.e. ``torch.float32``, ``torch.float64``, ``torch.float16``, and ``torch.bfloat16``). +This is similar to [numpy.finfo](https://numpy.org/doc/stable/reference/generated/numpy.finfo.html). + +A {class}`torch.finfo` provides the following attributes: + +| Name | Type | Description | +| :-------------- | :---- | :------------------------------------------------------------------------- | +| bits | int | The number of bits occupied by the type. | +| eps | float | The smallest representable number such that ``1.0 + eps != 1.0``. | +| max | float | The largest representable number. | +| min | float | The smallest representable number (typically ``-max``). | +| tiny | float | The smallest positive normal number. Equivalent to ``smallest_normal``. | +| smallest_normal | float | The smallest positive normal number. See notes. | +| resolution | float | The approximate decimal resolution of this type, i.e., ``10**-precision``. | + +```{note} + The constructor of {class}`torch.finfo` can be called without argument, + in which case the class is created for the pytorch default dtype (as returned by {func}`torch.get_default_dtype`). +``` + +```{note} + `smallest_normal` returns the smallest *normal* number, but there are smaller + subnormal numbers. See https://en.wikipedia.org/wiki/Denormal_number + for more information. +``` + +(iinfo-doc)= +## torch.iinfo + +```{eval-rst} +.. class:: torch.iinfo +``` + +A {class}`torch.iinfo` is an object that represents the numerical properties of a integer +{class}`torch.dtype` (i.e. ``torch.uint8``, ``torch.int8``, ``torch.int16``, ``torch.int32``, and ``torch.int64``). +This is similar to [numpy.iinfo](https://numpy.org/doc/stable/reference/generated/numpy.iinfo.html). + +A {class}`torch.iinfo` provides the following attributes: + +| Name | Type | Description | +| :--- | :--- | :--------------------------------------- | +| bits | int | The number of bits occupied by the type. | +| max | int | The largest representable number. | +| min | int | The smallest representable number. | diff --git a/docs/source/type_info.rst b/docs/source/type_info.rst deleted file mode 100644 index 29a5ca282697..000000000000 --- a/docs/source/type_info.rst +++ /dev/null @@ -1,62 +0,0 @@ -.. currentmodule:: torch - -.. _type-info-doc: - -Type Info -========= - -The numerical properties of a :class:`torch.dtype` can be accessed through either the :class:`torch.finfo` or the :class:`torch.iinfo`. - -.. _finfo-doc: - -torch.finfo ------------ - -.. class:: torch.finfo - -A :class:`torch.finfo` is an object that represents the numerical properties of a floating point -:class:`torch.dtype`, (i.e. ``torch.float32``, ``torch.float64``, ``torch.float16``, and ``torch.bfloat16``). This is similar to `numpy.finfo `_. - -A :class:`torch.finfo` provides the following attributes: - -=============== ===== ========================================================================== -Name Type Description -=============== ===== ========================================================================== -bits int The number of bits occupied by the type. -eps float The smallest representable number such that ``1.0 + eps != 1.0``. -max float The largest representable number. -min float The smallest representable number (typically ``-max``). -tiny float The smallest positive normal number. Equivalent to ``smallest_normal``. -smallest_normal float The smallest positive normal number. See notes. -resolution float The approximate decimal resolution of this type, i.e., ``10**-precision``. -=============== ===== ========================================================================== - -.. note:: - The constructor of :class:`torch.finfo` can be called without argument, in which case the class is created for the pytorch default dtype (as returned by :func:`torch.get_default_dtype`). - -.. note:: - `smallest_normal` returns the smallest *normal* number, but there are smaller - subnormal numbers. See https://en.wikipedia.org/wiki/Denormal_number - for more information. - - -.. _iinfo-doc: - -torch.iinfo ------------- - -.. class:: torch.iinfo - - -A :class:`torch.iinfo` is an object that represents the numerical properties of a integer -:class:`torch.dtype` (i.e. ``torch.uint8``, ``torch.int8``, ``torch.int16``, ``torch.int32``, and ``torch.int64``). This is similar to `numpy.iinfo `_. - -A :class:`torch.iinfo` provides the following attributes: - -========= ===== ======================================== -Name Type Description -========= ===== ======================================== -bits int The number of bits occupied by the type. -max int The largest representable number. -min int The smallest representable number. -========= ===== ======================================== diff --git a/docs/source/utils.rst b/docs/source/utils.md similarity index 95% rename from docs/source/utils.rst rename to docs/source/utils.md index 307872f359d0..6742866a8b25 100644 --- a/docs/source/utils.rst +++ b/docs/source/utils.md @@ -1,8 +1,13 @@ -torch.utils -=================================== +# torch.utils +```{eval-rst} .. automodule:: torch.utils -.. currentmodule:: torch.utils +``` +```{eval-rst} +.. currentmodule:: torch.utils +``` + +```{eval-rst} .. autosummary:: :toctree: generated :nosignatures: @@ -12,9 +17,11 @@ torch.utils get_cpp_backtrace set_module swap_tensors +``` -.. This module needs to be documented. Adding here in the meantime -.. for tracking purposes + +```{eval-rst} .. py:module:: torch.utils.backend_registration .. py:module:: torch.utils.benchmark.examples.compare .. py:module:: torch.utils.benchmark.examples.fuzzer @@ -87,3 +94,4 @@ torch.utils .. py:module:: torch.utils.tensorboard.writer .. py:module:: torch.utils.throughput_benchmark .. py:module:: torch.utils.weak +``` diff --git a/docs/source/xpu.rst b/docs/source/xpu.md similarity index 77% rename from docs/source/xpu.rst rename to docs/source/xpu.md index 51f8428e5d12..46d36451d4b8 100644 --- a/docs/source/xpu.rst +++ b/docs/source/xpu.md @@ -1,8 +1,12 @@ -torch.xpu -=================================== +# torch.xpu +```{eval-rst} .. automodule:: torch.xpu +``` +```{eval-rst} .. currentmodule:: torch.xpu +``` +```{eval-rst} .. autosummary:: :toctree: generated :nosignatures: @@ -26,9 +30,10 @@ torch.xpu set_stream stream synchronize +``` -Random Number Generator -------------------------- +## Random Number Generator +```{eval-rst} .. autosummary:: :toctree: generated :nosignatures: @@ -42,21 +47,27 @@ Random Number Generator seed_all set_rng_state set_rng_state_all +``` -Streams and events ------------------- +## Streams and events +```{eval-rst} .. autosummary:: :toctree: generated :nosignatures: Event Stream +``` +```{eval-rst} .. automodule:: torch.xpu.memory +``` +```{eval-rst} .. currentmodule:: torch.xpu.memory +``` -Memory management ------------------ +## Memory management +```{eval-rst} .. autosummary:: :toctree: generated :nosignatures: @@ -71,9 +82,11 @@ Memory management memory_stats_as_nested_dict reset_accumulated_memory_stats reset_peak_memory_stats +``` - -.. This module needs to be documented. Adding here in the meantime -.. for tracking purposes + +```{eval-rst} .. py:module:: torch.xpu.random .. py:module:: torch.xpu.streams +```