layout_reshapeable

Function layout_reshapeable 

Source
pub fn layout_reshapeable(
    layout_in: &Layout<Vec<usize>>,
    shape_out: &Vec<usize>,
    order: FlagOrder,
) -> Result<Option<Layout<Vec<usize>>>, Error>
Expand description

Check if a tensor can be reshaped to a new shape without explicitly copying underlying data.

  • If shape not match, this function will raise error.
  • If shape match but data need to be copied, return Ok(None).
  • If everything is fine, return Ok(Some(layout_out)).

For order, row-major and col-major behaves differently.