mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
[BE][Ez]: Update torch.is_tensor documentation (#165841)
TypeIs propogates the isinstance check with the typing system. They are now equivalent. Pull Request resolved: https://github.com/pytorch/pytorch/pull/165841 Approved by: https://github.com/albanD
This commit is contained in:
committed by
PyTorch MergeBot
parent
ceb11a584d
commit
57ba575242
@ -1120,11 +1120,6 @@ def typename(obj: _Any, /) -> str:
|
||||
def is_tensor(obj: _Any, /) -> _TypeIs["torch.Tensor"]:
|
||||
r"""Returns True if `obj` is a PyTorch tensor.
|
||||
|
||||
Note that this function is simply doing ``isinstance(obj, Tensor)``.
|
||||
Using that ``isinstance`` check is better for type checking with mypy,
|
||||
and more explicit - so it's recommended to use that instead of
|
||||
``is_tensor``.
|
||||
|
||||
Args:
|
||||
obj (object): Object to test
|
||||
Example::
|
||||
|
Reference in New Issue
Block a user