pub struct MetalLlmBackend { /* private fields */ }Implementations§
Source§impl MetalLlmBackend
impl MetalLlmBackend
pub fn is_available() -> bool
Trait Implementations§
Source§impl Clone for MetalLlmBackend
impl Clone for MetalLlmBackend
Source§fn clone(&self) -> MetalLlmBackend
fn clone(&self) -> MetalLlmBackend
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MetalLlmBackend
impl Debug for MetalLlmBackend
Source§impl Default for MetalLlmBackend
impl Default for MetalLlmBackend
Source§fn default() -> MetalLlmBackend
fn default() -> MetalLlmBackend
Returns the “default value” for a type. Read more
Source§impl LlmBackend for MetalLlmBackend
impl LlmBackend for MetalLlmBackend
fn name(&self) -> &'static str
fn linear_3d(&self, x: &Tensor, weight: &Tensor) -> Result<Tensor>
fn rms_norm(&self, x: &Tensor, weight: &Tensor, eps: f32) -> Result<Tensor>
fn layer_norm( &self, x: &Tensor, weight: &Tensor, bias: Option<&Tensor>, eps: f32, ) -> Result<Tensor>
fn silu(&self, x: &Tensor) -> Result<Tensor>
fn gelu(&self, x: &Tensor) -> Result<Tensor>
fn add(&self, a: &Tensor, b: &Tensor) -> Result<Tensor>
fn mul(&self, a: &Tensor, b: &Tensor) -> Result<Tensor>
fn apply_rope_positions( &self, x: &Tensor, positions: &[usize], base: f32, ) -> Result<Tensor>
fn gqa_attention( &self, q: &Tensor, k: &Tensor, v: &Tensor, n_kv_heads: usize, causal: bool, ) -> Result<Tensor>
Source§fn linear_3d_bias(
&self,
x: &Tensor,
weight: &Tensor,
bias: Option<&Tensor>,
) -> Result<Tensor>
fn linear_3d_bias( &self, x: &Tensor, weight: &Tensor, bias: Option<&Tensor>, ) -> Result<Tensor>
Linear projection with an optional bias added over the last dimension.
Backend-agnostic: computes
linear_3d then folds in the bias on the host,
so every backend gets correct bias handling for free.Source§fn apply_rope_partial(
&self,
x: &Tensor,
positions: &[usize],
base: f32,
rotary_dim: usize,
) -> Result<Tensor>
fn apply_rope_partial( &self, x: &Tensor, positions: &[usize], base: f32, rotary_dim: usize, ) -> Result<Tensor>
RoPE over only the first
rotary_dim channels (Phi partial rotary).
Computed on the CPU reference kernel for all backends — it is cheap and
avoids backend-specific partial-rotary support.Auto Trait Implementations§
impl Freeze for MetalLlmBackend
impl RefUnwindSafe for MetalLlmBackend
impl Send for MetalLlmBackend
impl Sync for MetalLlmBackend
impl Unpin for MetalLlmBackend
impl UnsafeUnpin for MetalLlmBackend
impl UnwindSafe for MetalLlmBackend
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more