<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/BNNS/applyInTopK(k:input:testIndices:output:axis:batchSize:filterParameters:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate4BNNSO11applyInTopK1k5input11testIndices6output4axis9batchSize16filterParametersySi_So21BNNSNDArrayDescriptoraA2MS2iSo010BNNSFilterN0aSgtKFZ"
  },
  "title" : "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.

```
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

> 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

[`func BNNSDirectApplyInTopK(Int, Int, Int, UnsafePointer<BNNSNDArrayDescriptor>, Int, UnsafePointer<BNNSNDArrayDescriptor>, Int, UnsafeMutablePointer<BNNSNDArrayDescriptor>, Int, UnsafePointer<BNNSFilterParameters>?) -> Int32`](/documentation/Accelerate/BNNSDirectApplyInTopK(_:_:_:_:_:_:_:_:_:_:))

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



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)