(numel, dtype)
| 453 | } |
| 454 | |
| 455 | function 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. |
no outgoing calls
no test coverage detected
searching dependent graphs…