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 function
argsort
def argsort[*, ascending: Bool = True, target: StringSpan[ImmStaticOrigin] = StringSpan("cpu"), IndicesEngine: TensorEngine = DefaultEngine, InputEngine: TensorEngine = DefaultEngine](output: TileTensor[Engine=IndicesEngine, linear_idx_type=output.linear_idx_type], input: TileTensor[Engine=InputEngine, address_space=input.address_space, linear_idx_type=input.linear_idx_type], ctx: DeviceContext)
Performs argsort on input buffer, storing indices in output buffer.
Parameters:
- ascending (
Bool): Sort direction (True for ascending, False for descending). - target (
StringSpan[ImmStaticOrigin]): Target device ("cpu" or "gpu"). - IndicesEngine (
TensorEngine): Engine of the output (indices) tile. - InputEngine (
TensorEngine): Engine of the input tile.
Args:
- output (
TileTensor[Engine=IndicesEngine, linear_idx_type=output.linear_idx_type]): Buffer to store sorted indices. - input (
TileTensor[Engine=InputEngine, address_space=input.address_space, linear_idx_type=input.linear_idx_type]): Buffer containing values to sort. - ctx (
DeviceContext): Device context for execution.
def argsort[ascending: Bool = True, IndicesEngine: TensorEngine = DefaultEngine, InputEngine: TensorEngine = DefaultEngine](output: TileTensor[Engine=IndicesEngine, linear_idx_type=output.linear_idx_type], input: TileTensor[Engine=InputEngine, address_space=input.address_space, linear_idx_type=input.linear_idx_type])
CPU-only version of argsort.
Parameters:
- ascending (
Bool): Sort direction (True for ascending, False for descending). - IndicesEngine (
TensorEngine): Engine of the output (indices) tile. - InputEngine (
TensorEngine): Engine of the input tile.
Args:
- output (
TileTensor[Engine=IndicesEngine, linear_idx_type=output.linear_idx_type]): Buffer to store sorted indices. - input (
TileTensor[Engine=InputEngine, address_space=input.address_space, linear_idx_type=input.linear_idx_type]): Buffer containing values to sort.