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

Function computeTensorMemory

torch/utils/model_dump/code.js:455–479  ·  view source on GitHub ↗
(numel, dtype)

Source from the content-addressed store, hash-verified

453}
454
455function computeTensorMemory(numel, dtype) {
456 const sizes = {
457 "Byte": 1,
458 "Char": 1,
459 "Short": 2,
460 "Int": 4,
461 "Long": 8,
462 "Half": 2,
463 "Float": 4,
464 "Double": 8,
465 "ComplexHalf": 4,
466 "ComplexFloat": 8,
467 "ComplexDouble": 16,
468 "Bool": 1,
469 "QInt8": 1,
470 "QUInt8": 1,
471 "QInt32": 4,
472 "BFloat16": 2,
473 };
474 let dtsize = sizes[dtype];
475 if (!dtsize) {
476 throw new Error("Unrecognized dtype: " + dtype);
477 }
478 return numel * dtsize;
479}
480
481// TODO: Maybe track by dtype as well.
482// TODO: Maybe distinguish between visible size and storage size.

Callers 1

getTensorMemoryByDeviceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…