(oldType: DataType, newType: DataType)
| 474 | * precision. |
| 475 | */ |
| 476 | export function hasEncodingLoss(oldType: DataType, newType: DataType): boolean { |
| 477 | if (newType === 'complex64') { |
| 478 | return false; |
| 479 | } |
| 480 | if (newType === 'float32' && oldType !== 'complex64') { |
| 481 | return false; |
| 482 | } |
| 483 | if (newType === 'int32' && oldType !== 'float32' && oldType !== 'complex64') { |
| 484 | return false; |
| 485 | } |
| 486 | if (newType === 'bool' && oldType === 'bool') { |
| 487 | return false; |
| 488 | } |
| 489 | return true; |
| 490 | } |
| 491 | |
| 492 | export function bytesPerElement(dtype: DataType): number { |
| 493 | if (dtype === 'float32' || dtype === 'int32') { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…