pub struct Tensor {
pub storage: Storage,
/* private fields */
}Fields§
§storage: StorageImplementations§
Source§impl Tensor
impl Tensor
pub fn new(storage: Storage, device: Device, requires_grad: bool) -> Self
pub fn view(&self, tensor: Storage) -> Self
pub fn tensor(&self) -> &Storage
pub fn tensor_mut(&mut self) -> &mut Storage
pub fn device(&self) -> Device
pub fn requires_grad(&self) -> &bool
pub fn grad_fn(&self) -> Option<Rc<dyn GradientFunction>>
pub fn set_grad_fn(&mut self, grad_fn: Option<Rc<dyn GradientFunction>>)
pub fn grad(&self) -> Option<GradientStorage>
pub fn grad_mut(&mut self) -> GradientStorage
pub fn shape(&self) -> &Vec<usize>
pub fn backward(&mut self)
Source§impl Tensor
impl Tensor
pub fn zeros( shape: Vec<usize>, device: Device, requires_grad: Option<bool>, ) -> Self
pub fn ones( shape: Vec<usize>, device: Device, requires_grad: Option<bool>, ) -> Self
pub fn from_ndarray<S, D, T>( data: &ArrayBase<S, D>, device: Device, requires_grad: Option<bool>, ) -> Self
pub fn uniform( l_bound: f32, r_bound: f32, shape: Vec<usize>, device: Device, requires_grad: Option<bool>, ) -> Self
Trait Implementations§
Source§impl ActivationOps for Tensor
impl ActivationOps for Tensor
fn binary_step(&self) -> Self
fn sigmoid(&self) -> Self
fn tanh(&self) -> Self
fn relu(&self) -> Self
fn leaky_relu(&self) -> Self
fn parametric_relu(&self, a: f32) -> Self
fn elu(&self, alpha: f32) -> Self
fn softmax(&self, dim: usize) -> Self
fn swish(&self) -> Self
Source§impl AddAssign<&Tensor> for Tensor
impl AddAssign<&Tensor> for Tensor
Source§fn add_assign(&mut self, rhs: &Tensor)
fn add_assign(&mut self, rhs: &Tensor)
Performs the
+= operation. Read moreSource§impl AddAssign<f32> for Tensor
impl AddAssign<f32> for Tensor
Source§fn add_assign(&mut self, rhs: f32)
fn add_assign(&mut self, rhs: f32)
Performs the
+= operation. Read moreSource§impl ArithmeticOps for Tensor
impl ArithmeticOps for Tensor
fn add_tensor(&self, other: &Self) -> Self
fn sub_tensor(&self, other: &Self) -> Self
fn mul_tensor(&self, other: &Self) -> Self
fn div_tensor(&self, other: &Self) -> Self
fn pow_f32(&self, other: f32) -> Self
fn add_f32(&self, other: f32) -> Self
fn sub_f32(&self, other: f32) -> Self
fn mul_f32(&self, other: f32) -> Self
fn div_f32(&self, other: f32) -> Self
fn abs(&self) -> Self
fn add_tensor_assign(&mut self, other: &Self)
fn sub_tensor_assign(&mut self, other: &Self)
fn mul_tensor_assign(&mut self, other: &Self)
fn div_tensor_assign(&mut self, other: &Self)
fn add_f32_assign(&mut self, other: f32)
fn sub_f32_assign(&mut self, other: f32)
fn mul_f32_assign(&mut self, other: f32)
fn div_f32_assign(&mut self, other: f32)
fn pow_f32_assign(&mut self, other: f32)
fn abs_assign(&mut self)
fn greater_than(&self, other: &Self, make_binary: bool) -> Self
fn greater_than_f32(&self, other: f32, make_binary: bool) -> Self
fn less_than(&self, other: &Self, make_binary: bool) -> Self
fn less_than_f32(&self, other: f32, make_binary: bool) -> Self
fn sign(&self) -> Self
Source§impl DivAssign<&Tensor> for Tensor
impl DivAssign<&Tensor> for Tensor
Source§fn div_assign(&mut self, rhs: &Tensor)
fn div_assign(&mut self, rhs: &Tensor)
Performs the
/= operation. Read moreSource§impl DivAssign<f32> for Tensor
impl DivAssign<f32> for Tensor
Source§fn div_assign(&mut self, rhs: f32)
fn div_assign(&mut self, rhs: f32)
Performs the
/= operation. Read moreSource§impl MulAssign<&Tensor> for Tensor
impl MulAssign<&Tensor> for Tensor
Source§fn mul_assign(&mut self, rhs: &Tensor)
fn mul_assign(&mut self, rhs: &Tensor)
Performs the
*= operation. Read moreSource§impl MulAssign<f32> for Tensor
impl MulAssign<f32> for Tensor
Source§fn mul_assign(&mut self, rhs: f32)
fn mul_assign(&mut self, rhs: f32)
Performs the
*= operation. Read moreSource§impl ReductionOps for Tensor
impl ReductionOps for Tensor
Source§impl SubAssign<&Tensor> for Tensor
impl SubAssign<&Tensor> for Tensor
Source§fn sub_assign(&mut self, rhs: &Tensor)
fn sub_assign(&mut self, rhs: &Tensor)
Performs the
-= operation. Read moreSource§impl SubAssign<f32> for Tensor
impl SubAssign<f32> for Tensor
Source§fn sub_assign(&mut self, rhs: f32)
fn sub_assign(&mut self, rhs: f32)
Performs the
-= operation. Read moreSource§impl TransformOps for Tensor
impl TransformOps for Tensor
fn apply<F>(&self, op: F) -> Self
fn apply_assign<F>(&mut self, op: F)
fn elementwise_op<F>(&self, other: &Self, op: F) -> Self
fn scalar_op<F>(&self, scalar: f32, op: F) -> Self
fn elementwise_op_assign<F>(&mut self, other: &Self, op: F)
fn scalar_op_assign<F>(&mut self, scalar: f32, op: F)
fn sum_dim(&self, dims: &[bool]) -> Self
fn reshape(&mut self, new_shape: Vec<usize>)
fn transpose(&self) -> Self
fn permute(&mut self, dims: &[usize])
fn flatten(&mut self)
fn squeeze(&mut self)
fn unsqueeze(&mut self, dim: usize)
fn broadcast(&self, new_shape: &[usize]) -> Self
fn compute_broadcast_shape(&self, target_shape: &[usize]) -> Vec<usize>
fn compute_broadcast_strides(&self, broadcast_shape: &[usize]) -> Vec<usize>
fn pad_shape(&self, target_rank: usize) -> Vec<usize>
fn broadcast_tensors(a: &Self, b: &Self) -> (Self, Self)where
Self: Sized,
Auto Trait Implementations§
impl Freeze for Tensor
impl !RefUnwindSafe for Tensor
impl !Send for Tensor
impl !Sync for Tensor
impl Unpin 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
Mutably borrows from an owned value. Read more
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>
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 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>
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