Fix logging torch.dtype.

This commit is contained in:
Fangjun Kuang 2025-05-21 12:01:38 +08:00
parent e79833aad2
commit 2ca458bb56

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)