pub(super) struct Operand {
pub(super) transposed: bool,
pub(super) leading: i32,
}
pub(super) fn classify(strides: [usize; 2], rows: usize, columns: usize) -> Option<Operand> {
if strides[1] == 1 {
let leading = if rows == 1 { columns } else { strides[0] };
if leading < columns {
return None;
}
return Some(Operand {
transposed: false,
leading: i32::try_from(leading).ok()?,
});
}
if strides[0] == 1 {
let leading = if columns == 1 { rows } else { strides[1] };
if leading < rows {
return None;
}
return Some(Operand {
transposed: true,
leading: i32::try_from(leading).ok()?,
});
}
None
}
#[cfg(test)]
#[path = "tests/operand_tests.rs"]
mod tests;