liveBook · Manning

Type promotion semantics

As explained in Deep Learning with JAX

Rules that determine the result dtype of an operation when its operands have different data types.

When operands use different dtypes, type promotion semantics determine the dtype of the operation result. JAX differs from NumPy: it defaults to float32 rather than aggressively promoting floating-point operands to float64. section 3.3.2

Mixing 16-bit floating-point types

With xb16 as bfloat16 and x16 as float16, xb16 + x16 produces float32 values. Adding xb16 to itself preserves bfloat16, showing that promotion depends on the operand combination.

How Deep Learning with JAX covers it

How deep it goes
Defines promotion behavior and demonstrates two 16-bit combinations, but does not enumerate the complete promotion hierarchy.
Examples
Uses bfloat16 plus float16 yielding float32, and bfloat16 plus bfloat16 preserving bfloat16.
What it assumes
Assumes familiarity with arrays and dtypes while introducing JAX’s float32 default and supported floating-point formats.
What you can do after
Evaluate resulting dtypes for mixed-precision JAX operations and recognize when values become float32.
How it connects
Connects type promotion with NumPy differences, floating-point types, and JAX precision configuration.

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with JAX. The section links point to the parts of the book it draws on.