modeci_mdf.functions.onnx.topk
- modeci_mdf.functions.onnx.topk(*args, **kwargs)
Retrieve the top-K largest or smallest elements along a specified axis. Given an input tensor of shape [a_0, a_1, …, a_{n-1}] and integer argument k, return two outputs:
Value tensor of shape [a_0, a_1, …, a_{axis-1}, k, a_{axis+1}, … a_{n-1}] which contains the values of the top k elements along the specified axis
Index tensor of shape [a_0, a_1, …, a_{axis-1}, k, a_{axis+1}, … a_{n-1}] which contains the indices of the top k elements (original indices from the input tensor).
If “largest” is 1 (the default value) then the k largest elements are returned.
If “sorted” is 1 (the default value) then the resulting k elements will be sorted.
If “sorted” is 0, order of returned ‘Values’ and ‘Indices’ are undefined.
Given two equivalent values, this operator uses the indices along the axis as a tiebreaker. That is, the element with the lower index will appear first.