Function expand_labels

Source
pub fn expand_labels(factors: &[(String, Vec<usize>)]) -> Vec<String>
Expand description

Expands factored dimension labels into one label per subdimension.

Each input pair (label, factors) represents an original dimension and the extents it was factored into. If a dimension was not factored, it will have a single-element vector.

For example:

  • [("zone", vec![2]), ("gpu", vec![2, 2, 2])] becomes ["zone", "gpu/0", "gpu/1", "gpu/2"]

This is used to generate new labels for reshaped shapes, where the dimensionality increases due to factoring.

§Arguments

  • factors: a list of factored dimension extents, paired with their labels

§Returns

  • A Vec<String> of expanded labels, one for each reshaped dimension.