Unverified Commit 18b39e36 authored by Gouvernathor's avatar Gouvernathor Committed by GitHub
Browse files

Clarify TypeError message (#5997)



* Clarify TypeError message

* typo

* Wrap tye() in repr()

so that the type-check stfu

* Even better message

incidentally speeds up the thing, since all() possibly checked all elements and we don't.
Co-authored-by: default avatarVasilis Vryniotis <datumbox@users.noreply.github.com>
parent 03bb3245
......@@ -56,8 +56,13 @@ def make_grid(
"""
if not torch.jit.is_scripting() and not torch.jit.is_tracing():
_log_api_usage_once(make_grid)
if not (torch.is_tensor(tensor) or (isinstance(tensor, list) and all(torch.is_tensor(t) for t in tensor))):
raise TypeError(f"tensor or list of tensors expected, got {type(tensor)}")
if not torch.is_tensor(tensor):
if isinstance(tensor, list):
for t in tensor:
if not torch.is_tensor(t):
raise TypeError(f"tensor or list of tensors expected, got a list containing {type(t)}")
else:
raise TypeError(f"tensor or list of tensors expected, got {type(tensor)}")
if "range" in kwargs.keys():
warnings.warn(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment