espnet2.torch_utils.model_summary.get_human_readable_count
Less than 1 minute
espnet2.torch_utils.model_summary.get_human_readable_count
espnet2.torch_utils.model_summary.get_human_readable_count(number: int) → str
Return a human-readable count of a given integer number.
This function abbreviates an integer number using the suffixes K, M, B, and T for thousands, millions, billions, and trillions, respectively.
Examples
>>> get_human_readable_count(123)
'123 '
>>> get_human_readable_count(1234) # (one thousand)
'1 K'
>>> get_human_readable_count(2e6) # (two million)
'2 M'
>>> get_human_readable_count(3e9) # (three billion)
'3 B'
>>> get_human_readable_count(4e12) # (four trillion)
'4 T'
>>> get_human_readable_count(5e15) # (more than trillion)
'5,000 T'
- Parameters:number – A positive integer number.
- Returns: A string formatted according to the pattern described above.
- Raises:AssertionError – If the input number is negative.