"vscode:/vscode.git/clone" did not exist on "9e532e7def70ff0756e04676f88d4ffc80debe1f"
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,7 +56,12 @@ def make_grid( ...@@ -56,7 +56,12 @@ def make_grid(
""" """
if not torch.jit.is_scripting() and not torch.jit.is_tracing(): if not torch.jit.is_scripting() and not torch.jit.is_tracing():
_log_api_usage_once(make_grid) _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))): 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)}") raise TypeError(f"tensor or list of tensors expected, got {type(tensor)}")
if "range" in kwargs.keys(): if "range" in kwargs.keys():
......
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