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>
impl<B: Backend, const D: usize> F<B, D>
Sourcepub fn sum_dim(self, dim: usize) -> Self
pub fn sum_dim(self, dim: usize) -> Self
Sum along dim, keeping it as a size-1 axis (rank-preserving).
Sourcepub fn flip(self, axes: &[usize]) -> Self
pub fn flip(self, axes: &[usize]) -> Self
Reverse the order of elements along the given axes (rank-preserving).
Sourcepub fn slice<S: SliceArg>(self, slices: S) -> Self
pub fn slice<S: SliceArg>(self, slices: S) -> Self
Slice the tensor (rank-preserving), accepting the same s![..] args as
the high-level API.
Sourcepub fn narrow(self, dim: usize, start: usize, length: usize) -> Self
pub fn narrow(self, dim: usize, start: usize, length: usize) -> Self
Narrow dim to [start, start + length) (rank-preserving).
Sourcepub fn reshape<const D2: usize>(self, shape: [usize; D2]) -> F<B, D2>
pub fn reshape<const D2: usize>(self, shape: [usize; D2]) -> F<B, D2>
Reshape to a new rank D2.
Sourcepub fn squeeze_dim<const D2: usize>(self, dim: usize) -> F<B, D2>
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.
Sourcepub fn unsqueeze_dim<const D2: usize>(self, dim: usize) -> F<B, D2>
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.
Sourcepub fn unsqueeze_dims<const D2: usize>(self, axes: &[isize]) -> F<B, D2>
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.
Sourcepub fn triu(self, diagonal: i64) -> Self
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.
Sourcepub fn mask_fill(self, mask: Mask<B>, value: f32) -> Self
pub fn mask_fill(self, mask: Mask<B>, value: f32) -> Self
Fill the positions where mask is true with value.
Sourcepub fn cat(tensors: Vec<F<B, D>>, dim: usize) -> Self
pub fn cat(tensors: Vec<F<B, D>>, dim: usize) -> Self
Concatenate same-rank tensors along dim (rank-preserving).
Sourcepub fn stack<const D2: usize>(tensors: Vec<F<B, D>>, dim: usize) -> F<B, D2>
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.