Skip to main content

Tensor

Struct Tensor 

Source
pub struct Tensor { /* private fields */ }
Expand description

A symbolic tensor in a traced graph.

Lazy by construction. Despite the eager-looking operator syntax, a Tensor is a deferred handle: &a + &b, .relu(), .matmul(..) etc. only append IR nodes — no host or device buffers are allocated and nothing executes. The graph is compiled (fused + memory-planned) and run only when you force it with to_vec / realize (both require the eval feature). This is what lets the whole expression fuse instead of materializing every intermediate.

Zero-copy clone & slice. clone() just bumps a refcount on the shared graph handle — no data is duplicated. slice/narrow/reshape/select add a view node into the same graph (referencing the parent by id), so they move zero payload bytes either. Use shares_graph to observe storage sharing and storage_bytes to confirm no data was copied. (Combining two independently-constructed tensors is the one case that copies — the right operand’s nodes are merged in once; see [crate::handle].)

Implementations§

Source§

impl Tensor

Source

pub fn from_vec(data: impl Into<Vec<f32>>, shape: impl AsRef<[usize]>) -> Self

Constant tensor from row-major host data (F32). The product of shape must equal data.len().

Source

pub fn zeros(shape: impl AsRef<[usize]>) -> Self

All-zeros constant of the given shape (F32).

Source

pub fn ones(shape: impl AsRef<[usize]>) -> Self

All-ones constant of the given shape (F32).

Source

pub fn full(shape: impl AsRef<[usize]>, value: f32) -> Self

Constant of the given shape filled with value (F32).

Source

pub fn eye(n: usize) -> Self

n × n identity matrix (F32).

Source

pub fn arange(end: i64) -> Self

1-D constant [0, 1, …, end) (F32).

Source

pub fn arange_step(start: i64, end: i64, step: i64) -> Self

1-D constant [start, start+step, …) up to (excluding) end (F32).

Source

pub fn from_f64(data: impl AsRef<[f64]>, shape: impl AsRef<[usize]>) -> Self

F64 (double-precision) constant from host data.

Source

pub fn from_i64(data: impl AsRef<[i64]>, shape: impl AsRef<[usize]>) -> Self

I64 constant from host data (general N-D).

Source

pub fn index_vec(data: impl AsRef<[i64]>) -> Self

1-D I64 index vector for gather / index_select.

Source

pub fn rand(shape: impl AsRef<[usize]>, seed: u64) -> Self

Uniform random in [0, 1) (F32), reproducible from seed.

Source

pub fn rand_range( shape: impl AsRef<[usize]>, seed: u64, lo: f32, hi: f32, ) -> Self

Uniform random in [lo, hi) (F32), reproducible from seed.

Source

pub fn randn(shape: impl AsRef<[usize]>, seed: u64) -> Self

Standard-normal random (mean 0, std 1), reproducible from seed.

Source

pub fn randn_std( shape: impl AsRef<[usize]>, seed: u64, mean: f32, std: f32, ) -> Self

Normal random with the given mean/std, reproducible from seed. Useful for weight init, e.g. randn_std(shape, seed, 0.0, (2.0/fan_in).sqrt()).

Source§

impl Tensor

Source

pub fn id(&self) -> NodeId

IR node id (mix with raw rlx_ir::Graph builders via NodeId).

Source

pub fn shape(&self) -> Shape

Source

pub fn dtype(&self) -> DType

Source

pub fn rank(&self) -> usize

Source

pub fn dims(&self) -> Vec<usize>

Static dimensions as a Vec<usize> (panics on a dynamic axis).

Source

pub fn numel(&self) -> usize

Total number of elements (panics on a dynamic axis).

Source

pub fn is_static_shape(&self) -> bool

True when every dimension is statically known.

Source

pub fn shares_graph(&self, other: &Tensor) -> bool

True if self and other are backed by the same graph — i.e. one is a clone or a view (slice/reshape/narrow/…) of the other, sharing storage with zero copy. Tensors from independent constructors return false until they’re combined in an op.

Source

pub fn storage_bytes(&self) -> usize

Total bytes of constant (payload) data physically held in the backing graph. Cloning and slicing do not increase this — they share storage and only add zero-payload view nodes. Combining tensors from different graphs copies the right-hand operand’s data in (once).

Source

pub fn slice(&self, spec: SliceSpec) -> Self

View slice — lowers to narrow (no copy at IR level).

Source

pub fn mm(&self, rhs: &Tensor) -> Self

Matrix multiply (@ in Python / JAX).

Source

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

Source

pub fn scaled_matmul( &self, rhs: &Tensor, fmt: ScaledFormat, layout: ScaleLayout, ) -> Self

Native low-precision GEMM (TN: self [m,k] · rhs [n,k]ᵀ → [m,n]). Both operands are dynamically quantized to the minifloat fmt + layout; rhs must be K-last ([n, k]). fmt may be any ScaledFormat, including a parameterized Custom — e.g. t.scaled_matmul(&w, ScaledFormat::custom(3, 0), ScaleLayout::mx()) runs the matmul in f4e3m0.

Source

pub fn softmax(&self, axis: i32) -> Self

Source

pub fn reshape(&self, new_shape: impl Into<Vec<i64>>) -> Self

Source

pub fn transpose(&self, perm: impl Into<Vec<usize>>) -> Self

Source

pub fn t(&self) -> Self

Source

pub fn cast(&self, to: DType) -> Self

Source

pub fn narrow(&self, axis: usize, start: usize, len: usize) -> Self

Source

pub fn broadcast_to(&self, shape: impl Into<Vec<i64>>) -> Self

Broadcast (expand) to an explicit target shape — NumPy broadcast_to. A 1 axis stretches; sizes must otherwise match. Use -1-free static targets.

Source

pub fn flatten(&self) -> Self

Flatten to a 1-D tensor (row-major).

Source

pub fn unsqueeze(&self, axis: usize) -> Self

Insert a size-1 axis at axis (NumPy expand_dims / PyTorch unsqueeze).

Source

pub fn squeeze(&self, axis: usize) -> Self

Remove the size-1 axis at axis (panics if it is not size 1).

Source

pub fn squeeze_all(&self) -> Self

Remove every size-1 axis.

Source

pub fn split(&self, axis: usize, sizes: &[usize]) -> Vec<Tensor>

Split axis into contiguous pieces of the given sizes (must sum to the axis length). NumPy split / PyTorch split_with_sizes.

Source

pub fn chunk(&self, axis: usize, n: usize) -> Vec<Tensor>

Split axis into n near-equal chunks (first len % n get one extra).

Source

pub fn tile(&self, axis: usize, reps: usize) -> Tensor

Repeat the whole tensor reps times along axis (NumPy tile on one axis): output axis length becomes len * reps.

Source

pub fn flip(&self, axis: usize) -> Tensor

Reverse the order of elements along axis (NumPy flip).

Source

pub fn roll(&self, axis: usize, shift: usize) -> Tensor

Cyclically shift elements along axis by shift (NumPy roll).

Source

pub fn pad( &self, axis: usize, before: usize, after: usize, value: f32, ) -> Tensor

Pad axis with before/after entries of value (constant pad).

Source

pub fn gather(&self, indices: &Tensor, axis: usize) -> Self

Source

pub fn index_select(&self, axis: usize, indices: &Tensor) -> Self

Gather along axis by an index tensor — NumPy take / PyTorch index_select. Alias for gather.

Source

pub fn select(&self, axis: usize, index: i64) -> Self

Pick a single position along axis, dropping that axis (NumPy a[…, i, …]). Negative index counts from the end.

Source

pub fn stop_gradient(&self) -> Self

Source

pub fn argmax(&self, axis: usize, keep_dim: bool) -> Self

Index of the maximum along axis (f32-encoded indices). Drops the axis unless keep_dim.

Source

pub fn argmin(&self, axis: usize, keep_dim: bool) -> Self

Index of the minimum along axis (f32-encoded indices).

Source

pub fn inv(&self) -> Self

Matrix inverse of a square 2-D tensor. Composite over DenseSolve (inv(A) = solve(A, I)), so it needs a BLAS-backed eval build (LAPACK) to run, not the default splat backend.

Source

pub fn solve(&self, b: &Tensor) -> Self

Solve the linear system self @ x = b for x (LAPACK via DenseSolve; needs a BLAS eval build). x takes b’s shape.

Source

pub fn cumsum(&self, axis: i32, exclusive: bool) -> Self

Cumulative sum along axis. exclusive shifts so output[0] = 0.

Source

pub fn var(&self, axes: impl Into<Vec<usize>>, keep_dim: bool) -> Self

Population variance over axes: mean((x - mean(x))²).

Source

pub fn std(&self, axes: impl Into<Vec<usize>>, keep_dim: bool) -> Self

Population standard deviation over axes.

Source

pub fn norm(&self, axes: impl Into<Vec<usize>>, keep_dim: bool) -> Self

L2 (Frobenius) norm over axes: sqrt(sum(x²)).

Source

pub fn logsumexp(&self, axis: usize, keep_dim: bool) -> Self

Numerically-stable log(sum(exp(x))) along axis (max + log(sum(exp(x - max)))).

Source

pub fn fft(&self) -> Self

1-D FFT along the last axis (unnormalized; ifft(fft(x)) = N·x). Complex data uses the [..., 2N] block layout (real plane then imag plane) for F32/F64, or a C64 last axis. Output matches input shape.

Source

pub fn ifft(&self) -> Self

Inverse 1-D FFT along the last axis (unnormalized — pairs with [fft] up to the N factor).

Source

pub fn fft_axis(&self, axis: usize, inverse: bool) -> Self

1-D FFT along an arbitrary axis (transpose → fft → transpose).

Source

pub fn layer_norm(&self, gamma: &Tensor, beta: &Tensor, eps: f32) -> Self

Source

pub fn rms_norm(&self, gamma: &Tensor, beta: &Tensor, eps: f32) -> Self

Source

pub fn conv2d( &self, weight: &Tensor, kernel_size: [usize; 2], stride: [usize; 2], padding: [usize; 2], dilation: [usize; 2], groups: usize, ) -> Self

Source

pub fn attention( &self, k: &Tensor, v: &Tensor, num_heads: usize, head_dim: usize, mask_kind: MaskKind, ) -> Self

Source

pub fn rope(&self, cos: &Tensor, sin: &Tensor, head_dim: usize) -> Self

Source

pub fn where_(&self, on_true: &Tensor, on_false: &Tensor) -> Self

Source

pub fn masked_fill(&self, mask: &Tensor, value: f64) -> Self

Replace entries of self where mask is true with value (NumPy masked_fill / the attention-mask primitive: scores.masked_fill(causal, f32::NEG_INFINITY) then softmax). Requires a static shape.

Source

pub fn maximum(&self, rhs: &Tensor) -> Self

Elementwise maximum.

Source

pub fn minimum(&self, rhs: &Tensor) -> Self

Elementwise minimum.

Source

pub fn clamp(&self, min: f64, max: f64) -> Self

Clamp values to [min, max].

Source

pub fn clamp_min(&self, min: f64) -> Self

Lower-bound values at min.

Source

pub fn clamp_max(&self, max: f64) -> Self

Upper-bound values at max.

Source

pub fn pow(&self, rhs: &Tensor) -> Self

Source

pub fn pow_scalar(&self, exp: f64) -> Self

Source§

impl Tensor

Source

pub fn relu(&self) -> Self

Rectified linear unit max(x, 0).

Source

pub fn gelu(&self) -> Self

Gaussian error linear unit (exact).

Source

pub fn gelu_approx(&self) -> Self

GELU, tanh approximation.

Source

pub fn silu(&self) -> Self

Sigmoid-weighted linear unit x · σ(x) (a.k.a. SwiGLU gate).

Source

pub fn tanh(&self) -> Self

Hyperbolic tangent.

Source

pub fn exp(&self) -> Self

Natural exponential e^x.

Source

pub fn sqrt(&self) -> Self

Square root.

Source

pub fn sigmoid(&self) -> Self

Logistic sigmoid 1 / (1 + e^-x).

Source

pub fn log(&self) -> Self

Natural logarithm.

Source

pub fn rsqrt(&self) -> Self

Reciprocal square root 1 / sqrt(x).

Source

pub fn abs(&self) -> Self

Absolute value.

Source

pub fn sin(&self) -> Self

Sine.

Source

pub fn cos(&self) -> Self

Cosine.

Source

pub fn tan(&self) -> Self

Tangent.

Source

pub fn atan(&self) -> Self

Arctangent.

Source

pub fn round(&self) -> Self

Round to nearest (half-to-even); straight-through gradient.

Source§

impl Tensor

Source

pub fn eq(&self, rhs: &Tensor) -> Self

Elementwise ==.

Source

pub fn ne(&self, rhs: &Tensor) -> Self

Elementwise !=.

Source

pub fn lt(&self, rhs: &Tensor) -> Self

Elementwise <.

Source

pub fn le(&self, rhs: &Tensor) -> Self

Elementwise <=.

Source

pub fn gt(&self, rhs: &Tensor) -> Self

Elementwise >.

Source

pub fn ge(&self, rhs: &Tensor) -> Self

Elementwise >=.

Source§

impl Tensor

Source

pub fn sum(&self, axes: impl Into<Vec<usize>>, keep_dim: bool) -> Self

Sum over axes.

Source

pub fn mean(&self, axes: impl Into<Vec<usize>>, keep_dim: bool) -> Self

Mean over axes.

Source

pub fn max(&self, axes: impl Into<Vec<usize>>, keep_dim: bool) -> Self

Maximum over axes.

Source

pub fn min(&self, axes: impl Into<Vec<usize>>, keep_dim: bool) -> Self

Minimum over axes.

Source

pub fn prod(&self, axes: impl Into<Vec<usize>>, keep_dim: bool) -> Self

Product over axes.

Trait Implementations§

Source§

impl Add for Tensor

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<&Tensor> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Tensor) -> Tensor

Performs the + operation. Read more
Source§

impl Add<&Tensor> for Tensor

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Tensor) -> Tensor

Performs the + operation. Read more
Source§

impl Add<&Tensor> for f64

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Tensor) -> Tensor

Performs the + operation. Read more
Source§

impl Add<&Tensor> for f32

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Tensor) -> Tensor

Performs the + operation. Read more
Source§

impl Add<&Tensor> for i32

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Tensor) -> Tensor

Performs the + operation. Read more
Source§

impl Add<Tensor> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<f32> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f32) -> Tensor

Performs the + operation. Read more
Source§

impl Add<f32> for Tensor

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f32) -> Tensor

Performs the + operation. Read more
Source§

impl Add<f64> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f64) -> Tensor

Performs the + operation. Read more
Source§

impl Add<f64> for Tensor

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f64) -> Tensor

Performs the + operation. Read more
Source§

impl Add<i32> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

fn add(self, rhs: i32) -> Tensor

Performs the + operation. Read more
Source§

impl Add<i32> for Tensor

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

fn add(self, rhs: i32) -> Tensor

Performs the + operation. Read more
Source§

impl Clone for Tensor

Source§

fn clone(&self) -> Tensor

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 Debug for Tensor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Div for Tensor

Source§

type Output = Tensor

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Tensor) -> Tensor

Performs the / operation. Read more
Source§

impl Div<&Tensor> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Tensor) -> Tensor

Performs the / operation. Read more
Source§

impl Div<&Tensor> for Tensor

Source§

type Output = Tensor

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Tensor) -> Tensor

Performs the / operation. Read more
Source§

impl Div<&Tensor> for f64

Source§

type Output = Tensor

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Tensor) -> Tensor

Performs the / operation. Read more
Source§

impl Div<&Tensor> for f32

Source§

type Output = Tensor

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Tensor) -> Tensor

Performs the / operation. Read more
Source§

impl Div<&Tensor> for i32

Source§

type Output = Tensor

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Tensor) -> Tensor

Performs the / operation. Read more
Source§

impl Div<Tensor> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Tensor) -> Tensor

Performs the / operation. Read more
Source§

impl Div<f32> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f32) -> Tensor

Performs the / operation. Read more
Source§

impl Div<f32> for Tensor

Source§

type Output = Tensor

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f32) -> Tensor

Performs the / operation. Read more
Source§

impl Div<f64> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Tensor

Performs the / operation. Read more
Source§

impl Div<f64> for Tensor

Source§

type Output = Tensor

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Tensor

Performs the / operation. Read more
Source§

impl Div<i32> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i32) -> Tensor

Performs the / operation. Read more
Source§

impl Div<i32> for Tensor

Source§

type Output = Tensor

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i32) -> Tensor

Performs the / operation. Read more
Source§

impl From<&Tensor> for NodeId

Source§

fn from(v: &Tensor) -> Self

Converts to this type from the input type.
Source§

impl From<Tensor> for NodeId

Source§

fn from(v: Tensor) -> Self

Converts to this type from the input type.
Source§

impl Mul for Tensor

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<&Tensor> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Tensor) -> Tensor

Performs the * operation. Read more
Source§

impl Mul<&Tensor> for Tensor

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Tensor) -> Tensor

Performs the * operation. Read more
Source§

impl Mul<&Tensor> for f64

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Tensor) -> Tensor

Performs the * operation. Read more
Source§

impl Mul<&Tensor> for f32

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Tensor) -> Tensor

Performs the * operation. Read more
Source§

impl Mul<&Tensor> for i32

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Tensor) -> Tensor

Performs the * operation. Read more
Source§

impl Mul<Tensor> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<f32> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> Tensor

Performs the * operation. Read more
Source§

impl Mul<f32> for Tensor

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> Tensor

Performs the * operation. Read more
Source§

impl Mul<f64> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Tensor

Performs the * operation. Read more
Source§

impl Mul<f64> for Tensor

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Tensor

Performs the * operation. Read more
Source§

impl Mul<i32> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i32) -> Tensor

Performs the * operation. Read more
Source§

impl Mul<i32> for Tensor

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i32) -> Tensor

Performs the * operation. Read more
Source§

impl Neg for &Tensor

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

fn neg(self) -> Tensor

Performs the unary - operation. Read more
Source§

impl Neg for Tensor

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

fn neg(self) -> Tensor

Performs the unary - operation. Read more
Source§

impl Sub for Tensor

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub<&Tensor> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Tensor) -> Tensor

Performs the - operation. Read more
Source§

impl Sub<&Tensor> for Tensor

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Tensor) -> Tensor

Performs the - operation. Read more
Source§

impl Sub<&Tensor> for f64

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Tensor) -> Tensor

Performs the - operation. Read more
Source§

impl Sub<&Tensor> for f32

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Tensor) -> Tensor

Performs the - operation. Read more
Source§

impl Sub<&Tensor> for i32

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Tensor) -> Tensor

Performs the - operation. Read more
Source§

impl Sub<Tensor> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub<f32> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f32) -> Tensor

Performs the - operation. Read more
Source§

impl Sub<f32> for Tensor

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f32) -> Tensor

Performs the - operation. Read more
Source§

impl Sub<f64> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f64) -> Tensor

Performs the - operation. Read more
Source§

impl Sub<f64> for Tensor

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f64) -> Tensor

Performs the - operation. Read more
Source§

impl Sub<i32> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: i32) -> Tensor

Performs the - operation. Read more
Source§

impl Sub<i32> for Tensor

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: i32) -> Tensor

Performs the - operation. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Tensor

§

impl !Send for Tensor

§

impl !Sync for Tensor

§

impl !UnwindSafe for Tensor

§

impl Freeze for Tensor

§

impl Unpin for Tensor

§

impl UnsafeUnpin for Tensor

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.