---
title: "HammingDistance(primary:secondary:resultDataType:name:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/hammingdistance(primary:secondary:resultdatatype:name:)"
---

# HammingDistance(primary:secondary:resultDataType:name:)

Computes the hamming distance of two input tensors with support for broadcasting.

## Declaration

```swift
func HammingDistance(primary primaryTensor: MPSGraphTensor, secondary secondaryTensor: MPSGraphTensor, resultDataType: MPSDataType, name: String?) -> MPSGraphTensor
```

## Parameters

- `primaryTensor`: The first input tensor.
- `secondaryTensor`: The second input tensor.
- `resultDataType`: The datatype of the return MPSGraphTensor. Must be either MPSDataTypeUInt32 or MPSDataTypeUInt16.
- `name`: The name for the operation.

## Return Value

Return Value A valid tensor containing the hamming distance between the input tensors.

## Discussion

Discussion The hamming distance is computed between 2 sets of vectors and the last dimension(s) of each input tensor is considered a vector.
