mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-08-25 11:12:15 +00:00
* [legacy] move trainer to legacy * [doc] update docs related to trainer * [test] ignore legacy test
10 lines
231 B
Python
10 lines
231 B
Python
import torch
|
|
|
|
|
|
def _format_number(val, prec=5):
|
|
if isinstance(val, float):
|
|
return f'{val:.{prec}g}'
|
|
elif torch.is_tensor(val) and torch.is_floating_point(val):
|
|
return f'{val.item():.{prec}g}'
|
|
return val
|