jax-js
    Preparing search index...

    Function promoteTypes

    • Promote two dtypes to their join according to the type lattice.

      When performing operations between arrays of different types, we need to promote both operands to a common type that can represent values from both input types. This follows JAX's type promotion rules.

      Type lattice:

      bool -> uint32 -> int32 -> float16 -> float32
       weakType --^
      

      weakType represents weakly typed arrays. These are created for JS numbers, which default to float32 but "weak" so they cast to the dtype of any array they are first combined with, except bool.

      Examples:

      • promoteTypes(bool, int32) → int32
      • promoteTypes(uint32, int32) → int32
      • promoteTypes(int32, float16) → float16
      • promoteTypes(float16, float32) → float32
      • promoteTypes(uint32, float32) → float32

      Parameters

      Returns DType