Struct QkvParamsBase

Source
pub struct QkvParamsBase<S, D = Ix2>
where D: Dimension, S: RawData,
{ /* private fields */ }
Expand description

This object is designed to store the parameters of the QKV (Query, Key, Value)

Implementations§

Source§

impl<A, S, D> QkvParamsBase<S, D>
where D: Dimension, S: RawData<Elem = A>,

Source

pub fn new( query: ArrayBase<S, D>, key: ArrayBase<S, D>, value: ArrayBase<S, D>, ) -> Self

Source

pub fn from_elem<Sh: ShapeBuilder<Dim = D>>(shape: Sh, elem: A) -> Self
where A: Clone, S: DataOwned,

Source

pub fn default<Sh: ShapeBuilder<Dim = D>>(shape: Sh) -> Self
where A: Clone + Default, S: DataOwned,

Source

pub fn ones<Sh: ShapeBuilder<Dim = D>>(shape: Sh) -> Self
where A: Clone + One, S: DataOwned,

Source

pub fn zeros<Sh: ShapeBuilder<Dim = D>>(shape: Sh) -> Self
where A: Clone + Zero, S: DataOwned,

Source

pub const fn key(&self) -> &ArrayBase<S, D>

returns an immutable reference to the key parameters

Source

pub fn key_mut(&mut self) -> &mut ArrayBase<S, D>

returns a mutable reference to the key parameters

Source

pub const fn query(&self) -> &ArrayBase<S, D>

returns an immutable reference to the query parameters

Source

pub fn query_mut(&mut self) -> &mut ArrayBase<S, D>

returns a mutable reference to the query parameters

Source

pub const fn value(&self) -> &ArrayBase<S, D>

returns an immutable reference to the value parameters

Source

pub fn value_mut(&mut self) -> &mut ArrayBase<S, D>

returns a mutable reference to the value parameters

Source

pub fn set_key(&mut self, key: ArrayBase<S, D>) -> &mut Self

Source

pub fn set_query(&mut self, query: ArrayBase<S, D>) -> &mut Self

Source

pub fn set_value(&mut self, value: ArrayBase<S, D>) -> &mut Self

Source

pub fn with_key(self, key: ArrayBase<S, D>) -> Self

Source

pub fn with_query(self, query: ArrayBase<S, D>) -> Self

Source

pub fn with_value(self, value: ArrayBase<S, D>) -> Self

Trait Implementations§

Source§

impl<X, Z, A, S, D> Forward<X> for QkvParamsBase<S, D>
where A: Clone, D: Dimension, S: Data<Elem = A>, X: Dot<ArrayBase<S, D>, Output = Z>, for<'a> Z: Add<Output = Z> + Add<&'a Z, Output = Z>,

This trait is used to implement the forward pass for the QKV parameters.

Source§

type Output = Z

Source§

fn forward(&self, input: &X) -> Result<Self::Output>

a single forward step
Source§

fn forward_then<F>(&self, input: &Rhs, then: F) -> Result<Self::Output, Error>
where F: FnOnce(Self::Output) -> Self::Output,

this method enables the forward pass to be generically activated using some closure. This is useful for isolating the logic of the forward pass from that of the activation function and is often used by layers and models.

Auto Trait Implementations§

§

impl<S, D> Freeze for QkvParamsBase<S, D>
where S: Freeze, D: Freeze,

§

impl<S, D> RefUnwindSafe for QkvParamsBase<S, D>

§

impl<S, D> Send for QkvParamsBase<S, D>
where S: Send + Data,

§

impl<S, D> Sync for QkvParamsBase<S, D>
where S: Sync + Data,

§

impl<S, D> Unpin for QkvParamsBase<S, D>
where S: Unpin, D: Unpin,

§

impl<S, D> UnwindSafe for QkvParamsBase<S, D>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<M, U, V> Predict<U> for M
where M: Forward<U, Output = V>,

Source§

type Output = V

Source§

fn __private__(&self) -> Seal

Source§

fn predict(&self, input: &U) -> Result<<M as Predict<U>>::Output, NeuralError>

Source§

impl<M, U, A, D> PredictWithConfidence<U> for M
where A: Float + FromPrimitive + ScalarOperand, D: Dimension, M: Predict<U, Output = ArrayBase<OwnedRepr<A>, D>>,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more