prepare_output_view

Function prepare_output_view 

Source
pub fn prepare_output_view<T: Scalar>(
    view: &mut StridedViewMut<'_, T>,
    _n_batch: usize,
    n_group1: usize,
    n_group2: usize,
    beta: T,
) -> Result<ContiguousOperandMut<T>>
Expand description

Prepare a borrowed mutable output view for GEMM.

Expects batch-last canonical order: [group1..., group2..., batch...]. Checks if the two inner dimension groups (lo, ro) are fusable. If not, allocates a col-major buffer and copies the existing data into it when beta is non-zero (so the GEMM accumulation is correct).

After GEMM, call ContiguousOperandMut::finalize_into with the original view to copy results back if needed.

§Safety contract

When inner dims are fusable (no copy needed), the returned ContiguousOperandMut holds a raw pointer into view’s data. The caller must ensure view outlives the returned operand and that no aliasing mutable references exist during GEMM.