mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-22 09:59:38 +00:00
[refactor] moving memtracer to gemini (#801)
This commit is contained in:
9
colossalai/trainer/hooks/_commons_.py
Normal file
9
colossalai/trainer/hooks/_commons_.py
Normal file
@@ -0,0 +1,9 @@
|
||||
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
|
Reference in New Issue
Block a user