Skip to content

Commit 341fb19

Browse files
committed
Add instance methods tensor.isnan(), tensor.isinf(), tensor.isfinite()
Update _tensor_docs.py Update tensors.rst Update _tensor_docs.py
1 parent 0c936f9 commit 341fb19

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

aten/src/ATen/native/native_functions.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,7 +1586,7 @@
15861586

15871587
- func: isnan(Tensor self) -> Tensor
15881588
use_c10_dispatcher: full
1589-
variants: function
1589+
variants: function, method
15901590
device_guard: False
15911591
supports_named_tensor: True
15921592
dispatch:
@@ -6973,13 +6973,13 @@
69736973

69746974
- func: isfinite(Tensor self) -> Tensor
69756975
use_c10_dispatcher: full
6976-
variants: function
6976+
variants: function, method
69776977
device_guard: False
69786978
supports_named_tensor: True
69796979

69806980
- func: isinf(Tensor self) -> Tensor
69816981
use_c10_dispatcher: full
6982-
variants: function
6982+
variants: function, method
69836983
device_guard: False
69846984
supports_named_tensor: True
69856985

docs/source/tensors.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ view of a storage and defines numeric operations on it.
313313
.. automethod:: inverse
314314
.. automethod:: irfft
315315
.. automethod:: isclose
316+
.. automethod:: isfinite
317+
.. automethod:: isinf
318+
.. automethod:: isnan
316319
.. automethod:: is_contiguous
317320
.. automethod:: is_complex
318321
.. automethod:: is_floating_point

torch/_tensor_docs.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,27 @@ def add_docstr_all(method, docstr):
15411541
See :func:`torch.inverse`
15421542
""")
15431543

1544+
add_docstr_all('isnan',
1545+
r"""
1546+
isnan() -> Tensor
1547+
1548+
See :func:`torch.isnan`
1549+
""")
1550+
1551+
add_docstr_all('isinf',
1552+
r"""
1553+
isinf() -> Tensor
1554+
1555+
See :func:`torch.isinf`
1556+
""")
1557+
1558+
add_docstr_all('isfinite',
1559+
r"""
1560+
isfinite() -> Tensor
1561+
1562+
See :func:`torch.isfinite`
1563+
""")
1564+
15441565
add_docstr_all('isclose',
15451566
r"""
15461567
isclose(other, rtol=1e-05, atol=1e-08, equal_nan=False) -> Tensor

0 commit comments

Comments
 (0)