Mojo function
top_k_fused_sampling_cpu
top_k_fused_sampling_cpu[type: DType, rank: Int, out_idx_type: DType](k: Int, input: NDBuffer[type, rank, origin], out_idxs: NDBuffer[out_idx_type, rank, origin], temperature: SIMD[type, 1] = __init__[__mlir_type.!pop.int_literal](1))
Generalized implementation of the Top K algorithm with sampling. Returns the sampled index from the innermost dimension of the input tensor for each row/subvolume.
Parameters:
- type (
DType
): Data type of the input buffer. - rank (
Int
): Rank of the input. - out_idx_type (
DType
): Data type of the output indices.
Args:
- k (
Int
): Int - Represents the K largest values to consider for sampling. - input (
NDBuffer[type, rank, origin]
): NDBuffer[type, rank] (Any shape)- The input tensor. - out_idxs (
NDBuffer[out_idx_type, rank, origin]
): NDBuffer[out_idx_type, rank] (shape of [input_shape[:-1]] + [1]) - The output indices. - temperature (
SIMD[type, 1]
): The temperature based scaling.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!