---
title: "nonZeroIndices(_:name:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/nonzeroindices(_:name:)"
---

# nonZeroIndices(_:name:)

Computes the indices of the non-zero elements of the input tensor.

## Declaration

```swift
func nonZeroIndices(_ tensor: MPSGraphTensor, name: String?) -> MPSGraphTensor
```

## Parameters

- `tensor`: An MPSGraphTensor of which to compute the non-zero indices.

## Return Value

Return Value A valid MPSGraphTensor containing indices in signed int32 data type.

## Discussion

Discussion The indices are returned as a two-dimensional tensor of size [number_of_nonzeros, input_rank]. Each row in the result contains indices of a nonzero elements in input. For example: tensor = [[ 1,  0, 3],           [ 0, 10, 0]] indices = [[ 0, 0],            [ 0, 2],            [ 1, 1]]
