Struct concrete_core::math::tensor::Tensor [−][src]
#[repr(transparent)]pub struct Tensor<Container: ?Sized>(_);
Expand description
A generic type to perform operations on collections of scalar values.
See the module-level documentation for more explanations on the logic of this type.
Naming convention
The methods that may mutate the values of a Tensor
, follow a convention:
- Methods prefixed with
update_with
use the current values ofself
when performing the operation. - Methods prefixed with
fill_with
discard the current vales ofself
, and overwrite it with the result of an operation on other values.
Implementations
Allocates a new Tensor<Vec<T>>
whose values are all value
.
use concrete_core::math::tensor::Tensor;
let tensor = Tensor::allocate(9 as u8, 1000);
assert_eq!(tensor.len(), 1000);
assert_eq!(*tensor.get_element(0), 9);
assert_eq!(*tensor.get_element(1), 9);
Saves a tensor to a binary file.
Note
The file format does not contain a type signature that guarantees that the file was restored to the same type it was saved.
Example
use concrete_core::math::tensor::Tensor;
use std::path::PathBuf;
let t = Tensor::allocate(66 as u8, 10_000);
let path = PathBuf::from("/tmp/test_save_tensor.ts");
assert!(!path.exists());
t.save_to_file(&path);
assert!(path.exists());
pub fn load_from_file<Path: AsRef<Path>>(path: Path) -> Result<Self, LoadError> where
Self: DeserializeOwned,
pub fn load_from_file<Path: AsRef<Path>>(path: Path) -> Result<Self, LoadError> where
Self: DeserializeOwned,
Loads a tensor from a binary file.
Note
The file format does not contain a type signature that guarantees that the file was restored to the same type it was saved.
Example
use concrete_core::math::tensor::Tensor;
use std::path::PathBuf;
let t_initial = Tensor::allocate(66 as u8, 10_000);
let path = PathBuf::from("/tmp/test_save_tensor.ts");
t_initial.save_to_file(&path);
let t_recovered = Tensor::load_from_file(&path).unwrap();
assert_eq!(t_initial, t_recovered);
Creates a new tensor from a container.
Example
use concrete_core::math::tensor::Tensor;
let vec = vec![9 as u8; 1000];
let view = vec.as_slice();
let tensor = Tensor::from_container(view);
assert_eq!(tensor.len(), 1000);
assert_eq!(*tensor.get_element(0), 9);
assert_eq!(*tensor.get_element(1), 9);
Consumes a tensor and returns its container.
Example
use concrete_core::math::tensor::Tensor;
let tensor = Tensor::allocate(9 as u8, 1000);
let vec = tensor.into_container();
assert_eq!(vec.len(), 1000);
assert_eq!(vec[0], 9);
assert_eq!(vec[1], 9);
Returns a reference to the tensor container.
Example
use concrete_core::math::tensor::Tensor;
let tensor = Tensor::allocate(9 as u8, 1000);
let vecref: &Vec<_> = tensor.as_container();
Returns a mutable reference to the tensor container.
Example
use concrete_core::math::tensor::Tensor;
let mut tensor = Tensor::allocate(9 as u8, 1000);
let vecmut: &mut Vec<_> = tensor.as_mut_container();
Returns the length of the tensor.
Example
use concrete_core::math::tensor::Tensor;
let tensor = Tensor::allocate(9 as u8, 1000);
assert_eq!(tensor.len(), 1000);
Returns whether the tensor is empty.
Example
use concrete_core::math::tensor::Tensor;
let tensor = Tensor::allocate(9 as u8, 1000);
assert_eq!(tensor.is_empty(), false);
pub fn iter(
&self
) -> impl DoubleEndedIterator<Item = &<Self as AsRefSlice>::Element> + ExactSizeIterator where
Self: AsRefSlice,
pub fn iter(
&self
) -> impl DoubleEndedIterator<Item = &<Self as AsRefSlice>::Element> + ExactSizeIterator where
Self: AsRefSlice,
Returns an iterator over &Scalar
elements.
Example
use concrete_core::math::tensor::Tensor;
let tensor = Tensor::allocate(9 as u8, 1000);
for scalar in tensor.iter() {
assert_eq!(*scalar, 9);
}
pub fn iter_mut(
&mut self
) -> impl DoubleEndedIterator<Item = &mut <Self as AsMutSlice>::Element> + ExactSizeIterator where
Self: AsMutSlice,
pub fn iter_mut(
&mut self
) -> impl DoubleEndedIterator<Item = &mut <Self as AsMutSlice>::Element> + ExactSizeIterator where
Self: AsMutSlice,
Returns an iterator over &mut T
elements.
Example:
use concrete_core::math::tensor::Tensor;
let mut tensor = Tensor::allocate(9 as u8, 1000);
for mut scalar in tensor.iter_mut() {
*scalar = 8;
}
for scalar in tensor.iter() {
assert_eq!(*scalar, 8);
}
pub fn subtensor_iter(
&self,
size: usize
) -> impl DoubleEndedIterator<Item = Tensor<&[<Self as AsRefSlice>::Element]>> + ExactSizeIterator where
Self: AsRefSlice,
pub fn subtensor_iter(
&self,
size: usize
) -> impl DoubleEndedIterator<Item = Tensor<&[<Self as AsRefSlice>::Element]>> + ExactSizeIterator where
Self: AsRefSlice,
pub fn subtensor_iter_mut(
&mut self,
size: usize
) -> impl DoubleEndedIterator<Item = Tensor<&mut [<Self as AsMutSlice>::Element]>> + ExactSizeIterator where
Self: AsMutSlice,
pub fn subtensor_iter_mut(
&mut self,
size: usize
) -> impl DoubleEndedIterator<Item = Tensor<&mut [<Self as AsMutSlice>::Element]>> + ExactSizeIterator where
Self: AsMutSlice,
Returns an iterator over mutable sub tensors Tensor<&mut [Scalar]>
.
Note:
The length of the sub-tensors must divide the size of the tensor.
Example:
use concrete_core::math::tensor::Tensor;
let mut tensor = Tensor::allocate(9 as u8, 1000);
for mut sub in tensor.subtensor_iter_mut(10) {
assert_eq!(sub.len(), 10);
*sub.get_element_mut(0) = 1;
}
for sub in tensor.subtensor_iter(20) {
assert_eq!(*sub.get_element(0), 1);
assert_eq!(*sub.get_element(10), 1);
}
pub fn first_mut<Element>(&mut self) -> &mut Element where
Self: AsMutSlice<Element = Element>,
pub fn first_mut<Element>(&mut self) -> &mut Element where
Self: AsMutSlice<Element = Element>,
pub fn split_first<Element>(&self) -> (&Element, Tensor<&[Element]>) where
Self: AsRefSlice<Element = Element>,
pub fn split_first<Element>(&self) -> (&Element, Tensor<&[Element]>) where
Self: AsRefSlice<Element = Element>,
Returns a reference to the first element, and a ref tensor for the rest of the values.
Note:
Panics if the tensor is empty.
Example:
use concrete_core::math::tensor::Tensor;
let tensor = Tensor::allocate(9 as u8, 1000);
let (first, end) = tensor.split_first();
assert_eq!(*first, 9);
assert_eq!(end.len(), 999);
pub fn split_last<Element>(&self) -> (&Element, Tensor<&[Element]>) where
Self: AsRefSlice<Element = Element>,
pub fn split_last<Element>(&self) -> (&Element, Tensor<&[Element]>) where
Self: AsRefSlice<Element = Element>,
Returns a reference to the last element, and a ref tensor to the rest of the values.
Note:
Panics if the tensor is empty.
Example:
use concrete_core::math::tensor::Tensor;
let tensor = Tensor::allocate(9 as u8, 1000);
let (last, beginning) = tensor.split_last();
assert_eq!(*last, 9);
assert_eq!(beginning.len(), 999);
pub fn split_first_mut<Element>(
&mut self
) -> (&mut Element, Tensor<&mut [Element]>) where
Self: AsMutSlice<Element = Element>,
pub fn split_first_mut<Element>(
&mut self
) -> (&mut Element, Tensor<&mut [Element]>) where
Self: AsMutSlice<Element = Element>,
Returns a mutable reference to the first element, and a mut tensor for the rest of the values.
Note:
Panics if the tensor is empty.
Example:
use concrete_core::math::tensor::Tensor;
let mut tensor = Tensor::allocate(9 as u8, 1000);
let (mut first, mut end) = tensor.split_first_mut();
*first = 8;
*end.get_element_mut(0) = 7;
assert_eq!(*tensor.get_element(0), 8);
assert_eq!(*tensor.get_element(1), 7);
assert_eq!(*tensor.get_element(2), 9);
pub fn split_last_mut<Element>(
&mut self
) -> (&mut Element, Tensor<&mut [Element]>) where
Self: AsMutSlice<Element = Element>,
pub fn split_last_mut<Element>(
&mut self
) -> (&mut Element, Tensor<&mut [Element]>) where
Self: AsMutSlice<Element = Element>,
Returns a mutable reference to the last element, and a mut tensor for the rest of the values.
Note:
Panics if the tensor is empty.
Example:
use concrete_core::math::tensor::Tensor;
let mut tensor = Tensor::allocate(9 as u8, 1000);
let (mut last, mut beginning) = tensor.split_last_mut();
*last = 8;
*beginning.get_element_mut(0) = 7;
assert_eq!(*tensor.get_element(0), 7);
assert_eq!(*tensor.get_element(999), 8);
assert_eq!(*tensor.get_element(2), 9);
pub fn get_sub<Index>(
&self,
index: Index
) -> Tensor<&[<Self as AsRefSlice>::Element]> where
Self: AsRefSlice,
Index: SliceIndex<[<Self as AsRefSlice>::Element], Output = [<Self as AsRefSlice>::Element]>,
pub fn get_sub<Index>(
&self,
index: Index
) -> Tensor<&[<Self as AsRefSlice>::Element]> where
Self: AsRefSlice,
Index: SliceIndex<[<Self as AsRefSlice>::Element], Output = [<Self as AsRefSlice>::Element]>,
pub fn get_sub_mut<Index>(
&mut self,
index: Index
) -> Tensor<&mut [<Self as AsMutSlice>::Element]> where
Self: AsMutSlice,
Index: SliceIndex<[<Self as AsMutSlice>::Element], Output = [<Self as AsMutSlice>::Element]>,
pub fn get_sub_mut<Index>(
&mut self,
index: Index
) -> Tensor<&mut [<Self as AsMutSlice>::Element]> where
Self: AsMutSlice,
Index: SliceIndex<[<Self as AsMutSlice>::Element], Output = [<Self as AsMutSlice>::Element]>,
Returns a mutable sub tensor from a range of indices.
Note:
Panics if the indices are out of range.
Example:
use concrete_core::math::tensor::Tensor;
let mut tensor = Tensor::allocate(9 as u8, 1000);
let mut sub = tensor.get_sub_mut(0..3);
sub.fill_with_element(0);
assert_eq!(*tensor.get_element(0), 0);
assert_eq!(*tensor.get_element(3), 9);
pub fn get_element(&self, index: usize) -> &<Self as AsRefSlice>::Element where
Self: AsRefSlice,
pub fn get_element(&self, index: usize) -> &<Self as AsRefSlice>::Element where
Self: AsRefSlice,
pub fn get_element_mut(
&mut self,
index: usize
) -> &mut <Self as AsMutSlice>::Element where
Self: AsMutSlice,
pub fn get_element_mut(
&mut self,
index: usize
) -> &mut <Self as AsMutSlice>::Element where
Self: AsMutSlice,
Returns a mutable reference to an element from an index.
Note:
Panics if the index is out of range.
Example:
use concrete_core::math::tensor::Tensor;
let mut tensor = Tensor::allocate(9 as u8, 1000);
*tensor.get_element_mut(0) = 8;
assert_eq!(*tensor.get_element(0), 8);
assert_eq!(*tensor.get_element(1), 9);
pub fn set_element(&mut self, index: usize, val: <Self as AsMutSlice>::Element) where
Self: AsMutSlice,
pub fn set_element(&mut self, index: usize, val: <Self as AsMutSlice>::Element) where
Self: AsMutSlice,
pub fn fill_with_copy<InputCont, Element>(&mut self, other: &Tensor<InputCont>) where
Self: AsMutSlice<Element = Element>,
Tensor<InputCont>: AsRefSlice<Element = Element>,
Element: Copy,
pub fn fill_with_copy<InputCont, Element>(&mut self, other: &Tensor<InputCont>) where
Self: AsMutSlice<Element = Element>,
Tensor<InputCont>: AsRefSlice<Element = Element>,
Element: Copy,
Fills a tensor with the values of another tensor, using memcpy.
Example
use concrete_core::math::tensor::Tensor;
let mut tensor1 = Tensor::allocate(9 as u8, 1000);
let tensor2 = Tensor::allocate(10 as u8, 1000);
tensor1.fill_with_copy(&tensor2);
assert_eq!(*tensor2.get_element(0), 10);
pub fn fill_two_with_one<Cont1, Cont2>(
first: &mut Self,
second: &mut Tensor<Cont1>,
one: &Tensor<Cont2>,
ope: impl Fn(&<Tensor<Cont2> as AsRefSlice>::Element) -> (<Self as AsRefSlice>::Element, <Tensor<Cont1> as AsRefSlice>::Element)
) where
Self: AsMutSlice,
Tensor<Cont1>: AsMutSlice,
Tensor<Cont2>: AsRefSlice,
pub fn fill_two_with_one<Cont1, Cont2>(
first: &mut Self,
second: &mut Tensor<Cont1>,
one: &Tensor<Cont2>,
ope: impl Fn(&<Tensor<Cont2> as AsRefSlice>::Element) -> (<Self as AsRefSlice>::Element, <Tensor<Cont1> as AsRefSlice>::Element)
) where
Self: AsMutSlice,
Tensor<Cont1>: AsMutSlice,
Tensor<Cont2>: AsRefSlice,
Fills two tensors with the result of the operation on a single one.
Example:
use concrete_core::math::tensor::Tensor;
let mut tensor1 = Tensor::allocate(9 as u8, 1000);
let mut tensor2 = Tensor::allocate(9 as u8, 1000);
let tensor3 = Tensor::allocate(10 as u8, 1000);
Tensor::fill_two_with_one(&mut tensor1, &mut tensor2, &tensor3, |a| (*a, *a));
assert_eq!(*tensor1.get_element(0), 10);
assert_eq!(*tensor2.get_element(0), 10);
pub fn fill_with_two<Cont1, Cont2>(
&mut self,
lhs: &Tensor<Cont1>,
rhs: &Tensor<Cont2>,
ope: impl Fn(&<Tensor<Cont1> as AsRefSlice>::Element, &<Tensor<Cont2> as AsRefSlice>::Element) -> <Self as AsMutSlice>::Element
) where
Tensor<Cont1>: AsRefSlice,
Tensor<Cont2>: AsRefSlice,
Self: AsMutSlice,
pub fn fill_with_two<Cont1, Cont2>(
&mut self,
lhs: &Tensor<Cont1>,
rhs: &Tensor<Cont2>,
ope: impl Fn(&<Tensor<Cont1> as AsRefSlice>::Element, &<Tensor<Cont2> as AsRefSlice>::Element) -> <Self as AsMutSlice>::Element
) where
Tensor<Cont1>: AsRefSlice,
Tensor<Cont2>: AsRefSlice,
Self: AsMutSlice,
Fills a mutable tensor with the result of an element-wise operation on two other tensors of the same size
use concrete_core::math::tensor::Tensor;
let mut t1 = Tensor::allocate(9 as u8, 1000);
let t2 = Tensor::allocate(1 as u8, 1000);
let t3 = Tensor::allocate(2 as u8, 1000);
t1.fill_with_two(&t2, &t3, |t2, t3| t3 + t2);
for scalar in t1.iter() {
assert_eq!(*scalar, 3);
}
pub fn fill_with_one<Cont>(
&mut self,
other: &Tensor<Cont>,
ope: impl Fn(&<Tensor<Cont> as AsRefSlice>::Element) -> <Self as AsMutSlice>::Element
) where
Tensor<Cont>: AsRefSlice,
Self: AsMutSlice,
pub fn fill_with_one<Cont>(
&mut self,
other: &Tensor<Cont>,
ope: impl Fn(&<Tensor<Cont> as AsRefSlice>::Element) -> <Self as AsMutSlice>::Element
) where
Tensor<Cont>: AsRefSlice,
Self: AsMutSlice,
Fills a mutable tensor with the result of an element-wise operation on one other tensor of the same size
use concrete_core::math::tensor::Tensor;
let mut t1 = Tensor::allocate(9 as u8, 1000);
let t2 = Tensor::allocate(2 as u8, 1000);
t1.fill_with_one(&t2, |t2| t2.pow(2));
for scalar in t1.iter() {
assert_eq!(*scalar, 4);
}
pub fn fill_with_element(&mut self, element: <Self as AsMutSlice>::Element) where
Self: AsMutSlice,
<Self as AsMutSlice>::Element: Copy,
pub fn fill_with_element(&mut self, element: <Self as AsMutSlice>::Element) where
Self: AsMutSlice,
<Self as AsMutSlice>::Element: Copy,
Fills a mutable tensor with an element.
use concrete_core::math::tensor::Tensor;
let mut tensor = Tensor::allocate(9 as u8, 1000);
tensor.fill_with_element(8);
for scalar in tensor.iter() {
assert_eq!(*scalar, 8);
}
pub fn fill_with(&mut self, ope: impl Fn() -> <Self as AsMutSlice>::Element) where
Self: AsMutSlice,
pub fn fill_with(&mut self, ope: impl Fn() -> <Self as AsMutSlice>::Element) where
Self: AsMutSlice,
Fills a mutable tensor by repeatedly calling a closure.
use concrete_core::math::tensor::Tensor;
use std::cell::RefCell;
let mut tensor = Tensor::allocate(9 as u16, 1000);
let mut boxed = RefCell::from(0);
tensor.fill_with(|| {
*boxed.borrow_mut() += 1;
*boxed.borrow()
});
assert_eq!(*tensor.get_element(0), 1);
assert_eq!(*tensor.get_element(1), 2);
assert_eq!(*tensor.get_element(2), 3);
pub fn fill_with_cast<Cont>(&mut self, other: &Tensor<Cont>) where
Self: AsMutSlice,
Tensor<Cont>: AsRefSlice,
<Self as AsMutSlice>::Element: CastFrom<<Tensor<Cont> as AsRefSlice>::Element>,
<Tensor<Cont> as AsRefSlice>::Element: Copy,
pub fn fill_with_cast<Cont>(&mut self, other: &Tensor<Cont>) where
Self: AsMutSlice,
Tensor<Cont>: AsRefSlice,
<Self as AsMutSlice>::Element: CastFrom<<Tensor<Cont> as AsRefSlice>::Element>,
<Tensor<Cont> as AsRefSlice>::Element: Copy,
Fills a mutable tensor by casting elements of another one.
use concrete_core::math::tensor::Tensor;
let mut t1 = Tensor::allocate(9 as u16, 1000);
let mut t2 = Tensor::allocate(8. as f32, 1000);
t1.fill_with_cast(&t2);
for scalar in t1.iter() {
assert_eq!(*scalar, 8);
}
pub fn fill_with_add<Lhs, Rhs>(&mut self, lhs: &Tensor<Lhs>, rhs: &Tensor<Rhs>) where
Tensor<Lhs>: AsRefSlice,
Tensor<Rhs>: AsRefSlice,
Self: AsMutSlice,
<Tensor<Lhs> as AsRefSlice>::Element: Add<<Tensor<Rhs> as AsRefSlice>::Element, Output = <Self as AsMutSlice>::Element>,
<Tensor<Lhs> as AsRefSlice>::Element: Copy,
<Tensor<Rhs> as AsRefSlice>::Element: Copy,
pub fn fill_with_sub<Lhs, Rhs>(&mut self, lhs: &Tensor<Lhs>, rhs: &Tensor<Rhs>) where
Tensor<Lhs>: AsRefSlice,
Tensor<Rhs>: AsRefSlice,
Self: AsMutSlice,
<Tensor<Lhs> as AsRefSlice>::Element: Sub<<Tensor<Rhs> as AsRefSlice>::Element, Output = <Self as AsMutSlice>::Element>,
<Tensor<Lhs> as AsRefSlice>::Element: Copy,
<Tensor<Rhs> as AsRefSlice>::Element: Copy,
pub fn fill_with_mul<Lhs, Rhs>(&mut self, lhs: &Tensor<Lhs>, rhs: &Tensor<Rhs>) where
Tensor<Lhs>: AsRefSlice,
Tensor<Rhs>: AsRefSlice,
Self: AsMutSlice,
<Tensor<Lhs> as AsRefSlice>::Element: Mul<<Tensor<Rhs> as AsRefSlice>::Element, Output = <Self as AsMutSlice>::Element>,
<Tensor<Lhs> as AsRefSlice>::Element: Copy,
<Tensor<Rhs> as AsRefSlice>::Element: Copy,
pub fn fill_with_div<Lhs, Rhs>(&mut self, lhs: &Tensor<Lhs>, rhs: &Tensor<Rhs>) where
Tensor<Lhs>: AsRefSlice,
Tensor<Rhs>: AsRefSlice,
Self: AsMutSlice,
<Tensor<Lhs> as AsRefSlice>::Element: Div<<Tensor<Rhs> as AsRefSlice>::Element, Output = <Self as AsMutSlice>::Element>,
<Tensor<Lhs> as AsRefSlice>::Element: Copy,
<Tensor<Rhs> as AsRefSlice>::Element: Copy,
pub fn fill_with_rem<Lhs, Rhs>(&mut self, lhs: &Tensor<Lhs>, rhs: &Tensor<Rhs>) where
Tensor<Lhs>: AsRefSlice,
Tensor<Rhs>: AsRefSlice,
Self: AsMutSlice,
<Tensor<Lhs> as AsRefSlice>::Element: Rem<<Tensor<Rhs> as AsRefSlice>::Element, Output = <Self as AsMutSlice>::Element>,
<Tensor<Lhs> as AsRefSlice>::Element: Copy,
<Tensor<Rhs> as AsRefSlice>::Element: Copy,
pub fn fill_with_bit_and<Lhs, Rhs>(
&mut self,
lhs: &Tensor<Lhs>,
rhs: &Tensor<Rhs>
) where
Tensor<Lhs>: AsRefSlice,
Tensor<Rhs>: AsRefSlice,
Self: AsMutSlice,
<Tensor<Lhs> as AsRefSlice>::Element: BitAnd<<Tensor<Rhs> as AsRefSlice>::Element, Output = <Self as AsMutSlice>::Element>,
<Tensor<Lhs> as AsRefSlice>::Element: Copy,
<Tensor<Rhs> as AsRefSlice>::Element: Copy,
pub fn fill_with_bit_or<Lhs, Rhs>(
&mut self,
lhs: &Tensor<Lhs>,
rhs: &Tensor<Rhs>
) where
Tensor<Lhs>: AsRefSlice,
Tensor<Rhs>: AsRefSlice,
Self: AsMutSlice,
<Tensor<Lhs> as AsRefSlice>::Element: BitOr<<Tensor<Rhs> as AsRefSlice>::Element, Output = <Self as AsMutSlice>::Element>,
<Tensor<Lhs> as AsRefSlice>::Element: Copy,
<Tensor<Rhs> as AsRefSlice>::Element: Copy,
pub fn fill_with_bit_xor<Lhs, Rhs>(
&mut self,
lhs: &Tensor<Lhs>,
rhs: &Tensor<Rhs>
) where
Tensor<Lhs>: AsRefSlice,
Tensor<Rhs>: AsRefSlice,
Self: AsMutSlice,
<Tensor<Lhs> as AsRefSlice>::Element: BitXor<<Tensor<Rhs> as AsRefSlice>::Element, Output = <Self as AsMutSlice>::Element>,
<Tensor<Lhs> as AsRefSlice>::Element: Copy,
<Tensor<Rhs> as AsRefSlice>::Element: Copy,
pub fn fill_with_bit_shl<Lhs, Rhs>(
&mut self,
lhs: &Tensor<Lhs>,
rhs: &Tensor<Rhs>
) where
Tensor<Lhs>: AsRefSlice,
Tensor<Rhs>: AsRefSlice,
Self: AsMutSlice,
<Tensor<Lhs> as AsRefSlice>::Element: Shl<<Tensor<Rhs> as AsRefSlice>::Element, Output = <Self as AsMutSlice>::Element>,
<Tensor<Lhs> as AsRefSlice>::Element: Copy,
<Tensor<Rhs> as AsRefSlice>::Element: Copy,
pub fn fill_with_bit_shr<Lhs, Rhs>(
&mut self,
lhs: &Tensor<Lhs>,
rhs: &Tensor<Rhs>
) where
Tensor<Lhs>: AsRefSlice,
Tensor<Rhs>: AsRefSlice,
Self: AsMutSlice,
<Tensor<Lhs> as AsRefSlice>::Element: Shr<<Tensor<Rhs> as AsRefSlice>::Element, Output = <Self as AsMutSlice>::Element>,
<Tensor<Lhs> as AsRefSlice>::Element: Copy,
<Tensor<Rhs> as AsRefSlice>::Element: Copy,
pub fn fill_with_wrapping_add<Lhs, Rhs, Element>(
&mut self,
lhs: &Tensor<Lhs>,
rhs: &Tensor<Rhs>
) where
Tensor<Lhs>: AsRefSlice<Element = Element>,
Tensor<Rhs>: AsRefSlice<Element = Element>,
Self: AsMutSlice<Element = Element>,
Element: UnsignedInteger,
pub fn fill_with_wrapping_sub<Lhs, Rhs, Element>(
&mut self,
lhs: &Tensor<Lhs>,
rhs: &Tensor<Rhs>
) where
Tensor<Lhs>: AsRefSlice<Element = Element>,
Tensor<Rhs>: AsRefSlice<Element = Element>,
Self: AsMutSlice<Element = Element>,
Element: UnsignedInteger,
pub fn fill_with_wrapping_mul<Lhs, Rhs, Element>(
&mut self,
lhs: &Tensor<Lhs>,
rhs: &Tensor<Rhs>
) where
Tensor<Lhs>: AsRefSlice<Element = Element>,
Tensor<Rhs>: AsRefSlice<Element = Element>,
Self: AsMutSlice<Element = Element>,
Element: UnsignedInteger,
pub fn fill_with_wrapping_div<Lhs, Rhs, Element>(
&mut self,
lhs: &Tensor<Lhs>,
rhs: &Tensor<Rhs>
) where
Tensor<Lhs>: AsRefSlice<Element = Element>,
Tensor<Rhs>: AsRefSlice<Element = Element>,
Self: AsMutSlice<Element = Element>,
Element: UnsignedInteger,
pub fn update_two_with_one<Cont1, Cont2>(
first: &mut Self,
second: &mut Tensor<Cont1>,
one: &Tensor<Cont2>,
ope: impl Fn(&mut <Self as AsRefSlice>::Element, &mut <Tensor<Cont1> as AsRefSlice>::Element, &<Tensor<Cont2> as AsRefSlice>::Element)
) where
Self: AsMutSlice,
Tensor<Cont1>: AsMutSlice,
Tensor<Cont2>: AsRefSlice,
pub fn update_two_with_one<Cont1, Cont2>(
first: &mut Self,
second: &mut Tensor<Cont1>,
one: &Tensor<Cont2>,
ope: impl Fn(&mut <Self as AsRefSlice>::Element, &mut <Tensor<Cont1> as AsRefSlice>::Element, &<Tensor<Cont2> as AsRefSlice>::Element)
) where
Self: AsMutSlice,
Tensor<Cont1>: AsMutSlice,
Tensor<Cont2>: AsRefSlice,
Updates two tensors with the result of the operation with a single one.
Example:
use concrete_core::math::tensor::Tensor;
let mut tensor1 = Tensor::allocate(9 as u8, 1000);
let mut tensor2 = Tensor::allocate(9 as u8, 1000);
let tensor3 = Tensor::allocate(10 as u8, 1000);
Tensor::update_two_with_one(&mut tensor1, &mut tensor2, &tensor3, |a, b, c| {
*a += *c;
*b += *c + 1;
});
assert_eq!(*tensor1.get_element(0), 19);
assert_eq!(*tensor2.get_element(0), 20);
pub fn update_with_two<Cont1, Cont2>(
&mut self,
first: &Tensor<Cont1>,
second: &Tensor<Cont2>,
ope: impl Fn(&mut <Self as AsMutSlice>::Element, &<Tensor<Cont1> as AsRefSlice>::Element, &<Tensor<Cont2> as AsRefSlice>::Element)
) where
Self: AsMutSlice,
Tensor<Cont1>: AsRefSlice,
Tensor<Cont2>: AsRefSlice,
pub fn update_with_two<Cont1, Cont2>(
&mut self,
first: &Tensor<Cont1>,
second: &Tensor<Cont2>,
ope: impl Fn(&mut <Self as AsMutSlice>::Element, &<Tensor<Cont1> as AsRefSlice>::Element, &<Tensor<Cont2> as AsRefSlice>::Element)
) where
Self: AsMutSlice,
Tensor<Cont1>: AsRefSlice,
Tensor<Cont2>: AsRefSlice,
Updates a mutable tensor with the result of an element-wise operation with two other tensors of the same size.
use concrete_core::math::tensor::Tensor;
let mut t1 = Tensor::allocate(9 as u8, 1000);
let t2 = Tensor::allocate(1 as u8, 1000);
let t3 = Tensor::allocate(2 as u8, 1000);
t1.update_with_two(&t2, &t3, |t1, t2, t3| *t1 += t3 + t2);
for scalar in t1.iter() {
assert_eq!(*scalar, 12);
}
pub fn update_with_one<Cont>(
&mut self,
other: &Tensor<Cont>,
ope: impl Fn(&mut <Self as AsMutSlice>::Element, &<Tensor<Cont> as AsRefSlice>::Element)
) where
Self: AsMutSlice,
Tensor<Cont>: AsRefSlice,
pub fn update_with_one<Cont>(
&mut self,
other: &Tensor<Cont>,
ope: impl Fn(&mut <Self as AsMutSlice>::Element, &<Tensor<Cont> as AsRefSlice>::Element)
) where
Self: AsMutSlice,
Tensor<Cont>: AsRefSlice,
Updates a mutable tensor with the result of an element-wise operation with one other tensor of the same size
use concrete_core::math::tensor::Tensor;
let mut t1 = Tensor::allocate(9 as u8, 1000);
let t2 = Tensor::allocate(2 as u8, 1000);
t1.update_with_one(&t2, |t1, t2| *t1 += t2.pow(2));
for scalar in t1.iter() {
assert_eq!(*scalar, 13);
}
pub fn update_with_element<Element>(
&mut self,
scalar: Element,
ope: impl Fn(&mut <Self as AsMutSlice>::Element, Element)
) where
Self: AsMutSlice,
Element: Copy,
pub fn update_with_element<Element>(
&mut self,
scalar: Element,
ope: impl Fn(&mut <Self as AsMutSlice>::Element, Element)
) where
Self: AsMutSlice,
Element: Copy,
Updates a mutable tensor with an element.
use concrete_core::math::tensor::Tensor;
let mut tensor = Tensor::allocate(9 as u8, 1000);
tensor.update_with_element(8, |t, s| *t += s);
for scalar in tensor.iter() {
assert_eq!(*scalar, 17);
}
pub fn update_with(&mut self, ope: impl Fn(&mut <Self as AsMutSlice>::Element)) where
Self: AsMutSlice,
pub fn update_with(&mut self, ope: impl Fn(&mut <Self as AsMutSlice>::Element)) where
Self: AsMutSlice,
Updates a mutable tensor by repeatedly calling a closure.
use concrete_core::math::tensor::Tensor;
use std::cell::RefCell;
let mut tensor = Tensor::allocate(9 as u16, 1000);
let mut boxed = RefCell::from(0);
tensor.update_with(|t| {
*boxed.borrow_mut() += 1;
*t += *boxed.borrow()
});
assert_eq!(*tensor.get_element(0), 10);
assert_eq!(*tensor.get_element(1), 11);
assert_eq!(*tensor.get_element(2), 12);
pub fn update_with_add<Other>(&mut self, other: &Tensor<Other>) where
Self: AsMutSlice,
Tensor<Other>: AsRefSlice,
<Self as AsMutSlice>::Element: AddAssign<<Tensor<Other> as AsRefSlice>::Element>,
<Tensor<Other> as AsRefSlice>::Element: Copy,
pub fn update_with_sub<Other>(&mut self, other: &Tensor<Other>) where
Self: AsMutSlice,
Tensor<Other>: AsRefSlice,
<Self as AsMutSlice>::Element: SubAssign<<Tensor<Other> as AsRefSlice>::Element>,
<Tensor<Other> as AsRefSlice>::Element: Copy,
pub fn update_with_mul<Other>(&mut self, other: &Tensor<Other>) where
Self: AsMutSlice,
Tensor<Other>: AsRefSlice,
<Self as AsMutSlice>::Element: MulAssign<<Tensor<Other> as AsRefSlice>::Element>,
<Tensor<Other> as AsRefSlice>::Element: Copy,
pub fn update_with_div<Other>(&mut self, other: &Tensor<Other>) where
Self: AsMutSlice,
Tensor<Other>: AsRefSlice,
<Self as AsMutSlice>::Element: DivAssign<<Tensor<Other> as AsRefSlice>::Element>,
<Tensor<Other> as AsRefSlice>::Element: Copy,
pub fn update_with_rem<Other>(&mut self, other: &Tensor<Other>) where
Self: AsMutSlice,
Tensor<Other>: AsRefSlice,
<Self as AsMutSlice>::Element: RemAssign<<Tensor<Other> as AsRefSlice>::Element>,
<Tensor<Other> as AsRefSlice>::Element: Copy,
pub fn update_with_and<Other>(&mut self, other: &Tensor<Other>) where
Self: AsMutSlice,
Tensor<Other>: AsRefSlice,
<Self as AsMutSlice>::Element: BitAndAssign<<Tensor<Other> as AsRefSlice>::Element>,
<Tensor<Other> as AsRefSlice>::Element: Copy,
pub fn update_with_or<Other>(&mut self, other: &Tensor<Other>) where
Self: AsMutSlice,
Tensor<Other>: AsRefSlice,
<Self as AsMutSlice>::Element: BitOrAssign<<Tensor<Other> as AsRefSlice>::Element>,
<Tensor<Other> as AsRefSlice>::Element: Copy,
pub fn update_with_xor<Other>(&mut self, other: &Tensor<Other>) where
Self: AsMutSlice,
Tensor<Other>: AsRefSlice,
<Self as AsMutSlice>::Element: BitXorAssign<<Tensor<Other> as AsRefSlice>::Element>,
<Tensor<Other> as AsRefSlice>::Element: Copy,
pub fn update_with_shl<Other>(&mut self, other: &Tensor<Other>) where
Self: AsMutSlice,
Tensor<Other>: AsRefSlice,
<Self as AsMutSlice>::Element: ShlAssign<<Tensor<Other> as AsRefSlice>::Element>,
<Tensor<Other> as AsRefSlice>::Element: Copy,
pub fn update_with_shr<Other>(&mut self, other: &Tensor<Other>) where
Self: AsMutSlice,
Tensor<Other>: AsRefSlice,
<Self as AsMutSlice>::Element: ShrAssign<<Tensor<Other> as AsRefSlice>::Element>,
<Tensor<Other> as AsRefSlice>::Element: Copy,
pub fn update_with_wrapping_add<Other, Element>(
&mut self,
other: &Tensor<Other>
) where
Self: AsMutSlice<Element = Element>,
Tensor<Other>: AsRefSlice<Element = Element>,
Element: UnsignedInteger,
pub fn update_with_wrapping_sub<Other, Element>(
&mut self,
other: &Tensor<Other>
) where
Self: AsMutSlice<Element = Element>,
Tensor<Other>: AsRefSlice<Element = Element>,
Element: UnsignedInteger,
pub fn update_with_wrapping_mul<Other, Element>(
&mut self,
other: &Tensor<Other>
) where
Self: AsMutSlice<Element = Element>,
Tensor<Other>: AsRefSlice<Element = Element>,
Element: UnsignedInteger,
pub fn update_with_wrapping_div<Other, Element>(
&mut self,
other: &Tensor<Other>
) where
Self: AsMutSlice<Element = Element>,
Tensor<Other>: AsRefSlice<Element = Element>,
Element: UnsignedInteger,
pub fn update_with_scalar_add<Element>(&mut self, element: &Element) where
Self: AsMutSlice,
<Self as AsMutSlice>::Element: AddAssign<Element>,
Element: Copy,
pub fn update_with_scalar_sub<Element>(&mut self, element: &Element) where
Self: AsMutSlice,
<Self as AsMutSlice>::Element: SubAssign<Element>,
Element: Copy,
pub fn update_with_scalar_mul<Element>(&mut self, element: &Element) where
Self: AsMutSlice,
<Self as AsMutSlice>::Element: MulAssign<Element>,
Element: Copy,
pub fn update_with_scalar_div<Element>(&mut self, element: &Element) where
Self: AsMutSlice,
<Self as AsMutSlice>::Element: DivAssign<Element>,
Element: Copy,
pub fn update_with_scalar_rem<Element>(&mut self, element: &Element) where
Self: AsMutSlice,
<Self as AsMutSlice>::Element: RemAssign<Element>,
Element: Copy,
pub fn update_with_scalar_and<Element>(&mut self, element: &Element) where
Self: AsMutSlice,
<Self as AsMutSlice>::Element: BitAndAssign<Element>,
Element: Copy,
pub fn update_with_scalar_or<Element>(&mut self, element: &Element) where
Self: AsMutSlice,
<Self as AsMutSlice>::Element: BitOrAssign<Element>,
Element: Copy,
pub fn update_with_scalar_xor<Element>(&mut self, element: &Element) where
Self: AsMutSlice,
<Self as AsMutSlice>::Element: BitXorAssign<Element>,
Element: Copy,
pub fn update_with_scalar_shl<Element>(&mut self, element: &Element) where
Self: AsMutSlice,
<Self as AsMutSlice>::Element: ShlAssign<Element>,
Element: Copy,
pub fn update_with_scalar_shr<Element>(&mut self, element: &Element) where
Self: AsMutSlice,
<Self as AsMutSlice>::Element: ShrAssign<Element>,
Element: Copy,
pub fn update_with_wrapping_scalar_add<Element>(&mut self, element: &Element) where
Self: AsMutSlice<Element = Element>,
Element: UnsignedInteger,
pub fn update_with_wrapping_scalar_sub<Element>(&mut self, element: &Element) where
Self: AsMutSlice<Element = Element>,
Element: UnsignedInteger,
pub fn update_with_wrapping_scalar_mul<Element>(&mut self, element: &Element) where
Self: AsMutSlice<Element = Element>,
Element: UnsignedInteger,
pub fn update_with_wrapping_scalar_div<Element>(&mut self, element: &Element) where
Self: AsMutSlice<Element = Element>,
Element: UnsignedInteger,
pub fn update_with_neg(&mut self) where
Self: AsMutSlice,
<Self as AsMutSlice>::Element: Neg<Output = <Self as AsMutSlice>::Element> + Copy,
pub fn update_with_neg(&mut self) where
Self: AsMutSlice,
<Self as AsMutSlice>::Element: Neg<Output = <Self as AsMutSlice>::Element> + Copy,
Sets each value of self
to its own opposite.
Example
use concrete_core::math::tensor::Tensor;
let mut tensor = Tensor::allocate(9 as i16, 1000);
tensor.update_with_neg();
for scalar in tensor.iter() {
assert_eq!(*scalar, -9);
}
pub fn update_with_wrapping_neg(&mut self) where
Self: AsMutSlice,
<Self as AsMutSlice>::Element: UnsignedInteger,
pub fn update_with_wrapping_neg(&mut self) where
Self: AsMutSlice,
<Self as AsMutSlice>::Element: UnsignedInteger,
Sets each value of self
to its own wrapping opposite.
Example
use concrete_core::math::tensor::Tensor;
let mut tensor = Tensor::allocate(9 as u8, 1000);
tensor.update_with_wrapping_neg();
for scalar in tensor.iter() {
assert_eq!(*scalar, 247);
}
pub fn fill_with_element_mul<Cont, Element>(
&mut self,
tensor: &Tensor<Cont>,
element: Element
) where
Self: AsMutSlice,
Tensor<Cont>: AsRefSlice,
<Tensor<Cont> as AsRefSlice>::Element: Mul<Element, Output = <Self as AsMutSlice>::Element>,
Element: Copy,
<Tensor<Cont> as AsRefSlice>::Element: Copy,
pub fn fill_with_element_mul<Cont, Element>(
&mut self,
tensor: &Tensor<Cont>,
element: Element
) where
Self: AsMutSlice,
Tensor<Cont>: AsRefSlice,
<Tensor<Cont> as AsRefSlice>::Element: Mul<Element, Output = <Self as AsMutSlice>::Element>,
Element: Copy,
<Tensor<Cont> as AsRefSlice>::Element: Copy,
Fills a mutable tensor with the result of the multiplication of elements of another tensor by an element.
Example
use concrete_core::math::tensor::Tensor;
let mut t1 = Tensor::allocate(9 as u8, 1000);
let t2 = Tensor::allocate(3 as u8, 1000);
t1.fill_with_element_mul(&t2, 2);
for scalar in t1.iter() {
assert_eq!(*scalar, 6);
}
pub fn fill_with_wrapping_element_mul<Cont, Element>(
&mut self,
tensor: &Tensor<Cont>,
element: Element
) where
Self: AsMutSlice<Element = Element>,
Tensor<Cont>: AsRefSlice<Element = Element>,
Element: UnsignedInteger,
pub fn fill_with_wrapping_element_mul<Cont, Element>(
&mut self,
tensor: &Tensor<Cont>,
element: Element
) where
Self: AsMutSlice<Element = Element>,
Tensor<Cont>: AsRefSlice<Element = Element>,
Element: UnsignedInteger,
Fills a mutable tensor with the result of the wrapping multiplication of elements of another tensor by an element.
Example
use concrete_core::math::tensor::Tensor;
let mut t1 = Tensor::allocate(9 as u8, 1000);
let t2 = Tensor::allocate(3 as u8, 1000);
t1.fill_with_wrapping_element_mul(&t2, 250);
for scalar in t1.iter() {
assert_eq!(*scalar, 238);
}
pub fn update_with_sub_element_mul<Cont, Element>(
&mut self,
tensor: &Tensor<Cont>,
scalar: Element
) where
Self: AsMutSlice,
Tensor<Cont>: AsRefSlice,
<Tensor<Cont> as AsRefSlice>::Element: Copy,
Element: Copy,
<Tensor<Cont> as AsRefSlice>::Element: Mul<Element, Output = <Self as AsMutSlice>::Element>,
<Self as AsMutSlice>::Element: SubAssign<<Self as AsMutSlice>::Element>,
pub fn update_with_sub_element_mul<Cont, Element>(
&mut self,
tensor: &Tensor<Cont>,
scalar: Element
) where
Self: AsMutSlice,
Tensor<Cont>: AsRefSlice,
<Tensor<Cont> as AsRefSlice>::Element: Copy,
Element: Copy,
<Tensor<Cont> as AsRefSlice>::Element: Mul<Element, Output = <Self as AsMutSlice>::Element>,
<Self as AsMutSlice>::Element: SubAssign<<Self as AsMutSlice>::Element>,
Updates the values of a mutable tensor by subtracting the product of the element of another tensor and an element.
Example
use concrete_core::math::tensor::Tensor;
let mut t1 = Tensor::allocate(9 as u8, 1000);
let t2 = Tensor::allocate(2 as u8, 1000);
t1.update_with_sub_element_mul(&t2, 4);
for scalar in t1.iter() {
assert_eq!(*scalar, 1);
}
pub fn update_with_wrapping_sub_element_mul<Cont, Element>(
&mut self,
tensor: &Tensor<Cont>,
scalar: Element
) where
Self: AsMutSlice<Element = Element>,
Tensor<Cont>: AsRefSlice<Element = Element>,
Element: UnsignedInteger,
pub fn update_with_wrapping_sub_element_mul<Cont, Element>(
&mut self,
tensor: &Tensor<Cont>,
scalar: Element
) where
Self: AsMutSlice<Element = Element>,
Tensor<Cont>: AsRefSlice<Element = Element>,
Element: UnsignedInteger,
Updates the values of a mutable tensor by wrap-subtracting the wrapping product of the elements of another tensor and an element.
Example
use concrete_core::math::tensor::Tensor;
let mut t1 = Tensor::allocate(9 as u8, 1000);
let t2 = Tensor::allocate(2 as u8, 1000);
t1.update_with_wrapping_sub_element_mul(&t2, 250);
for scalar in t1.iter() {
assert_eq!(*scalar, 21);
}
pub fn update_with_add_element_mul<Cont, Element>(
&mut self,
tensor: &Tensor<Cont>,
scalar: Element
) where
Self: AsMutSlice,
Tensor<Cont>: AsRefSlice,
<Tensor<Cont> as AsRefSlice>::Element: Copy,
Element: Copy,
<Tensor<Cont> as AsRefSlice>::Element: Mul<Element, Output = <Self as AsMutSlice>::Element>,
<Self as AsMutSlice>::Element: AddAssign<<Self as AsMutSlice>::Element>,
pub fn update_with_add_element_mul<Cont, Element>(
&mut self,
tensor: &Tensor<Cont>,
scalar: Element
) where
Self: AsMutSlice,
Tensor<Cont>: AsRefSlice,
<Tensor<Cont> as AsRefSlice>::Element: Copy,
Element: Copy,
<Tensor<Cont> as AsRefSlice>::Element: Mul<Element, Output = <Self as AsMutSlice>::Element>,
<Self as AsMutSlice>::Element: AddAssign<<Self as AsMutSlice>::Element>,
Updates the values of a mutable tensor by adding the product of the element of another tensor and an element.
Example
use concrete_core::math::tensor::Tensor;
let mut t1 = Tensor::allocate(9 as u8, 1000);
let t2 = Tensor::allocate(2 as u8, 1000);
t1.update_with_add_element_mul(&t2, 4);
for scalar in t1.iter() {
assert_eq!(*scalar, 17);
}
pub fn update_with_wrapping_add_element_mul<Cont, Element>(
&mut self,
tensor: &Tensor<Cont>,
element: Element
) where
Self: AsMutSlice<Element = Element>,
Tensor<Cont>: AsRefSlice<Element = Element>,
Element: UnsignedInteger,
pub fn update_with_wrapping_add_element_mul<Cont, Element>(
&mut self,
tensor: &Tensor<Cont>,
element: Element
) where
Self: AsMutSlice<Element = Element>,
Tensor<Cont>: AsRefSlice<Element = Element>,
Element: UnsignedInteger,
Updates the values of a mutable tensor by wrap-adding the wrapping product of the elements of another tensor and an element.
Example
use concrete_core::math::tensor::Tensor;
let mut t1 = Tensor::allocate(9 as u8, 1000);
let t2 = Tensor::allocate(2 as u8, 1000);
t1.update_with_wrapping_add_element_mul(&t2, 250);
for scalar in t1.iter() {
assert_eq!(*scalar, 253);
}
pub fn fold_with_one<Cont, Output>(
&self,
other: &Tensor<Cont>,
acc: Output,
ope: impl Fn(Output, &<Self as AsRefSlice>::Element, &<Tensor<Cont> as AsRefSlice>::Element) -> Output
) -> Output where
Self: AsRefSlice,
Tensor<Cont>: AsRefSlice,
pub fn fold_with_one<Cont, Output>(
&self,
other: &Tensor<Cont>,
acc: Output,
ope: impl Fn(Output, &<Self as AsRefSlice>::Element, &<Tensor<Cont> as AsRefSlice>::Element) -> Output
) -> Output where
Self: AsRefSlice,
Tensor<Cont>: AsRefSlice,
Computes a value by folding a tensor with another.
Example
use concrete_core::math::tensor::Tensor;
let t1 = Tensor::allocate(10 as u16, 10);
let t2 = Tensor::allocate(2 as u16, 10);
let val = t1.fold_with_one(&t2, 0, |mut a, t1, t2| {
a += t1 + t2;
a
});
assert_eq!(val, 120);
Reverses the elements of the tensor inplace.
Example
use concrete_core::math::tensor::Tensor;
let mut tensor = Tensor::from_container(vec![1u8, 2, 3, 4]);
tensor.reverse();
assert_eq!(*tensor.get_element(0), 4);
Rotates the elements of the tensor to the right, inplace.
Example
use concrete_core::math::tensor::Tensor;
let mut tensor = Tensor::from_container(vec![1u8, 2, 3, 4]);
tensor.rotate_right(2);
assert_eq!(*tensor.get_element(0), 3);
Rotates the elements of the tensor to the left, inplace.
Example
use concrete_core::math::tensor::Tensor;
let mut tensor = Tensor::from_container(vec![1u8, 2, 3, 4]);
tensor.rotate_left(2);
assert_eq!(*tensor.get_element(0), 3);
Trait Implementations
type Element = <Cont as AsMutSlice>::Element
type Element = <Cont as AsMutSlice>::Element
The element type.
type Container = Cont
type Container = Cont
The container used by the tensor.
Returns a mutable reference to the enclosed tensor.
impl<'de, Container: ?Sized> Deserialize<'de> for Tensor<Container> where
Container: Deserialize<'de>,
impl<'de, Container: ?Sized> Deserialize<'de> for Tensor<Container> where
Container: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Creates a value from an iterator. Read more
Auto Trait Implementations
impl<Container: ?Sized> RefUnwindSafe for Tensor<Container> where
Container: RefUnwindSafe,
impl<Container: ?Sized> UnwindSafe for Tensor<Container> where
Container: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more