IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Mojo function

calculate_symmetric_vector

def calculate_symmetric_vector[input_dtype: DType, simd_width: Int, output_bits: Int](data: SIMD[input_dtype, simd_width]) -> Tuple[SIMD[DType.uint8, simd_width], Scalar[input_dtype]]

Symmetrically quantizes the given SIMD vector data with input type input_dtype and simd_width elements, assuming we want the results to fit in an unsigned integer of size output_bits.

Parameters:

  • ​input_dtype (DType): The dtype of the input tensor.
  • ​simd_width (Int): The width of the SIMD input.
  • ​output_bits (Int): The bits we want to fit the unsigned integral result in.

Args:

Returns:

Tuple[SIMD[DType.uint8, simd_width], Scalar[input_dtype]]: A vector of the quantized values. The associated scale factor.