Contents

quantize(_:scale:zeroPoint:dataType:name:)

Creates a Quantize operation and returns the result tensor.

Declaration

func quantize(_ tensor: MPSGraphTensor, scale: Double, zeroPoint: Double, dataType: MPSDataType, name: String?) -> MPSGraphTensor

Parameters

  • tensor:

    Input tensor to be quantized

  • scale:

    Scale scalar parameter

  • zeroPoint:

    Bias scalar parameter (converted to dataType of resultTensor)

  • dataType:

    Data type of the result tensor. Supports MPSDataTypeInt8, MPSDataTypeUInt8, MPSDataTypeFloat8E4M3, and MPSDataTypeFloat8E5M2. Float8 output requires symmetric quantization (zeroPoint = 0).

  • name:

    The name for the operation.

Return Value

A valid MPSGraphTensor array of datatype dataType

Discussion

Convert the float tensor to a quantized tensor by applying a scale + bias transform: result = round(tensor / scale) + zeroPoint