MCPcopy Create free account
hub / github.com/tensorflow/tfjs / hasEncodingLoss

Function hasEncodingLoss

tfjs-core/src/util_base.ts:476–490  ·  view source on GitHub ↗
(oldType: DataType, newType: DataType)

Source from the content-addressed store, hash-verified

474 * precision.
475 */
476export 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
492export function bytesPerElement(dtype: DataType): number {
493 if (dtype === 'float32' || dtype === 'int32') {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…