consider case of empty tensor (#540)

This commit is contained in:
Zengwei Yao 2022-08-22 21:42:56 +08:00 committed by GitHub
parent 9277c95bcd
commit c0101185d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -130,6 +130,8 @@ class TensorDiagnostic(object):
x = x[0]
if not isinstance(x, Tensor):
return
if x.numel() == 0: # for empty tensor
return
x = x.detach().clone()
if x.ndim == 0:
x = x.unsqueeze(0)