pub fn plan_lazy_outer_product(
output_dims: &[usize],
lhs_dims: &[usize],
lhs_strides: &[isize],
lhs_axes: &[usize],
rhs_dims: &[usize],
rhs_strides: &[isize],
rhs_axes: &[usize],
) -> Result<Option<LazyOuterProductLayout>>Expand description
Plan an outer-product output whose memory order follows the inputs’ physical stride order instead of the logical output order.
lhs_axes[k] (respectively rhs_axes[k]) names the output axis that
operand axis k maps to, with the operand extent equal to the output
extent. Output axes mapped only by lhs are its free axes, axes mapped
only by rhs are its free axes, and axes mapped by both are batch axes.
A layout is returned only when the product splits into free and batch
groups, both free groups have more than one element, the logical output
order is [lhs_free, rhs_free, batch] or [rhs_free, lhs_free, batch],
all strides are non-negative, and sorting either operand’s free axes by
(stride, axis) changes their order. The base then holds the leading
group’s free axes in the leading operand’s physical order, then the
trailing group’s free axes in the trailing operand’s physical order, then
the batch axes in output order. Traversing inputs in their physical order
while writing the base contiguously is what makes the layout useful.
§Examples
use strided_basic::plan_lazy_outer_product;
// lhs is a transposed 2 x 3 matrix (row-major strides), rhs is a vector.
let layout = plan_lazy_outer_product(&[2, 3, 4], &[2, 3], &[3, 1], &[0, 1], &[4], &[1], &[2])
.unwrap()
.unwrap();
assert_eq!(layout.base_dims, [3, 2, 4]);
assert_eq!(layout.output_strides, [3, 1, 6]);§Errors
Returns StridedError::RankMismatch when an operand’s dims, strides,
and axis map lengths disagree, and StridedError::OffsetOverflow when a
base extent product or stride is not representable. Inputs that are valid
but ineligible return Ok(None).