Skip to main content

Tensor

Struct Tensor 

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

A compact, contiguous multi-dtype tensor representation.

Default dtype is F32. FP16 and BF16 dtypes are stored natively as u16 bit patterns and can be created via from_f16 / from_bf16 or converted via to_dtype.

Implementations§

Source§

impl Tensor

Source

pub fn trace(&self) -> Result<f32, TensorError>

Sum of diagonal elements of a 2D square matrix.

Source

pub fn dot(&self, rhs: &Self) -> Result<f32, TensorError>

Dot product of two 1D tensors.

Source

pub fn cross(&self, rhs: &Self) -> Result<Self, TensorError>

Cross product of two 3-element 1D tensors.

Source

pub fn norm(&self, p: f32) -> f32

Lp norm of all elements. p=1 for L1, p=2 for L2.

Source

pub fn det(&self) -> Result<f32, TensorError>

Determinant of a square matrix (LU-based).

Source

pub fn inv(&self) -> Result<Self, TensorError>

Inverse of a square matrix (Gauss-Jordan elimination).

Source

pub fn solve(&self, b: &Self) -> Result<Self, TensorError>

Solve linear system Ax = b. self is A, rhs is b.

Source

pub fn qr(&self) -> Result<(Self, Self), TensorError>

QR decomposition via Householder reflections. Returns (Q, R).

Source

pub fn cholesky(&self) -> Result<Self, TensorError>

Cholesky decomposition of a symmetric positive-definite matrix. Returns lower triangular L.

Source§

impl Tensor

Source

pub fn add(&self, rhs: &Self) -> Result<Self, TensorError>

Element-wise addition with NumPy-style broadcasting.

Source

pub fn sub(&self, rhs: &Self) -> Result<Self, TensorError>

Element-wise subtraction with NumPy-style broadcasting.

Source

pub fn mul(&self, rhs: &Self) -> Result<Self, TensorError>

Element-wise multiplication with NumPy-style broadcasting.

Source

pub fn div(&self, rhs: &Self) -> Result<Self, TensorError>

Element-wise division with NumPy-style broadcasting.

Source

pub fn pow(&self, rhs: &Self) -> Result<Self, TensorError>

Element-wise power with NumPy-style broadcasting.

Fast paths:

  • Constant exponent 2.0 → mul(x, x) (SIMD-accelerated).
  • Constant exponent 0.5 → sqrt(x) (SIMD-accelerated).
  • Same-shape general case → SIMD exp(exp * ln(base)).
Source

pub fn atan2(&self, rhs: &Self) -> Result<Self, TensorError>

Element-wise atan2(self, other), with broadcasting.

Same-shape case uses a SIMD-friendly polynomial approximation of atan with quadrant correction, avoiding scalar f32::atan2.

Source

pub fn minimum(&self, rhs: &Self) -> Result<Self, TensorError>

Element-wise minimum with NumPy-style broadcasting.

Source

pub fn maximum(&self, rhs: &Self) -> Result<Self, TensorError>

Element-wise maximum with NumPy-style broadcasting.

Source

pub fn neg(&self) -> Self

Element-wise negation.

Source

pub fn abs(&self) -> Self

Element-wise absolute value.

Source

pub fn exp(&self) -> Self

Element-wise natural exponential.

Source

pub fn ln(&self) -> Self

Element-wise natural logarithm.

Source

pub fn sqrt(&self) -> Self

Element-wise square root.

Source

pub fn reciprocal(&self) -> Self

Element-wise reciprocal (1 / x).

Source

pub fn sign(&self) -> Self

Element-wise sign (-1, 0, or 1).

Source

pub fn floor(&self) -> Self

Element-wise floor.

Source

pub fn ceil(&self) -> Self

Element-wise ceil.

Source

pub fn round(&self) -> Self

Element-wise round.

Source

pub fn sin(&self) -> Self

Element-wise sine (SIMD-accelerated polynomial approximation).

Source

pub fn cos(&self) -> Self

Element-wise cosine (SIMD-accelerated polynomial approximation).

Source

pub fn tan(&self) -> Self

Element-wise tangent (SIMD-accelerated via sin/cos).

Source

pub fn asin(&self) -> Self

Element-wise arcsine.

Source

pub fn acos(&self) -> Self

Element-wise arccosine.

Source

pub fn atan(&self) -> Self

Element-wise arctangent.

Source

pub fn sinh(&self) -> Self

Element-wise hyperbolic sine.

Source

pub fn cosh(&self) -> Self

Element-wise hyperbolic cosine.

Source

pub fn log2(&self) -> Self

Element-wise base-2 logarithm.

Source

pub fn log10(&self) -> Self

Element-wise base-10 logarithm.

Source

pub fn degrees(&self) -> Self

Convert radians to degrees.

Source

pub fn radians(&self) -> Self

Convert degrees to radians.

Source

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

Clamp all elements to [min, max].

Source

pub fn scale(&self, factor: f32) -> Self

Scalar multiplication (broadcast multiply by a constant).

Source

pub fn add_scalar(&self, value: f32) -> Self

Add a scalar to all elements.

Source

pub fn sum(&self) -> f32

Sum reduction over all elements.

Source

pub fn mean(&self) -> f32

Mean reduction over all elements.

Source

pub fn max_value(&self) -> f32

Global max reduction. Returns f32::NEG_INFINITY for empty tensors.

Source

pub fn min_value(&self) -> f32

Global min reduction. Returns f32::INFINITY for empty tensors.

Source

pub fn argmax(&self) -> Option<usize>

Global argmax (flat index of maximum value).

Source

pub fn argmin(&self) -> Option<usize>

Global argmin (flat index of minimum value).

Source

pub fn var(&self) -> f32

Variance over all elements (population variance).

Source

pub fn std_dev(&self) -> f32

Standard deviation over all elements (population).

Source

pub fn sum_axis(&self, axis: usize) -> Result<Self, TensorError>

Sum reduction over one axis. Reduced axis is removed from output shape.

Source

pub fn mean_axis(&self, axis: usize) -> Result<Self, TensorError>

Mean reduction over one axis. Reduced axis is removed from output shape.

Source

pub fn max_axis(&self, axis: usize) -> Result<Self, TensorError>

Max reduction over one axis. Reduced axis is removed from output shape.

Source

pub fn min_axis(&self, axis: usize) -> Result<Self, TensorError>

Min reduction over one axis. Reduced axis is removed from output shape.

Source

pub fn var_axis(&self, axis: usize) -> Result<Self, TensorError>

Variance reduction over one axis (population variance).

Source

pub fn median(&self) -> f32

Global median of all elements.

Source

pub fn median_axis(&self, axis: usize) -> Result<Self, TensorError>

Median along a given axis.

Source

pub fn any(&self) -> bool

Returns true if any element is non-zero.

Source

pub fn all(&self) -> bool

Returns true if all elements are non-zero.

Source

pub fn quantile(&self, q: f32) -> f32

Quantile of all elements. q must be in [0, 1].

Source

pub fn transpose_2d(&self) -> Result<Self, TensorError>

2D matrix transpose. Requires rank-2 input.

§Safety

AlignedVec::uninitialized allocates without zeroing. The tiled loop writes every element before anything reads from the buffer.

Source

pub fn permute(&self, axes: &[usize]) -> Result<Self, TensorError>

General axis permutation (like NumPy transpose/permute).

Source

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

Insert a length-1 dimension at the given axis.

Source

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

Remove a length-1 dimension at the given axis.

Source

pub fn cat(tensors: &[&Self], axis: usize) -> Result<Self, TensorError>

Concatenate tensors along an axis. All tensors must have the same shape except along the concatenation axis.

Source

pub fn stack(tensors: &[&Self], axis: usize) -> Result<Self, TensorError>

Stack tensors along a new axis. All tensors must have identical shapes.

Source

pub fn select(&self, axis: usize, index: usize) -> Result<Self, TensorError>

Select a single slice along an axis, removing that axis from the output.

Source

pub fn narrow( &self, axis: usize, start: usize, length: usize, ) -> Result<Self, TensorError>

Narrow (slice) along an axis: extract elements start..start+length.

Source

pub fn eq_tensor(&self, rhs: &Self) -> Result<Self, TensorError>

Element-wise equality check: 1.0 where equal, 0.0 otherwise.

Source

pub fn gt_tensor(&self, rhs: &Self) -> Result<Self, TensorError>

Element-wise greater-than: 1.0 where self > rhs, 0.0 otherwise.

Source

pub fn lt_tensor(&self, rhs: &Self) -> Result<Self, TensorError>

Element-wise less-than: 1.0 where self < rhs, 0.0 otherwise.

Source

pub fn gt_tensor_into(&self, rhs: &Self, output: &mut Self)

Element-wise greater-than writing into a pre-allocated output tensor. self, rhs, and output must all have the same shape.

Source

pub fn eq_tensor_into(&self, rhs: &Self, output: &mut Self)

Element-wise equality check writing into a pre-allocated output tensor. self, rhs, and output must all have the same shape.

Source

pub fn lt_tensor_into(&self, rhs: &Self, output: &mut Self)

Element-wise less-than writing into a pre-allocated output tensor. self, rhs, and output must all have the same shape.

Source

pub fn ne_tensor(&self, rhs: &Self) -> Result<Self, TensorError>

Element-wise not-equal: 1.0 where not equal (diff.abs() >= 1e-7), 0.0 otherwise.

Source

pub fn le_tensor(&self, rhs: &Self) -> Result<Self, TensorError>

Element-wise less-than-or-equal: 1.0 where self <= rhs, 0.0 otherwise.

Source

pub fn ge_tensor(&self, rhs: &Self) -> Result<Self, TensorError>

Element-wise greater-than-or-equal: 1.0 where self >= rhs, 0.0 otherwise.

Source

pub fn all_finite(&self) -> bool

Returns true if all elements are finite (no NaN or Inf).

Source

pub fn where_cond( &self, condition: &Self, other: &Self, ) -> Result<Self, TensorError>

Element-wise where: condition ? self : other. condition has 1.0 for true, 0.0 for false.

Source

pub fn masked_fill(&self, mask: &Self, value: f32) -> Result<Self, TensorError>

Replace elements where mask != 0 with value.

Source

pub fn scatter( &self, axis: usize, index: &Self, src: &Self, ) -> Result<Self, TensorError>

Scatter values into self along axis at positions given by index. src provides the values. index has same shape as src.

Source

pub fn gather(&self, axis: usize, index: &Self) -> Result<Self, TensorError>

Gather elements along axis at positions given by index.

Source

pub fn topk(&self, k: usize) -> Result<(Self, Self), TensorError>

Returns the top-k values and their indices along the last axis.

Source

pub fn triu(&self, diagonal: i64) -> Result<Self, TensorError>

Upper triangular mask: zero below diagonal, keep above. diagonal shifts: 0 = main, positive = above, negative = below.

Source

pub fn tril(&self, diagonal: i64) -> Result<Self, TensorError>

Lower triangular mask: zero above diagonal, keep below.

Source

pub fn eye(n: usize) -> Result<Self, TensorError>

Identity matrix [n, n].

Source

pub fn diag(vector: &Tensor) -> Result<Self, TensorError>

Create a diagonal matrix from a 1D vector.

Source

pub fn diag_extract(&self) -> Result<Self, TensorError>

Extract the diagonal of a 2D matrix as a 1D vector.

Source

pub fn pad( &self, padding: &[(usize, usize)], value: f32, ) -> Result<Self, TensorError>

Pad the tensor with a constant value. padding is a slice of (before, after) per dimension.

Source

pub fn repeat(&self, counts: &[usize]) -> Result<Self, TensorError>

Repeat tensor along each axis by the given counts.

Source

pub fn cumsum(&self, axis: usize) -> Result<Self, TensorError>

Cumulative sum along an axis.

Source

pub fn cumprod(&self, axis: usize) -> Result<Self, TensorError>

Cumulative product along an axis.

Source

pub fn to_fp16(&self) -> Vec<u16>

Convert all elements to IEEE 754 half-precision (FP16) bytes. Returns Vec<u16> where each u16 is an FP16 bit pattern.

Source

pub fn from_fp16( shape: Vec<usize>, fp16_data: &[u16], ) -> Result<Self, TensorError>

Create a tensor from FP16 bit patterns.

Source

pub fn relu_inplace(&mut self)

In-place ReLU: clamp negative values to zero.

Source

pub fn add_inplace(&mut self, rhs: &Self)

In-place element-wise add from another tensor (must have same shape).

Source

pub fn add_scalar_inplace(&mut self, s: f32)

In-place add scalar to all elements.

Source

pub fn mul_scalar_inplace(&mut self, s: f32)

In-place multiply all elements by scalar.

Source

pub fn add_into(output: &mut Self, lhs: &Self, rhs: &Self)

Element-wise addition writing into a pre-allocated output tensor. output, lhs, and rhs must all have the same shape.

Source

pub fn sub_into(output: &mut Self, lhs: &Self, rhs: &Self)

Element-wise subtraction writing into a pre-allocated output tensor. output, lhs, and rhs must all have the same shape.

Source

pub fn mul_into(output: &mut Self, lhs: &Self, rhs: &Self)

Element-wise multiplication writing into a pre-allocated output tensor. output, lhs, and rhs must all have the same shape.

Source§

impl Tensor

Source

pub fn sort( &self, dim: usize, descending: bool, ) -> Result<(Self, Self), TensorError>

Sort along dim. Returns (sorted_values, sorted_indices).

If descending is true, values are sorted largest-first.

Source

pub fn argsort(&self, dim: usize, descending: bool) -> Result<Self, TensorError>

Return indices that would sort along dim.

Source

pub fn unique(&self) -> (Self, Self, Self)

Return unique elements (sorted), inverse indices, and counts.

Source

pub fn nonzero(&self) -> Self

Return coordinates of nonzero elements as a 2D tensor [N, rank].

Source

pub fn flip(&self, dims: &[usize]) -> Result<Self, TensorError>

Reverse elements along the given dimensions.

Source

pub fn roll(&self, shift: i64, dim: usize) -> Result<Self, TensorError>

Circular shift elements along dim by shift positions.

Source

pub fn linspace(start: f32, end: f32, steps: usize) -> Result<Self, TensorError>

Create a 1-D tensor of steps evenly spaced values from start to end (inclusive).

Source

pub fn arange(start: f32, end: f32, step: f32) -> Result<Self, TensorError>

Create a 1-D tensor with values in [start, end) with given step.

Source

pub fn meshgrid(tensors: &[Self]) -> Result<Vec<Self>, TensorError>

Create coordinate grids from 1-D tensors (numpy-style meshgrid with indexing='ij').

Source

pub fn boolean_mask(&self, mask: &Self) -> Result<Self, TensorError>

Select elements where mask (f32, nonzero = true) is true, returned as 1-D.

Source

pub fn index_select( &self, dim: usize, indices: &Self, ) -> Result<Self, TensorError>

Select slices along dim using integer indices tensor (1-D).

Source

pub fn rand(shape: Vec<usize>, seed: u64) -> Result<Self, TensorError>

Create a tensor filled with uniform random values in [0, 1).

Source

pub fn randn(shape: Vec<usize>, seed: u64) -> Result<Self, TensorError>

Create a tensor filled with normally distributed random values (mean=0, std=1). Uses Box-Muller transform.

Source

pub fn randint( shape: Vec<usize>, low: i64, high: i64, seed: u64, ) -> Result<Self, TensorError>

Create a tensor filled with random integers in [low, high).

Source

pub fn randperm(n: usize, seed: u64) -> Result<Self, TensorError>

Create a random permutation of integers [0, n).

Source§

impl Tensor

Source

pub fn step_slice( &self, dim: usize, start: usize, end: usize, step: usize, ) -> Result<Self, TensorError>

Slice with step: extract every step-th element along dim from start to end.

Source

pub fn einsum( equation: &str, tensors: &[&Tensor], ) -> Result<Tensor, TensorError>

Einstein summation for common patterns.

Supported equations:

  • "ij,jk->ik" — matrix multiply
  • "ij->ji" — transpose
  • "ii->i" — diagonal
  • "ij->i" — row sum
  • "ij->j" — column sum
  • "ij->" — total sum
  • "i,i->" — dot product
  • "ij,ij->" — Frobenius inner product
Source

pub fn chunk( &self, n_chunks: usize, axis: usize, ) -> Result<Vec<Self>, TensorError>

Split tensor into n_chunks pieces along axis. Last chunk may be smaller.

Source

pub fn histogram( &self, bins: usize, min: f32, max: f32, ) -> Result<Self, TensorError>

Counts elements in each bin, returns 1D tensor of shape [bins]. Bins are evenly spaced between min and max.

Source

pub fn bincount(&self, num_bins: usize) -> Result<Self, TensorError>

Treats values as integer indices, counts occurrences. Returns 1D tensor of shape [num_bins].

Source

pub fn item(&self) -> Result<f32, TensorError>

Returns the single scalar value if tensor has exactly one element. Errors if tensor has more than one element.

Source

pub fn is_scalar(&self) -> bool

Returns true if tensor has exactly one element.

Source

pub fn scatter_add( &self, dim: usize, index: &Self, src: &Self, ) -> Result<Self, TensorError>

Like scatter but adds instead of replacing values.

For dim=1: self[i][index[i][j][k]][k] += src[i][j][k]

Source§

impl Tensor

Source

pub fn scalar(value: f32) -> Self

Builds a scalar tensor from one value.

Source

pub fn from_raw_parts( shape: &[usize], strides: &[usize], data: AlignedVec<f32>, ) -> Self

Creates a tensor from pre-validated shape, strides, and data. No validation, no heap allocation (shape/strides stored inline for ≤6D).

Source

pub fn from_aligned( shape: Vec<usize>, data: AlignedVec<f32>, ) -> Result<Self, TensorError>

Builds a tensor from shape and a pre-filled AlignedVec.

This avoids the extra copy that from_vec performs when converting a Vec<f32> into aligned storage. Use this when the output buffer was already allocated as an AlignedVec (e.g. via AlignedVec::uninitialized filled by a BLAS/SIMD kernel).

Source

pub fn from_vec(shape: Vec<usize>, data: Vec<f32>) -> Result<Self, TensorError>

Builds a tensor from shape and raw contiguous f32 data.

Source

pub fn from_f16(shape: Vec<usize>, data: Vec<u16>) -> Result<Self, TensorError>

Builds a tensor from shape and raw FP16 bit patterns (u16).

Source

pub fn from_bf16(shape: Vec<usize>, data: Vec<u16>) -> Result<Self, TensorError>

Builds a tensor from shape and raw BF16 bit patterns (u16).

Source

pub fn from_slice(data: &[f32]) -> Self

Builds a 1-D tensor from a slice. Equivalent to from_vec(vec![data.len()], data.to_vec()).

Source

pub fn filled(shape: Vec<usize>, value: f32) -> Result<Self, TensorError>

Builds a value-initialized tensor for a given shape.

Alias: full is provided as a more familiar name.

Source

pub fn zeros(shape: Vec<usize>) -> Result<Self, TensorError>

Builds a zero-initialized tensor for a given shape.

Uses alloc_zeroed under the hood so the OS can provide pre-zeroed pages without writing every byte — significantly faster for large tensors.

Source

pub fn ones(shape: Vec<usize>) -> Result<Self, TensorError>

Builds a one-initialized tensor for a given shape.

Source

pub fn full(shape: Vec<usize>, value: f32) -> Result<Self, TensorError>

Builds a tensor filled with value. Alias for filled.

Source

pub fn shape(&self) -> &[usize]

Returns the tensor shape.

Source

pub fn strides(&self) -> &[usize]

Returns the tensor strides.

Source

pub fn rank(&self) -> usize

Returns tensor rank (number of axes).

Source

pub fn len(&self) -> usize

Returns element count.

Source

pub fn is_empty(&self) -> bool

Returns true if tensor contains zero elements.

Source

pub fn dtype(&self) -> DType

Returns the element data type.

Source

pub fn device(&self) -> Device

Returns the logical device this tensor is associated with.

Source

pub fn to_device(&self, device: Device) -> Self

Returns a copy of this tensor tagged with the given device.

This is currently a metadata-only operation — no actual data transfer occurs. GPU data movement is handled by GpuSession in yscv-kernels.

Source

pub fn is_f32(&self) -> bool

Returns true if the tensor stores f32 data.

Source

pub fn try_data(&self) -> Result<&[f32], TensorError>

Fallible version of data() — returns an error for non-F32 tensors.

Source

pub fn try_data_mut(&mut self) -> Result<&mut [f32], TensorError>

Fallible version of data_mut() — returns an error for non-F32 tensors.

Source

pub fn data(&self) -> &[f32]

Returns an immutable view over contiguous f32 storage.

§Panics

Panics if the tensor dtype is not F32. Use try_data() for a fallible version.

Source

pub fn data_mut(&mut self) -> &mut [f32]

Returns a mutable view over contiguous f32 storage.

§Panics

Panics if the tensor dtype is not F32. Use try_data_mut() for a fallible version.

Source

pub fn try_data_f32(&self) -> Result<&[f32], TensorError>

Alias for try_data() for backward compatibility.

Source

pub fn data_f16(&self) -> Result<&[u16], TensorError>

Returns raw FP16 bit-pattern data if dtype is F16.

Source

pub fn data_bf16(&self) -> Result<&[u16], TensorError>

Returns raw BF16 bit-pattern data if dtype is BF16.

Source

pub fn to_dtype(&self, target: DType) -> Self

Converts this tensor to the specified dtype, returning a new tensor. Converting to the same dtype is a no-op clone.

Source

pub fn get(&self, indices: &[usize]) -> Result<f32, TensorError>

Reads one element by multi-dimensional index (always returns f32).

Source

pub fn set(&mut self, indices: &[usize], value: f32) -> Result<(), TensorError>

Writes one element by multi-dimensional index (stores as native dtype).

Source

pub fn reshape(&self, new_shape: Vec<usize>) -> Result<Self, TensorError>

Returns a reshaped tensor view with copied metadata and data.

Source

pub fn into_reshape(self, new_shape: Vec<usize>) -> Result<Self, TensorError>

Consumes the tensor and returns a reshaped version without copying data.

Trait Implementations§

Source§

impl Add for &Tensor

Source§

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

Element-wise addition. Panics on shape mismatch.

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

impl Add for Tensor

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> 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 · 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 Display 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: Self) -> Tensor

Performs the / operation. Read more
Source§

impl Div for Tensor

Source§

type Output = Tensor

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Mul<f32> for &Tensor

Source§

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

Scalar multiplication.

Source§

type Output = Tensor

The resulting type after applying the * operator.
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 for &Tensor

Source§

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

Element-wise multiplication. Panics on shape mismatch.

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

impl Mul for Tensor

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> 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 PartialEq for Tensor

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Sub for &Tensor

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub for Tensor

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl StructuralPartialEq for Tensor

Auto Trait Implementations§

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.