IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo trait

IndexerTopk

Selects each indexer score row's top-k key positions.

The contract is persistent_topk_block_split's with ordered=False: row r scans its first row_bounds.row(r)[0] columns, a row with at most k of them takes them all with -1 in the slots past them, and the order of the k columns, and which columns tied at the k-th score survive, are unspecified. An implementation may promise more: BlockSplitTopk[True] makes both reproducible, the same columns in the same slots on every run.

Implemented traits​

AnyType

Required methods​

select​

static def select[in_dtype: DType, RB: RowBound](ctx: DeviceContext, scores: ImmPointer[Scalar[in_dtype], ImmutAnyOrigin], out_idxs: MutPointer[Int32, MutAnyOrigin], n: Int, k: Int, rows: Int, row_bounds: RB)

Writes the top-k columns of each row of scores to out_idxs.

Parameters:

  • ​in_dtype (DType): Score element type.
  • ​RB (RowBound): Type of row_bounds.

Args:

Was this page helpful?