Fix logging torch.dtype. (#1947)

This commit is contained in:
Fangjun Kuang 2025-05-21 12:04:57 +08:00 committed by GitHub
parent e79833aad2
commit fd8f8780fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -186,7 +186,7 @@ class AttributeDict(dict):
tmp = {}
for k, v in self.items():
# PosixPath is ont JSON serializable
if isinstance(v, pathlib.Path) or isinstance(v, torch.device):
if isinstance(v, (pathlib.Path, torch.device, torch.dtype)):
v = str(v)
tmp[k] = v
return json.dumps(tmp, indent=indent, sort_keys=True)