Skip to main content

F

Struct F 

Source
pub struct F<B: Backend, const D: usize>(pub FloatTensor<B>);
Expand description

A backend float-tensor primitive tagged with a compile-time rank D.

Mirrors the slice of Tensor’s method API needed by the custom backward gradient math, operating directly on B’s primitives.

Tuple Fields§

§0: FloatTensor<B>

Implementations§

Source§

impl<B: Backend, const D: usize> F<B, D>

Source

pub fn new(p: FloatTensor<B>) -> Self

Wrap a raw primitive.

Source

pub fn inner(self) -> FloatTensor<B>

Unwrap to the raw primitive.

Source

pub fn dims(&self) -> [usize; D]

Runtime shape as a [usize; D] array.

Source

pub fn device(&self) -> Device<B>

Device the tensor lives on.

Source

pub fn dtype(&self) -> FloatDType

Float dtype of the tensor.

Source

pub fn matmul(self, rhs: Self) -> Self

Batched matrix multiplication over the last two dims.

Source

pub fn permute(self, axes: [usize; D]) -> Self

Permute the axes (rank-preserving).

Source

pub fn swap_dims(self, dim1: usize, dim2: usize) -> Self

Swap two axes.

Source

pub fn exp(self) -> Self

Element-wise exp.

Source

pub fn sum_dim(self, dim: usize) -> Self

Sum along dim, keeping it as a size-1 axis (rank-preserving).

Source

pub fn cumsum(self, dim: usize) -> Self

Cumulative sum along dim.

Source

pub fn flip(self, axes: &[usize]) -> Self

Reverse the order of elements along the given axes (rank-preserving).

Source

pub fn slice<S: SliceArg>(self, slices: S) -> Self

Slice the tensor (rank-preserving), accepting the same s![..] args as the high-level API.

Source

pub fn narrow(self, dim: usize, start: usize, length: usize) -> Self

Narrow dim to [start, start + length) (rank-preserving).

Source

pub fn reshape<const D2: usize>(self, shape: [usize; D2]) -> F<B, D2>

Reshape to a new rank D2.

Source

pub fn expand(self, shape: [usize; D]) -> Self

Broadcast-expand to shape (rank-preserving).

Source

pub fn squeeze_dim<const D2: usize>(self, dim: usize) -> F<B, D2>

Remove the size-1 axis at dim, yielding rank D2 = D - 1.

Source

pub fn unsqueeze_dim<const D2: usize>(self, dim: usize) -> F<B, D2>

Insert a size-1 axis at dim, yielding rank D2 = D + 1.

Source

pub fn unsqueeze_dims<const D2: usize>(self, axes: &[isize]) -> F<B, D2>

Insert size-1 axes at the given output positions, yielding rank D2.

Mirrors Tensor::unsqueeze_dims: negative indices count from the back and duplicates insert multiple axes.

Source

pub fn triu(self, diagonal: i64) -> Self

Zero everything strictly below the diagonal (keeps the upper triangle).

Equivalent to Tensor::triu: builds the triangular bool mask over the last two dims and fills the masked region with 0.

Source

pub fn mask_fill(self, mask: Mask<B>, value: f32) -> Self

Fill the positions where mask is true with value.

Source

pub fn cat(tensors: Vec<F<B, D>>, dim: usize) -> Self

Concatenate same-rank tensors along dim (rank-preserving).

Source

pub fn stack<const D2: usize>(tensors: Vec<F<B, D>>, dim: usize) -> F<B, D2>

Stack same-rank tensors along a fresh axis dim, yielding rank D2 = D + 1.

Source

pub fn zeros(shape: [usize; D], device: &Device<B>, dtype: FloatDType) -> Self

All-zeros tensor of the given shape, dtype and device.

Source

pub fn full( shape: [usize; D], value: f32, device: &Device<B>, dtype: FloatDType, ) -> Self

Constant-filled tensor of the given shape, dtype and device.

Trait Implementations§

Source§

impl<B: Backend, const D: usize> Add for F<B, D>

Source§

type Output = F<B, D>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl<B: Backend, const D: usize> Clone for F<B, D>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<B: Backend, const D: usize> Mul for F<B, D>

Source§

type Output = F<B, D>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
Source§

impl<B: Backend, const D: usize> Neg for F<B, D>

Source§

type Output = F<B, D>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<B: Backend, const D: usize> Sub for F<B, D>

Source§

type Output = F<B, D>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<B, const D: usize> Freeze for F<B, D>
where <B as BackendTypes>::FloatTensorPrimitive: Freeze,

§

impl<B, const D: usize> RefUnwindSafe for F<B, D>
where <B as BackendTypes>::FloatTensorPrimitive: RefUnwindSafe,

§

impl<B, const D: usize> Send for F<B, D>

§

impl<B, const D: usize> Sync for F<B, D>

§

impl<B, const D: usize> Unpin for F<B, D>
where <B as BackendTypes>::FloatTensorPrimitive: Unpin,

§

impl<B, const D: usize> UnsafeUnpin for F<B, D>
where <B as BackendTypes>::FloatTensorPrimitive: UnsafeUnpin,

§

impl<B, const D: usize> UnwindSafe for F<B, D>
where <B as BackendTypes>::FloatTensorPrimitive: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.