Skip to main content
Log in

Mojo function

bitcast

bitcast[new_type: DType, new_width: Int, src_type: DType, src_width: Int](val: SIMD[src_type, src_width]) -> SIMD[$0, $1]

Bitcasts a SIMD value to another SIMD value.

Constraints:

The bitwidth of the two types must be the same.

Parameters:

  • new_type (DType): The target type.
  • new_width (Int): The target width.
  • src_type (DType): The source type.
  • src_width (Int): The source width.

Args:

  • val (SIMD[src_type, src_width]): The source value.

Returns:

A new SIMD value with the specified type and width with a bitcopy of the source SIMD value.

bitcast[new_type: DType, src_type: DType](val: SIMD[src_type, 1]) -> SIMD[$0, 1]

Bitcasts a SIMD value to another SIMD value.

Constraints:

The bitwidth of the two types must be the same.

Parameters:

  • new_type (DType): The target type.
  • src_type (DType): The source type.

Args:

  • val (SIMD[src_type, 1]): The source value.

Returns:

A new SIMD value with the specified type and width with a bitcopy of the source SIMD value.

bitcast[new_type: DType, src_width: Int](val: SIMD[bool, src_width]) -> SIMD[$0, 1]

Packs a SIMD bool into an integer.

Constraints:

The bitwidth of the two types must be the same.

Parameters:

  • new_type (DType): The target type.
  • src_width (Int): The source width.

Args:

  • val (SIMD[bool, src_width]): The source value.

Returns:

A new integer scalar which has the same bitwidth as the bool vector.

Was this page helpful?