oa::matrix::top_k

Return the largest k FP32 values and their I32 indices on the last axis. Rank-one and rank-two inputs are admitted. dim may be -1 or the exact last-axis index. Values are sorted descending; ties select lower indices. k is clamped to the last-axis extent, matching OA C++. Errors Returns an error for an unsupported rank, dtype, axis, negative k, a request above the admitted 1024-entry GPU limit, an empty last axis, size overflow, allocation failure, or runtime recording failure.

FnRust public API

Function Documentation

pub fn top_k( input: &Matrix, k: i32, dim: i32 ) -> Result<TopKResult>
Return the largest k FP32 values and their I32 indices on the last axis. Rank-one and rank-two inputs are admitted. dim may be -1 or the exact last-axis index. Values are sorted descending; ties select lower indices. k is clamped to the last-axis extent, matching OA C++. Errors Returns an error for an unsupported rank, dtype, axis, negative k, a request above the admitted 1024-entry GPU limit, an empty last axis, size overflow, allocation failure, or runtime recording failure.