Returns the k largest values along the last axis, sorted in
descending order, together with their indices into that axis.
For other axes, transpose so the target axis is last, call
prim_top_k(), then transpose back. nv_top_k() does this.
Arguments
- x
(
arrayish)
Tensor of integer, unsigned integer, or floating-point dtype with rank >= 1.- k
(
integer(1))
Number of top elements. Must satisfy1 <= k <= shape(x)[naxes(x)].
Value
list of two arrayish values:
The top-k values (same dtype as x) and their indices along
the last axis (dtype i32, matching JAX). Both have the same
shape as x with the last axis replaced by k. Ties are
broken by lower index first.
StableHLO
Lowers to hlo_top_k().