---
title: "quantize(_:scaleTensor:zeroPointTensor:dataType:axis:name:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/quantize(_:scaletensor:zeropointtensor:datatype:axis:name:)"
---

# quantize(_:scaleTensor:zeroPointTensor:dataType:axis:name:)

Creates a Quantize operation and returns the result tensor.

## Declaration

```swift
func quantize(_ tensor: MPSGraphTensor, scaleTensor: MPSGraphTensor, zeroPointTensor: MPSGraphTensor, dataType: MPSDataType, axis: Int, name: String?) -> MPSGraphTensor
```

## Parameters

- `tensor`: Input tensor to be quantized
- `scaleTensor`: Scale scalar or 1D Tensor parameter with size == tensor.shape[axis]
- `zeroPointTensor`: Bias scalar or 1D Tensor parameter with size == tensor.shape[axis]
- `dataType`: Integer data type of the result tensor.
- `axis`: Axis on which the scale 1D value is being broadcasted
- `name`: The name for the operation.

## Return Value

Return Value A valid MPSGraphTensor array of datatype dataType

## Discussion

Discussion Convert the float tensor to an i8 or u8 tensor by applying a scale + bias transform: result = (tensor / scaleTensor) + zeroPointTensor
