---
title: "applyInTopK(k:input:testIndices:output:axis:batchSize:filterParameters:)"
framework: accelerate
role: symbol
role_heading: Type Method
path: "accelerate/bnns/applyintopk(k:input:testindices:output:axis:batchsize:filterparameters:)"
---

# applyInTopK(k:input:testIndices:output:axis:batchSize:filterParameters:)

Applies an in-top-k filter directly to an input.

## Declaration

```swift
static func applyInTopK(k: Int, input: BNNSNDArrayDescriptor, testIndices: BNNSNDArrayDescriptor, output: BNNSNDArrayDescriptor, axis: Int, batchSize: Int, filterParameters: BNNSFilterParameters? = nil) throws
```

## Parameters

- `k`: The number of entries the operation finds.
- `input`: The descriptor of the input.
- `testIndices`: The descriptor of the test indices.
- `output`: The descriptor of the output.
- `axis`: The axis along which the operation finds top-k entries.
- `batchSize`: The number of input-output pairs to process.
- `filterParameters`: The filter runtime parameters.

## Discussion

Discussion important: The input data type must be float, the test indices data type must be int32, and the output data type must be BNNSDataTypeBoolean.

## See Also

### Related Documentation

- [BNNSDirectApplyInTopK(_:_:_:_:_:_:_:_:_:_:)](accelerate/bnnsdirectapplyintopk(_:_:_:_:_:_:_:_:_:_:).md)

### Top-k layers

- [applyTopK(k:input:bestValues:bestIndices:axis:batchSize:filterParameters:)](accelerate/bnns/applytopk(k:input:bestvalues:bestindices:axis:batchsize:filterparameters:).md)
