(numel: int)
| 7 | |
| 8 | |
| 9 | def format_numel_str(numel: int) -> str: |
| 10 | B = 1024**3 |
| 11 | M = 1024**2 |
| 12 | K = 1024 |
| 13 | if numel >= B: |
| 14 | return f"{numel / B:.2f} B" |
| 15 | elif numel >= M: |
| 16 | return f"{numel / M:.2f} M" |
| 17 | elif numel >= K: |
| 18 | return f"{numel / K:.2f} K" |
| 19 | else: |
| 20 | return f"{numel}" |
| 21 | |
| 22 | def sample_from_range(value: Union[float, int, Sequence, Mapping], |
| 23 | device: Optional[torch.device] = None, |