summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvishwakftw <cs15btech11043@iith.ac.in>2019-01-07 10:38:16 -0800
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>2019-01-07 10:43:22 -0800
commit95febdfacc112158565561e374819396dfd88861 (patch)
tree5e59ef74d6e11cfcebec19d515402c83af45ddaa
parent2ff0e3b196f22490ba35271b59676f481165c5ac (diff)
downloadpytorch-95febdfacc112158565561e374819396dfd88861.tar.gz
pytorch-95febdfacc112158565561e374819396dfd88861.tar.bz2
pytorch-95febdfacc112158565561e374819396dfd88861.zip
Add is_floating_point to docs (#15704)
Summary: Fixes #15700 . Changelog: - Expose torch.*.is_floating_point to docs Differential Revision: D13580734 Pulled By: zou3519 fbshipit-source-id: 76edb4af666c08237091a2cebf53d9ba5e6c8909
-rw-r--r--docs/source/tensor_attributes.rst3
-rw-r--r--docs/source/tensors.rst1
-rw-r--r--docs/source/torch.rst1
-rw-r--r--test/test_torch.py1
-rw-r--r--torch/_tensor_docs.py7
-rw-r--r--torch/_torch_docs.py11
6 files changed, 23 insertions, 1 deletions
diff --git a/docs/source/tensor_attributes.rst b/docs/source/tensor_attributes.rst
index 230b74d7dd..8233211dba 100644
--- a/docs/source/tensor_attributes.rst
+++ b/docs/source/tensor_attributes.rst
@@ -30,6 +30,9 @@ Data type dtype Tensor
64-bit integer (signed) ``torch.int64`` or ``torch.long`` ``torch.*.LongTensor``
======================== =========================================== ===========================
+To find out if a :class:`torch.dtype` is a floating point data type, the property :attr:`is_floating_point`
+can be used, which returns ``True`` if the data type is a floating point data type.
+
.. _device-doc:
torch.device
diff --git a/docs/source/tensors.rst b/docs/source/tensors.rst
index 977cf2b52f..4e89392082 100644
--- a/docs/source/tensors.rst
+++ b/docs/source/tensors.rst
@@ -259,6 +259,7 @@ view of a storage and defines numeric operations on it.
.. automethod:: int
.. automethod:: inverse
.. automethod:: is_contiguous
+ .. automethod:: is_floating_point
.. automethod:: is_pinned
.. automethod:: is_set_to
.. automethod:: is_signed
diff --git a/docs/source/torch.rst b/docs/source/torch.rst
index eb34f1ac70..f04b7fb21a 100644
--- a/docs/source/torch.rst
+++ b/docs/source/torch.rst
@@ -6,6 +6,7 @@ Tensors
----------------------------------
.. autofunction:: is_tensor
.. autofunction:: is_storage
+.. autofunction:: is_floating_point
.. autofunction:: set_default_dtype
.. autofunction:: get_default_dtype
.. autofunction:: set_default_tensor_type
diff --git a/test/test_torch.py b/test/test_torch.py
index 006b25632f..58b6e8f931 100644
--- a/test/test_torch.py
+++ b/test/test_torch.py
@@ -197,7 +197,6 @@ class _TestTorchMixin(object):
'index_put',
'is_coalesced',
'is_distributed',
- 'is_floating_point',
'is_complex',
'is_nonzero',
'is_same_size',
diff --git a/torch/_tensor_docs.py b/torch/_tensor_docs.py
index 08e9547c47..bcc7d0578d 100644
--- a/torch/_tensor_docs.py
+++ b/torch/_tensor_docs.py
@@ -1263,6 +1263,13 @@ is_contiguous() -> bool
Returns True if :attr:`self` tensor is contiguous in memory in C order.
""")
+add_docstr_all('is_floating_point',
+ r"""
+is_floating_point() -> bool
+
+Returns True if the data type of :attr:`self` is a floating point data type.
+""")
+
add_docstr_all('is_set_to',
r"""
is_set_to(tensor) -> bool
diff --git a/torch/_torch_docs.py b/torch/_torch_docs.py
index 857b8a684e..162c2af8a9 100644
--- a/torch/_torch_docs.py
+++ b/torch/_torch_docs.py
@@ -2202,6 +2202,17 @@ Example::
tensor(1.9073e-06)
""")
+add_docstr(torch.is_floating_point,
+ r"""
+is_floating_point(tensor) -> (bool)
+
+Returns True if the data type of :attr:`tensor` is a floating point data type i.e.,
+one of ``torch.float64``, ``torch.float32`` and ``torch.float16``.
+
+Args:
+ tensor (Tensor): the PyTorch tensor to test
+""")
+
add_docstr(torch.kthvalue,
r"""
kthvalue(input, k, dim=None, keepdim=False, out=None) -> (Tensor, LongTensor)