pub struct DenseLinear<B: Backend> { /* private fields */ }Expand description
Dense linear projection.
Holds a single weight matrix laid out row-major as [out_features, in_features].
forward delegates to B::gemm plus (optional) B::add_bias.
Implementations§
Source§impl<B: Backend> DenseLinear<B>
impl<B: Backend> DenseLinear<B>
Sourcepub fn from_rows(
weight_row_major: &[f32],
out_features: usize,
in_features: usize,
) -> Self
pub fn from_rows( weight_row_major: &[f32], out_features: usize, in_features: usize, ) -> Self
Build a weight-only dense projection (no bias).
Sourcepub fn from_rows_with_bias(
weight_row_major: &[f32],
bias: &[f32],
out_features: usize,
in_features: usize,
) -> Self
pub fn from_rows_with_bias( weight_row_major: &[f32], bias: &[f32], out_features: usize, in_features: usize, ) -> Self
Build a dense projection with a bias vector of length out_features.
Sourcepub fn from_buffer(
weight: B::Buffer,
out_features: usize,
in_features: usize,
) -> Self
pub fn from_buffer( weight: B::Buffer, out_features: usize, in_features: usize, ) -> Self
Construct by moving already-allocated Backend buffers.
pub fn with_bias(self, bias: B::Buffer) -> Self
pub fn weight(&self) -> &B::Buffer
pub fn bias(&self) -> Option<&B::Buffer>
Trait Implementations§
Source§impl<B: Backend> Linear<B> for DenseLinear<B>
impl<B: Backend> Linear<B> for DenseLinear<B>
Auto Trait Implementations§
impl<B> Freeze for DenseLinear<B>
impl<B> RefUnwindSafe for DenseLinear<B>
impl<B> Send for DenseLinear<B>
impl<B> Sync for DenseLinear<B>
impl<B> Unpin for DenseLinear<B>
impl<B> UnsafeUnpin for DenseLinear<B>
impl<B> UnwindSafe for DenseLinear<B>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more