pub fn truncation_select<B: Backend>(
population: &Tensor<B, 2>,
fitness: &[f32],
top_k: usize,
device: &<B as BackendTypes>::Device,
) -> Tensor<B, 2>Expand description
Gathers the top_k highest-fitness rows out of a population tensor.
Convenience wrapper that runs truncation_indices_host on the
host and then performs a single Tensor::select gather on the
device. The returned tensor has shape (top_k, genome_dim) with
rows ordered from best to worst fitness.
population must have shape (N, D) where N matches
fitness.len().
§Panics
Inherits the panic conditions of truncation_indices_host:
fitness.is_empty() or top_k > fitness.len().
Panics if population.dims()[0] != fitness.len().