MCPcopy Create free account
hub / github.com/pytorch/pytorch / humanFileSize

Function humanFileSize

torch/utils/model_dump/code.js:9–13  ·  view source on GitHub ↗
(size)

Source from the content-addressed store, hash-verified

7
8// https://stackoverflow.com/a/20732091
9function humanFileSize(size) {
10 if (size == 0) { return "0 B"; }
11 var i = Math.floor( Math.log(size) / Math.log(1024) );
12 return (size / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
13}
14
15function caret(down) {
16 return down ? "\u25BE" : "\u25B8";

Callers 2

ModelSizeSectionFunction · 0.85
renderMethod · 0.85

Calls 3

floorMethod · 0.45
logMethod · 0.45
powMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…