[−][src]Struct auto_diff::tensor::gen_tensor::GenTensor
Naive tensor implementation, single thread
Implementations
impl<T> GenTensor<T> where
T: Float,
[src]
T: Float,
pub fn new() -> GenTensor<T>
[src]
Creation Ops
pub fn new_raw(data: &[T], shape: &[usize]) -> GenTensor<T>
[src]
Create a tensor with given Vec.
pub fn index2dimpos(&self, index: usize) -> Vec<usize>
[src]
Convert 1 dim index to multi-dim index.
pub fn dimpos2index(&self, dimpos: &[usize]) -> usize
[src]
Convert multi-dim index to 1 dim index.
pub fn zeros(size: &[usize]) -> GenTensor<T>
[src]
pub fn zeros_like(&self) -> GenTensor<T>
[src]
pub fn ones(size: &[usize]) -> GenTensor<T>
[src]
pub fn ones_like(&self) -> GenTensor<T>
[src]
pub fn arange(end: usize) -> GenTensor<T>
[src]
pub fn empty(shape: &[usize]) -> GenTensor<T>
[src]
pub fn fill(d: T, shape: &[usize]) -> GenTensor<T>
[src]
Create a tensor filled with the same value d
let m1 = GenTensor::<f64>::fill(1., &vec![3,5,2]);
pub fn from_record(&mut self, row: usize, record: &[f32]) -> Result<(), ()>
[src]
assign a row.
pub fn stride(&self) -> Vec<usize>
[src]
Right dimension changes fastest. Right dimension has the stride 1.
let m1 = GenTensor::<f64>::new_raw(&vec![0.; 3*5*2], &vec![3,5,2]); assert_eq!(m1.stride(), vec![10,2,1]);
pub fn get(&self, o: &[usize]) -> T
[src]
Return value at the index of the tensor.
let m1 = GenTensor::<f64>::new_raw(&vec![1.,2.,3.,4.,5.,6.], &vec![2,3]); assert_eq!(m1.get(&vec![1,1]), 5.);
pub fn set(&mut self, o: &[usize], v: T)
[src]
pub fn set_1d(&mut self, o: usize, v: T)
[src]
pub fn get_mut(&mut self, o: &[usize]) -> &mut T
[src]
pub fn get_raw(&self) -> Vec<T>
[src]
dump the underlying vec
pub fn get_u8(&self) -> Option<Vec<u8>>
[src]
pub fn get_scale(&self) -> T
[src]
dump the single value in the tensor if it is the single value in the tensor.
pub fn get_n(&self) -> GenTensor<T>
[src]
get NCHW elements, always return the size of left most dimension.
pub fn get_c(&self) -> GenTensor<T>
[src]
get NCHW elements, always return the size of second left most dimension.
pub fn get_d(&self) -> GenTensor<T>
[src]
get NCDHW elements, will require the self.dim has 5 dimensions.
pub fn get_h(&self) -> GenTensor<T>
[src]
get NCDHW elements, will require the self.dim has 5 dimensions or 4 dimensions.
pub fn get_w(&self) -> GenTensor<T>
[src]
get NCDHW elements, will require the self.dim has 5 dimensions or 4 dimensions.
pub fn size(&self) -> &Vec<usize>
[src]
Returns the size of the self tensor.
pub fn get_data(&self) -> &Vec<T>
[src]
pub fn get_data_mut(&mut self) -> &mut Vec<T>
[src]
pub fn numel(&self) -> usize
[src]
Returns the total number of elements in the input tensor
pub fn numel_tensor(&self) -> GenTensor<T>
[src]
Returns the total number of elements in the input tensor
pub fn get_patch(
&self,
range: &[(usize, usize)],
step: Option<&[usize]>
) -> GenTensor<T>
[src]
&self,
range: &[(usize, usize)],
step: Option<&[usize]>
) -> GenTensor<T>
Return portion of the image. Every range of each dim with inclusive start and exclusive end.
pub fn set_patch(
&mut self,
val: &GenTensor<T>,
range: &[(usize, usize)],
step: Option<&[usize]>
)
[src]
&mut self,
val: &GenTensor<T>,
range: &[(usize, usize)],
step: Option<&[usize]>
)
pub fn _iter_patch<F>(
&self,
dim: Option<&[usize]>,
keep_dim: bool,
closure: F
) -> GenTensor<T> where
F: Fn(&[T]) -> T,
[src]
&self,
dim: Option<&[usize]>,
keep_dim: bool,
closure: F
) -> GenTensor<T> where
F: Fn(&[T]) -> T,
pub fn _dim_statistic<F>(
&self,
dim: usize,
keepdim: bool,
closure: F
) -> GenTensor<T> where
F: Fn(usize, usize, usize, usize, usize) -> T,
[src]
&self,
dim: usize,
keepdim: bool,
closure: F
) -> GenTensor<T> where
F: Fn(usize, usize, usize, usize, usize) -> T,
pub fn abs(&self) -> GenTensor<T>
[src]
pub fn acos(&self) -> GenTensor<T>
[src]
pub fn asin(&self) -> GenTensor<T>
[src]
pub fn atan(&self) -> GenTensor<T>
[src]
pub fn ceil(&self) -> GenTensor<T>
[src]
pub fn clamp(&self, min: T, max: T) -> GenTensor<T>
[src]
pub fn cos(&self) -> GenTensor<T>
[src]
pub fn cosh(&self) -> GenTensor<T>
[src]
pub fn exp(&self) -> GenTensor<T>
[src]
pub fn expm1(&self) -> GenTensor<T>
[src]
pub fn floor(&self) -> GenTensor<T>
[src]
pub fn frac(&self) -> GenTensor<T>
[src]
pub fn log(&self) -> GenTensor<T>
[src]
pub fn log10(&self) -> GenTensor<T>
[src]
pub fn log1p(&self) -> GenTensor<T>
[src]
pub fn log1pexp(&self) -> GenTensor<T>
[src]
Better log(1 + exp(x)) see https://cran.r-project.org/web/packages/Rmpfr/vignettes/log1mexp-note.pdf
pub fn log2(&self) -> GenTensor<T>
[src]
pub fn neg(&self) -> GenTensor<T>
[src]
pub fn pow(&self, n: T) -> GenTensor<T>
[src]
pub fn reciprocal(&self) -> GenTensor<T>
[src]
pub fn round(&self) -> GenTensor<T>
[src]
pub fn rsqrt(&self) -> GenTensor<T>
[src]
pub fn sigmoid(&self) -> GenTensor<T>
[src]
pub fn sign(&self) -> GenTensor<T>
[src]
pub fn sin(&self) -> GenTensor<T>
[src]
pub fn sinh(&self) -> GenTensor<T>
[src]
pub fn sqrt(&self) -> GenTensor<T>
[src]
pub fn square(&self) -> GenTensor<T>
[src]
pub fn tan(&self) -> GenTensor<T>
[src]
pub fn tanh(&self) -> GenTensor<T>
[src]
pub fn trunc(&self) -> GenTensor<T>
[src]
pub fn _right_broadcast<F>(&self, o: &GenTensor<T>, closure: F) -> GenTensor<T> where
F: Fn(&T, &T) -> T,
[src]
F: Fn(&T, &T) -> T,
pub fn add(&self, o: &GenTensor<T>) -> GenTensor<T>
[src]
element-wise add with right-hand broadcast.
let m1 = GenTensor::<f64>::new_raw(&vec![1.,2.,3.,4.,], &vec![2,2]); let m2 = GenTensor::<f64>::new_raw(&vec![1.,2.,3.,4.,], &vec![2,2]); let m3 = m1.add(&m2); assert_eq!(m3.get(&vec![0,0]), 2.); assert_eq!(m3.get(&vec![1,1]), 8.);
pub fn sub(&self, o: &GenTensor<T>) -> GenTensor<T>
[src]
pub fn mul(&self, o: &GenTensor<T>) -> GenTensor<T>
[src]
pub fn div(&self, o: &GenTensor<T>) -> GenTensor<T>
[src]
pub fn mm(&self, o: &GenTensor<T>) -> GenTensor<T>
[src]
matrix multiplication
let m1 = GenTensor::<f64>::new_raw(&vec![1.,2.,3.,4.,5.,6.], &vec![3,2]); let m2 = GenTensor::<f64>::new_raw(&vec![2.,3.,4.,5.,6.,7.], &vec![2,3]); let mut result = m1.mm(&m2); assert!(result == GenTensor::<f64>::new_raw(&vec![12.,15.,18.,26.,33.,40.,40.,51.,62.,], &vec![3,3]), "");
pub fn matmul(&self, o: &GenTensor<T>) -> GenTensor<T>
[src]
matrix multiplication of two tensor
pub fn outer(&self, o: &GenTensor<T>, avg: Option<bool>) -> GenTensor<T>
[src]
outer product of right-most dimensions.
pub fn squared_error(t1: &Self, t2: &Self) -> GenTensor<T>
[src]
pub fn all_close(&self, o: &GenTensor<T>) -> GenTensor<T>
[src]
pub fn arg_sort(&self, dim: usize, descending: bool) -> GenTensor<T>
[src]
pub fn eq_t(&self, o: &GenTensor<T>) -> GenTensor<T>
[src]
Computes element-wise equality use eq_t instead, as eq is reserved for == overloading.
let m1 = GenTensor::<f64>::new_raw(&vec![1.,2.,3.,4.,5.,6.], &vec![3,2]); let m2 = GenTensor::<f64>::new_raw(&vec![1.,2.,3.,4.,5.,6.], &vec![3,2]); assert_eq!(m1.eq_t(&m2).get(&vec![0,0]), 1.); assert_eq!(m1.eq_t(&m2).get(&vec![2,1]), 1.);
pub fn equal(&self, o: &GenTensor<T>) -> bool
[src]
true if two tensors have the same size and elements, false otherwise.
let m1 = GenTensor::<f64>::fill(1., &vec![3,5,2]); let m2 = GenTensor::<f64>::fill(1., &vec![3,5,2]); assert_eq!(m1.equal(&m2), true)
pub fn ge(&self, o: &GenTensor<T>) -> GenTensor<T>
[src]
pub fn gt(&self, o: &GenTensor<T>) -> GenTensor<T>
[src]
pub fn le(&self, o: &GenTensor<T>) -> GenTensor<T>
[src]
pub fn lt(&self, o: &GenTensor<T>) -> GenTensor<T>
[src]
pub fn ne(&self, o: &GenTensor<T>) -> GenTensor<T>
[src]
Trait Implementations
impl<T> Clone for GenTensor<T> where
T: Float,
[src]
T: Float,
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T> CompareTensor for GenTensor<T> where
T: Float,
[src]
T: Float,
type TensorType = GenTensor<T>
fn max_pair(&self, o: &GenTensor<T>) -> GenTensor<T>
[src]
fn min_pair(&self, o: &GenTensor<T>) -> GenTensor<T>
[src]
impl<T> Convolution for GenTensor<T> where
T: Float,
[src]
T: Float,
type TensorType = GenTensor<T>
fn conv2d(
&self,
filter: &GenTensor<T>,
stride: (usize, usize),
padding: (usize, usize),
dilation: (usize, usize),
padding_mode: PaddingMode
) -> Self::TensorType
[src]
&self,
filter: &GenTensor<T>,
stride: (usize, usize),
padding: (usize, usize),
dilation: (usize, usize),
padding_mode: PaddingMode
) -> Self::TensorType
fn conv2d_grad(
&self,
filter: &GenTensor<T>,
stride: (usize, usize),
padding: (usize, usize),
dilation: (usize, usize),
padding_mode: PaddingMode,
output_grad: &GenTensor<T>
) -> (Self::TensorType, Self::TensorType)
[src]
&self,
filter: &GenTensor<T>,
stride: (usize, usize),
padding: (usize, usize),
dilation: (usize, usize),
padding_mode: PaddingMode,
output_grad: &GenTensor<T>
) -> (Self::TensorType, Self::TensorType)
fn conv_gen(
&self,
filter: &GenTensor<T>,
stride: &[usize],
padding: &[usize],
dilation: &[usize],
padding_mode: PaddingMode
) -> GenTensor<T>
[src]
&self,
filter: &GenTensor<T>,
stride: &[usize],
padding: &[usize],
dilation: &[usize],
padding_mode: PaddingMode
) -> GenTensor<T>
fn conv_grad_gen(
&self,
filter: &GenTensor<T>,
stride: &[usize],
padding: &[usize],
dilation: &[usize],
padding_mode: PaddingMode,
output_grad: &GenTensor<T>
) -> (GenTensor<T>, GenTensor<T>)
[src]
&self,
filter: &GenTensor<T>,
stride: &[usize],
padding: &[usize],
dilation: &[usize],
padding_mode: PaddingMode,
output_grad: &GenTensor<T>
) -> (GenTensor<T>, GenTensor<T>)
impl Debug for GenTensor<f32>
[src]
impl Debug for GenTensor<f64>
[src]
impl Display for GenTensor<f32>
[src]
impl Display for GenTensor<f64>
[src]
impl<T> Eq for GenTensor<T> where
T: Float,
[src]
T: Float,
impl<T> IndexSlicing for GenTensor<T> where
T: Float,
[src]
T: Float,
type TensorType = GenTensor<T>
fn cat(&self, tensors: &[&Self::TensorType], dim: usize) -> Self::TensorType
[src]
Concatenates the given sequence of seq tensors in the given dimension.
fn chunk(&self, chunks: usize, dim: usize) -> Vec<Self::TensorType>
[src]
Splits a tensor into a specific number of chunks.
fn gather(&self, dim: usize, index: &Self::TensorType) -> Self::TensorType
[src]
fn index_select(&self, dim: usize, index: &Self::TensorType) -> Self::TensorType
[src]
fn reshape(&self, new_shape: &[usize]) -> Self::TensorType
[src]
fn split(&self, sections: &[usize], dim: usize) -> Vec<Self::TensorType>
[src]
Splits the tensor into chunks. Each chunk is a view of the original tensor.
fn squeeze(&self, dim: Option<usize>) -> Self::TensorType
[src]
fn stack(tensors: &[&Self], dim: usize) -> Self::TensorType
[src]
Concatenates sequence of tensors along a new dimension.
All tensors need to be of the same size.
let m1 = GenTensor::<f64>::new_raw(&vec![1.,2.,3.,4.,5.,6.], &vec![3,2]); let m2 = GenTensor::<f64>::new_raw(&vec![2.,3.,4.,5.,6.,7.], &vec![3,2]); let result = GenTensor::<f64>::stack(&vec![&m1, &m2], 1); let raw = result.get_raw(); for i in raw { println!("{}", i); } assert_eq!(*result.size(), vec![3,2,2]);
fn take(&self, index: &[usize]) -> Self::TensorType
[src]
Returns a new tensor with the elements of input at the given indices. The input tensor is treated as if it were viewed as a 1-D tensor. The result takes the same shape as the indices.
fn permute(&self, dims: &[usize]) -> Self::TensorType
[src]
Permute the dimensions of this tensor.
let mut m1 = GenTensor::<f64>::fill(1., &vec![2, 3, 5]); m1.permute(&vec![2, 0, 1]);
fn unsqueeze(&self, dim: usize) -> Self::TensorType
[src]
fn conditional_select(
&self,
x: &Self::TensorType,
y: &Self::TensorType
) -> Self::TensorType
[src]
&self,
x: &Self::TensorType,
y: &Self::TensorType
) -> Self::TensorType
fn repeat(&self, sizes: &[usize]) -> Self::TensorType
[src]
impl<T> PartialEq<GenTensor<T>> for GenTensor<T> where
T: Float,
[src]
T: Float,
let m1 = GenTensor::<f64>::fill(1., &vec![3,5,2]); let m2 = GenTensor::<f64>::fill(1., &vec![3,5,2]); assert_eq!(m1==m2, true)
impl<T> ReduceTensor for GenTensor<T> where
T: Float,
[src]
T: Float,
type TensorType = GenTensor<T>
fn argmax(&self, dim: Option<&[usize]>, keep_dim: bool) -> Self::TensorType
[src]
fn argmin(&self, dim: Option<&[usize]>, keep_dim: bool) -> Self::TensorType
[src]
fn dist()
[src]
fn logsumexp(&self, dim: Option<&[usize]>, keep_dim: bool) -> Self::TensorType
[src]
fn mean(&self, dim: Option<&[usize]>, keep_dim: bool) -> GenTensor<T>
[src]
Returns the mean value of the tensor along dim row.
fn median()
[src]
fn mode()
[src]
fn norm()
[src]
fn prod(&self, dim: Option<&[usize]>, keep_dim: bool) -> GenTensor<T>
[src]
fn std(&self, dim: Option<&[usize]>, keep_dim: bool) -> GenTensor<T>
[src]
fn std_mean()
[src]
fn sum(&self, dim: Option<&[usize]>, keep_dim: bool) -> GenTensor<T>
[src]
Returns the sum of all elements.
let m1 = GenTensor::<f64>::new_raw(&vec![1.,2.,3.,4.,], &vec![2,2]); assert_eq!(m1.sum(None, false).get_scale(), 10.);
fn unique()
[src]
fn unique_consecutive()
[src]
fn var(&self, dim: Option<&[usize]>, keep_dim: bool) -> GenTensor<T>
[src]
fn var_mean()
[src]
fn max(&self, dim: Option<&[usize]>, keep_dim: bool) -> Self::TensorType
[src]
fn min(&self, dim: Option<&[usize]>, keep_dim: bool) -> Self::TensorType
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for GenTensor<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for GenTensor<T> where
T: Send,
T: Send,
impl<T> Sync for GenTensor<T> where
T: Sync,
T: Sync,
impl<T> Unpin for GenTensor<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for GenTensor<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,