pub enum Tensor {
F32(TypedTensor<f32>),
F64(TypedTensor<f64>),
I32(TypedTensor<i32>),
I64(TypedTensor<i64>),
Bool(TypedTensor<bool>),
C32(TypedTensor<Complex<f32>>),
C64(TypedTensor<Complex<f64>>),
}Expand description
Dynamic tensor enum over the supported scalar types.
The enum keeps dtype dynamic and rank dynamic. Use
TypedTensor<T, R> directly when the scalar type or rank
should be represented in Rust’s type system.
§Examples
use tenferro_tensor::{Tensor, TypedTensor};
let t = Tensor::F64(TypedTensor::from_vec_col_major(vec![2], vec![1.0, 2.0]).unwrap());
assert_eq!(t.shape(), &[2]);
let erased = Tensor::from_vec_col_major(vec![1, 2], vec![1.0_f64, 2.0]).unwrap();
assert_eq!(erased.shape().len(), 2);Variants§
F32(TypedTensor<f32>)
F64(TypedTensor<f64>)
I32(TypedTensor<i32>)
I64(TypedTensor<i64>)
Bool(TypedTensor<bool>)
C32(TypedTensor<Complex<f32>>)
C64(TypedTensor<Complex<f64>>)
Implementations§
Source§impl Tensor
impl Tensor
Sourcepub fn linear_offset(&self, indices: &[usize]) -> Result<usize, Error>
pub fn linear_offset(&self, indices: &[usize]) -> Result<usize, Error>
Compute the linear physical-buffer offset for a logical index.
§Examples
use tenferro_tensor::Tensor;
let t = Tensor::from_vec_col_major(vec![2, 3], vec![0.0_f64; 6]).unwrap();
assert_eq!(t.linear_offset(&[1, 2])?, 5);§Errors
Returns crate::Error::Validation containing
tenferro_tensor_core::ValidationError::RankMismatch when indices
has a rank different from the tensor, tenferro_tensor_core::ValidationError::InvalidArgument
when an index is outside its axis extent, or
tenferro_tensor_core::ValidationError::IntegerOverflow when checked
offset arithmetic overflows.
Sourcepub fn linear_offset2(&self, i: usize, j: usize) -> Result<usize, Error>
pub fn linear_offset2(&self, i: usize, j: usize) -> Result<usize, Error>
Compute the linear physical-buffer offset for a rank-2 logical index.
§Examples
use tenferro_tensor::Tensor;
let t = Tensor::from_vec_col_major(vec![2, 3], vec![0.0_f64; 6]).unwrap();
assert_eq!(t.linear_offset2(1, 2)?, 5);§Errors
Returns crate::Error::Validation containing
tenferro_tensor_core::ValidationError::RankMismatch when the tensor
rank is not two, tenferro_tensor_core::ValidationError::InvalidArgument
when i or j is outside its axis extent, or
tenferro_tensor_core::ValidationError::IntegerOverflow when checked
offset arithmetic overflows.
Sourcepub fn linear_offset3(
&self,
i: usize,
j: usize,
k: usize,
) -> Result<usize, Error>
pub fn linear_offset3( &self, i: usize, j: usize, k: usize, ) -> Result<usize, Error>
Compute the linear physical-buffer offset for a rank-3 logical index.
§Examples
use tenferro_tensor::Tensor;
let t = Tensor::from_vec_col_major(vec![2, 3, 2], vec![0.0_f64; 12]).unwrap();
assert_eq!(t.linear_offset3(1, 2, 1)?, 11);§Errors
Returns crate::Error::Validation containing
tenferro_tensor_core::ValidationError::RankMismatch when the tensor
rank is not three, tenferro_tensor_core::ValidationError::InvalidArgument
when i, j, or k is outside its axis extent, or
tenferro_tensor_core::ValidationError::IntegerOverflow when checked
offset arithmetic overflows.
Sourcepub fn get<T>(&self, indices: &[usize]) -> Result<&T, Error>where
T: TensorScalar,
pub fn get<T>(&self, indices: &[usize]) -> Result<&T, Error>where
T: TensorScalar,
Borrow a single typed element by multi-index.
§Examples
use tenferro_tensor::Tensor;
let t = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap();
assert_eq!(t.get::<f64>(&[1])?, &2.0);
assert!(t.get::<f32>(&[1]).is_err());§Errors
Returns crate::Error::Validation containing
tenferro_tensor_core::ValidationError::RankMismatch or
tenferro_tensor_core::ValidationError::InvalidArgument for an
invalid index, tenferro_tensor_core::ValidationError::DTypeMismatch
when T does not match the tensor dtype, or
crate::Error::RuntimeState for a device-backed tensor.
Sourcepub fn get_mut<T>(&mut self, indices: &[usize]) -> Result<&mut T, Error>where
T: TensorScalar,
pub fn get_mut<T>(&mut self, indices: &[usize]) -> Result<&mut T, Error>where
T: TensorScalar,
Mutably borrow a single typed element by multi-index.
§Examples
use tenferro_tensor::Tensor;
let mut t = Tensor::from_vec_col_major(vec![1], vec![1.0_f64]).unwrap();
*t.get_mut::<f64>(&[0])? = 2.0;
assert_eq!(t.as_slice::<f64>()?, &[2.0]);§Errors
Returns crate::Error::Validation containing
tenferro_tensor_core::ValidationError::RankMismatch or
tenferro_tensor_core::ValidationError::InvalidArgument for an
invalid index, tenferro_tensor_core::ValidationError::DTypeMismatch
when T does not match the tensor dtype, or
crate::Error::RuntimeState for a device-backed tensor.
Sourcepub unsafe fn get_unchecked<T>(&self, indices: &[usize]) -> Result<&T, Error>where
T: TensorScalar,
pub unsafe fn get_unchecked<T>(&self, indices: &[usize]) -> Result<&T, Error>where
T: TensorScalar,
Try to borrow a single typed element by multi-index without release-mode bounds checks.
Debug builds still validate the rank and bounds. Dtype and backend host-access failures are still reported as errors.
§Safety
indices must have the same rank as this tensor and every index must
be in bounds.
§Examples
use tenferro_tensor::Tensor;
let t = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap();
assert_eq!(unsafe { *t.get_unchecked::<f64>(&[1])? }, 2.0);§Errors
Returns crate::Error::RuntimeState for a device-backed tensor and
tenferro_tensor_core::ValidationError::DTypeMismatch when T does
not match the tensor dtype.
§Panics
May panic if the unsafe rank/bounds precondition is violated and the checked linear-offset calculation overflows.
Sourcepub unsafe fn get_unchecked_mut<T>(
&mut self,
indices: &[usize],
) -> Result<&mut T, Error>where
T: TensorScalar,
pub unsafe fn get_unchecked_mut<T>(
&mut self,
indices: &[usize],
) -> Result<&mut T, Error>where
T: TensorScalar,
Try to mutably borrow a single typed element by multi-index without release-mode bounds checks.
Debug builds still validate the rank and bounds. Dtype and backend host-access failures are still reported as errors.
§Safety
indices must have the same rank as this tensor and every index must
be in bounds.
§Examples
use tenferro_tensor::Tensor;
let mut t = Tensor::from_vec_col_major(vec![1], vec![1.0_f64]).unwrap();
unsafe {
*t.get_unchecked_mut::<f64>(&[0])? = 2.0;
}
assert_eq!(t.as_slice::<f64>()?, &[2.0]);§Errors
Returns crate::Error::RuntimeState for a device-backed tensor and
tenferro_tensor_core::ValidationError::DTypeMismatch when T does
not match the tensor dtype.
§Panics
May panic if the unsafe rank/bounds precondition is violated and the checked linear-offset calculation overflows.
Sourcepub fn as_slice_mut<T>(&mut self) -> Result<&mut [T], Error>where
T: TensorScalar,
pub fn as_slice_mut<T>(&mut self) -> Result<&mut [T], Error>where
T: TensorScalar,
Mutably borrow the host data as a typed slice.
§Examples
use tenferro_tensor::Tensor;
let mut t = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap();
t.as_slice_mut::<f64>()?[0] = 3.0;
assert_eq!(t.as_slice::<f64>()?, &[3.0, 2.0]);
assert!(t.as_slice_mut::<f32>().is_err());§Errors
Returns tenferro_tensor_core::ValidationError::DTypeMismatch when
T does not match the tensor dtype, or crate::Error::RuntimeState
when the tensor is backed by a device buffer.
Sourcepub fn iter<T>(&self) -> Result<Iter<'_, T>, Error>where
T: TensorScalar,
pub fn iter<T>(&self) -> Result<Iter<'_, T>, Error>where
T: TensorScalar,
Iterate over the contiguous host buffer in physical memory order.
§Examples
use tenferro_tensor::Tensor;
let t = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap();
let sum: f64 = t.iter::<f64>()?.copied().sum();
assert_eq!(sum, 3.0);
assert!(t.iter::<f32>().is_err());§Errors
Returns tenferro_tensor_core::ValidationError::DTypeMismatch when
T does not match the tensor dtype, or crate::Error::RuntimeState
when the tensor is backed by a device buffer.
Sourcepub fn iter_mut<T>(&mut self) -> Result<IterMut<'_, T>, Error>where
T: TensorScalar,
pub fn iter_mut<T>(&mut self) -> Result<IterMut<'_, T>, Error>where
T: TensorScalar,
Mutably iterate over the contiguous host buffer in physical memory order.
§Examples
use tenferro_tensor::Tensor;
let mut t = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap();
for value in t.iter_mut::<f64>()? {
*value += 1.0;
}
assert_eq!(t.as_slice::<f64>()?, &[2.0, 3.0]);
assert!(t.iter_mut::<f32>().is_err());§Errors
Returns tenferro_tensor_core::ValidationError::DTypeMismatch when
T does not match the tensor dtype, or crate::Error::RuntimeState
when the tensor is backed by a device buffer.
Source§impl Tensor
impl Tensor
Sourcepub fn index_select(
&self,
axis: isize,
positions: &[usize],
ctx: &mut impl TensorBackend,
) -> Result<Tensor, Error>
pub fn index_select( &self, axis: isize, positions: &[usize], ctx: &mut impl TensorBackend, ) -> Result<Tensor, Error>
Select entries from one axis using host-known positions.
§Examples
use tenferro_tensor::{Tensor, TensorBackend};
fn select_last_axis<B: TensorBackend>(
backend: &mut B,
x: &Tensor,
) -> tenferro_tensor::Result<Tensor> {
x.index_select(-1, &[2, 0], backend)
}§Errors
Returns crate::Error::Validation with a typed shape, axis, or argument
source when the inputs cannot be packed without violating their metadata.
Sourcepub fn stack(
tensors: &[&Tensor],
dim: isize,
ctx: &mut impl TensorBackend,
) -> Result<Tensor, Error>
pub fn stack( tensors: &[&Tensor], dim: isize, ctx: &mut impl TensorBackend, ) -> Result<Tensor, Error>
Stack tensors along a newly inserted axis.
§Examples
use tenferro_tensor::{Tensor, TensorBackend};
fn stack_scalars<B: TensorBackend>(
backend: &mut B,
a: &Tensor,
b: &Tensor,
) -> tenferro_tensor::Result<Tensor> {
Tensor::stack(&[a, b], -1, backend)
}§Errors
Returns crate::Error::Validation with a typed shape, axis, or argument
source when the inputs cannot be packed without violating their metadata.
Source§impl Tensor
impl Tensor
Sourcepub fn from_vec_col_major<T>(
shape: impl IntoShapeVec,
data: Vec<T>,
) -> Result<Tensor, Error>where
T: TensorScalar,
pub fn from_vec_col_major<T>(
shape: impl IntoShapeVec,
data: Vec<T>,
) -> Result<Tensor, Error>where
T: TensorScalar,
Create a tensor from a shape and column-major flat data.
This is the Tensor-level equivalent of
TypedTensor::<T>::from_vec_col_major.
§Examples
use tenferro_tensor::Tensor;
let t = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 3.0, 2.0, 4.0]).unwrap();
assert_eq!(t.shape(), &[2, 2]);
assert_eq!(t.as_slice::<f64>().unwrap(), &[1.0, 3.0, 2.0, 4.0]);§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::ShapeDataLengthMismatch when
the shape product differs from data.len(), or
tenferro_tensor_core::ValidationError::IntegerOverflow when shape
arithmetic overflows.
Sourcepub fn shape(&self) -> &[usize]
pub fn shape(&self) -> &[usize]
Tensor shape.
§Examples
use tenferro_tensor::{Tensor, TypedTensor};
let t = Tensor::F64(TypedTensor::from_vec_col_major(vec![2], vec![1.0, 2.0]).unwrap());
assert_eq!(t.shape(), &[2]);Sourcepub fn dtype(&self) -> DType
pub fn dtype(&self) -> DType
Tensor dtype tag.
§Examples
use tenferro_tensor::{DType, Tensor, TypedTensor};
let t = Tensor::F64(TypedTensor::from_vec_col_major(vec![], vec![1.0]).unwrap());
assert_eq!(t.dtype(), DType::F64);Sourcepub fn placement(&self) -> &Placement
pub fn placement(&self) -> &Placement
Return placement metadata for this dtype-erased tensor.
§Examples
use tenferro_tensor::{MemoryKind, Tensor};
let t = Tensor::from_vec_col_major(vec![1], vec![1.0_f64]).unwrap();
assert_eq!(t.placement().memory_kind, MemoryKind::UnpinnedHost);Sourcepub fn is_backend_buffer(&self) -> bool
pub fn is_backend_buffer(&self) -> bool
Return whether this tensor is backed by backend-native storage.
§Examples
use tenferro_tensor::Tensor;
let t = Tensor::from_vec_col_major(vec![1], vec![1.0_f64]).unwrap();
assert!(!t.is_backend_buffer());Sourcepub fn layout_linear_offset(&self, indices: &[usize]) -> Result<usize, Error>
pub fn layout_linear_offset(&self, indices: &[usize]) -> Result<usize, Error>
Compute the physical element offset for a logical index.
§Examples
use tenferro_tensor::Tensor;
let t = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0])?;
assert_eq!(t.layout_linear_offset(&[1])?, 1);§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::RankMismatch when indices
has the wrong rank, tenferro_tensor_core::ValidationError::InvalidArgument
when an index is outside its axis extent, or
tenferro_tensor_core::ValidationError::IntegerOverflow when offset
arithmetic overflows.
Sourcepub fn is_col_major_contiguous(&self) -> Result<bool, Error>
pub fn is_col_major_contiguous(&self) -> Result<bool, Error>
Return whether this tensor is compact column-major.
§Examples
use tenferro_tensor::Tensor;
let t = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0])?;
assert!(t.is_col_major_contiguous()?);§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::IntegerOverflow when
compactness arithmetic overflows.
Sourcepub fn layout_summary(&self) -> String
pub fn layout_summary(&self) -> String
Return a compact string summary of this tensor’s layout metadata.
§Examples
use tenferro_tensor::Tensor;
let t = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0])?;
assert!(t.layout_summary().contains("shape=[2]"));Sourcepub fn assert_col_major_contiguous(&self) -> Result<(), Error>
pub fn assert_col_major_contiguous(&self) -> Result<(), Error>
Assert this tensor is compact column-major.
§Examples
use tenferro_tensor::Tensor;
let t = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0])?;
t.assert_col_major_contiguous()?;§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::IntegerOverflow when
compactness arithmetic overflows, or
tenferro_tensor_core::ValidationError::InvalidArgument when the
tensor is not compact column-major.
Sourcepub fn as_slice<T>(&self) -> Result<&[T], Error>where
T: TensorScalar,
pub fn as_slice<T>(&self) -> Result<&[T], Error>where
T: TensorScalar,
Try to borrow the host data as a typed slice.
Returns an error if the tensor dtype does not match T.
§Examples
use tenferro_tensor::{Tensor, TypedTensor};
let t = Tensor::F64(TypedTensor::from_vec_col_major(vec![3], vec![1.0, 2.0, 3.0]).unwrap());
assert_eq!(t.as_slice::<f64>().unwrap(), [1.0, 2.0, 3.0].as_slice());
assert!(t.as_slice::<f32>().is_err());§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::DTypeMismatch when T does
not match the tensor dtype, or crate::Error::RuntimeState when the
matching tensor uses backend storage that has not been downloaded.
Sourcepub fn into_vec_col_major<T>(self) -> Result<(Vec<usize>, Vec<T>), Error>where
T: TensorScalar,
pub fn into_vec_col_major<T>(self) -> Result<(Vec<usize>, Vec<T>), Error>where
T: TensorScalar,
Consume this tensor and return its owned column-major buffer when the dtype matches.
§Examples
use tenferro_tensor::Tensor;
let t = Tensor::from_vec_col_major(vec![1], vec![2.0_f64]).unwrap();
assert_eq!(t.into_vec_col_major::<f64>().unwrap().1, vec![2.0]);§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::DTypeMismatch when T does
not match the tensor dtype, or crate::Error::RuntimeState when the
matching tensor uses backend storage that has not been downloaded.
Trait Implementations§
Source§impl From<TypedTensor<Complex<f32>>> for Tensor
Wrap a Complex32 TypedTensor into the corresponding Tensor
variant.
impl From<TypedTensor<Complex<f32>>> for Tensor
Wrap a Complex32 TypedTensor into the corresponding Tensor
variant.
§Examples
use num_complex::Complex32;
use tenferro_tensor::{Tensor, TypedTensor};
let typed = TypedTensor::from_vec_col_major(
vec![1],
vec![Complex32::new(1.0, 2.0)],
).unwrap();
let tensor: Tensor = typed.into();
assert_eq!(tensor.shape(), &[1]);Source§impl From<TypedTensor<Complex<f64>>> for Tensor
Wrap a Complex64 TypedTensor into the corresponding Tensor
variant.
impl From<TypedTensor<Complex<f64>>> for Tensor
Wrap a Complex64 TypedTensor into the corresponding Tensor
variant.
§Examples
use num_complex::Complex64;
use tenferro_tensor::{Tensor, TypedTensor};
let typed = TypedTensor::from_vec_col_major(
vec![1],
vec![Complex64::new(1.0, 2.0)],
).unwrap();
let tensor: Tensor = typed.into();
assert_eq!(tensor.shape(), &[1]);Source§impl From<TypedTensor<bool>> for Tensor
Wrap a bool TypedTensor into the corresponding Tensor variant.
impl From<TypedTensor<bool>> for Tensor
Wrap a bool TypedTensor into the corresponding Tensor variant.
§Examples
use tenferro_tensor::{DType, Tensor, TypedTensor};
let typed = TypedTensor::from_vec_col_major(vec![2], vec![true, false]).unwrap();
let tensor: Tensor = typed.into();
assert_eq!(tensor.dtype(), DType::Bool);
assert_eq!(tensor.shape(), &[2]);Source§impl From<TypedTensor<f32>> for Tensor
Wrap an f32 TypedTensor into the corresponding Tensor variant.
impl From<TypedTensor<f32>> for Tensor
Wrap an f32 TypedTensor into the corresponding Tensor variant.
§Examples
use tenferro_tensor::{Tensor, TypedTensor};
let typed = TypedTensor::from_vec_col_major(vec![2], vec![1.0_f32, 2.0]).unwrap();
let tensor: Tensor = typed.into();
assert_eq!(tensor.shape(), &[2]);Source§impl From<TypedTensor<f64>> for Tensor
Wrap an f64 TypedTensor into the corresponding Tensor variant.
impl From<TypedTensor<f64>> for Tensor
Wrap an f64 TypedTensor into the corresponding Tensor variant.
§Examples
use tenferro_tensor::{Tensor, TypedTensor};
let typed = TypedTensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap();
let tensor: Tensor = typed.into();
assert_eq!(tensor.shape(), &[2]);Source§impl From<TypedTensor<i32>> for Tensor
Wrap an i32 TypedTensor into the corresponding Tensor variant.
impl From<TypedTensor<i32>> for Tensor
Wrap an i32 TypedTensor into the corresponding Tensor variant.
§Examples
use tenferro_tensor::{DType, Tensor, TypedTensor};
let typed = TypedTensor::from_vec_col_major(vec![2], vec![1_i32, 2]).unwrap();
let tensor: Tensor = typed.into();
assert_eq!(tensor.dtype(), DType::I32);
assert_eq!(tensor.shape(), &[2]);Source§impl From<TypedTensor<i64>> for Tensor
Wrap an i64 TypedTensor into the corresponding Tensor variant.
impl From<TypedTensor<i64>> for Tensor
Wrap an i64 TypedTensor into the corresponding Tensor variant.
§Examples
use tenferro_tensor::{DType, Tensor, TypedTensor};
let typed = TypedTensor::from_vec_col_major(vec![2], vec![1_i64, 2]).unwrap();
let tensor: Tensor = typed.into();
assert_eq!(tensor.dtype(), DType::I64);
assert_eq!(tensor.shape(), &[2]);§impl TensorOpsExt for Tensor
impl TensorOpsExt for Tensor
§fn convert<B>(&self, to: DType, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn convert<B>(&self, to: DType, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn cast<B>(&self, to: DType, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn cast<B>(&self, to: DType, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn add<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn add<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn sub<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn sub<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn mul<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn mul<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn div<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn div<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn rem<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn rem<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn pow<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn pow<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn maximum<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn maximum<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn minimum<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn minimum<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn neg<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn neg<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn abs<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn abs<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn sign<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn sign<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn conj<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn conj<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn exp<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn exp<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn log<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn log<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn sin<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn sin<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn cos<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn cos<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn tanh<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn tanh<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn sqrt<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn sqrt<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn rsqrt<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn rsqrt<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn expm1<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn expm1<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
exp(x) - 1. Read more§fn log1p<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn log1p<B>(&self, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
log(1 + x). Read more§fn compare<B>(
&self,
rhs: &Tensor,
dir: CompareDir,
backend: &mut B,
) -> Result<Tensor, Error>where
B: TensorBackend,
fn compare<B>(
&self,
rhs: &Tensor,
dir: CompareDir,
backend: &mut B,
) -> Result<Tensor, Error>where
B: TensorBackend,
§fn where_select<B>(
&self,
on_true: &Tensor,
on_false: &Tensor,
backend: &mut B,
) -> Result<Tensor, Error>where
B: TensorBackend,
fn where_select<B>(
&self,
on_true: &Tensor,
on_false: &Tensor,
backend: &mut B,
) -> Result<Tensor, Error>where
B: TensorBackend,
§fn clamp<B>(
&self,
lower: &Tensor,
upper: &Tensor,
backend: &mut B,
) -> Result<Tensor, Error>where
B: TensorBackend,
fn clamp<B>(
&self,
lower: &Tensor,
upper: &Tensor,
backend: &mut B,
) -> Result<Tensor, Error>where
B: TensorBackend,
§fn matmul<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn matmul<B>(&self, rhs: &Tensor, backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn reshape<B>(&self, shape: &[usize], backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn reshape<B>(&self, shape: &[usize], backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn transpose<B>(&self, perm: &[usize], backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
fn transpose<B>(&self, perm: &[usize], backend: &mut B) -> Result<Tensor, Error>where
B: TensorBackend,
§fn reduce_sum<B>(
&self,
axes: &[usize],
backend: &mut B,
) -> Result<Tensor, Error>where
B: TensorBackend,
fn reduce_sum<B>(
&self,
axes: &[usize],
backend: &mut B,
) -> Result<Tensor, Error>where
B: TensorBackend,
Auto Trait Implementations§
impl Freeze for Tensor
impl !RefUnwindSafe for Tensor
impl Send for Tensor
impl Sync for Tensor
impl Unpin for Tensor
impl UnsafeUnpin for Tensor
impl !UnwindSafe for Tensor
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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