pub fn erased_broadcast_mul_into_uninit(
dtype: KernelDType,
ctx: &ExecContext,
dest: &mut ErasedRawStridedUninitMut<'_>,
lhs: &ErasedRawStridedPtr<'_>,
lhs_axes: &[usize],
rhs: &ErasedRawStridedPtr<'_>,
rhs_axes: &[usize],
) -> Result<()>Expand description
Broadcast two same-dtype operands onto the destination axes and multiply them into uninitialized storage.
lhs_axes[k] names the destination axis that lhs axis k maps to; each
mapped extent must equal the destination extent or be one, and unmapped
destination axes broadcast. Supported dtypes are f32, f64, c32,
c64, and the signed integers, whose products wrap on overflow.
§Examples
use core::mem::MaybeUninit;
use strided_kernel::{
erased_broadcast_mul_into_uninit, ErasedRawStridedPtr, ErasedRawStridedRef,
ErasedRawStridedUninitMut, ExecContext, KernelDType,
};
// Outer product: out[i, j] = a[i] * b[j], column-major 2 x 3 output.
let a = [1.0_f64, 2.0];
let b = [10.0_f64, 20.0, 30.0];
let a = ErasedRawStridedRef::from_slice(&a, &[2], &[1], 0).unwrap();
let b = ErasedRawStridedRef::from_slice(&b, &[3], &[1], 0).unwrap();
let mut out = [MaybeUninit::<f64>::uninit(); 6];
let mut dest =
ErasedRawStridedUninitMut::from_uninit_slice(&mut out, &[2, 3], &[1, 2], 0).unwrap();
erased_broadcast_mul_into_uninit(
KernelDType::F64,
&ExecContext::serial(),
&mut dest,
&ErasedRawStridedPtr::from_ref(&a),
&[0],
&ErasedRawStridedPtr::from_ref(&b),
&[1],
)
.unwrap();
// SAFETY: a successful call initializes every reachable element.
let out = unsafe { out.map(|value| value.assume_init()) };
assert_eq!(out, [10.0, 20.0, 20.0, 40.0, 30.0, 60.0]);§Errors
Returns a typed StridedError for dtype, axis mapping, shape,
output-layout, or overlap contracts. Validation completes before any write.