Struct burn_tensor::Data

source ยท
pub struct Data<E, const D: usize> {
    pub value: Vec<E>,
    pub shape: Shape<D>,
}
๐Ÿ‘ŽDeprecated since 0.14.0: the internal data format has changed, please use TensorData instead
Expand description

Data structure for tensors.

Fieldsยง

ยงvalue: Vec<E>
๐Ÿ‘ŽDeprecated since 0.14.0: the internal data format has changed, please use TensorData instead

The values of the tensor.

ยงshape: Shape<D>
๐Ÿ‘ŽDeprecated since 0.14.0: the internal data format has changed, please use TensorData instead

The shape of the tensor.

Implementationsยง

sourceยง

impl<E, const D: usize> Data<E, D>

source

pub fn new(value: Vec<E>, shape: Shape<D>) -> Self

Constructs a new Data.

sourceยง

impl<const D: usize, E: Element> Data<E, D>

source

pub fn convert<EOther: Element>(self) -> Data<EOther, D>

Converts the data to a different element type.

source

pub fn assert_within_range<EOther: Element>(&self, range: Range<EOther>)

Asserts each value is within a given range.

ยงArguments
  • range - The range.
ยงPanics

If any value is not within the half-open range bounded inclusively below and exclusively above (start..end).

sourceยง

impl<E: Element, const D: usize> Data<E, D>

source

pub fn random<R: RngCore>( shape: Shape<D>, distribution: Distribution, rng: &mut R, ) -> Self

Populates the data with random values.

sourceยง

impl<E, const D: usize> Data<E, D>
where E: Element + Debug,

source

pub fn zeros<S: Into<Shape<D>>>(shape: S) -> Data<E, D>

Populates the data with zeros.

sourceยง

impl<E, const D: usize> Data<E, D>
where E: Element + Debug,

source

pub fn ones(shape: Shape<D>) -> Data<E, D>

Populates the data with ones.

sourceยง

impl<E, const D: usize> Data<E, D>
where E: Element + Debug,

source

pub fn full(shape: Shape<D>, fill_value: E) -> Data<E, D>

Populates the data with the given value

sourceยง

impl<E: Debug + Copy, const D: usize> Data<E, D>

source

pub fn serialize(&self) -> DataSerialize<E>

Serializes the data.

ยงReturns

The serialized data.

sourceยง

impl<E: Into<f64> + Clone + Debug + PartialEq, const D: usize> Data<E, D>

source

pub fn assert_approx_eq(&self, other: &Self, precision: usize)

Asserts the data is approximately equal to another data.

ยงArguments
  • other - The other data.
  • precision - The precision of the comparison.
ยงPanics

Panics if the data is not approximately equal.

source

pub fn assert_approx_eq_diff(&self, other: &Self, tolerance: f64)

Asserts the data is approximately equal to another data.

ยงArguments
  • other - The other data.
  • tolerance - The tolerance of the comparison.
ยงPanics

Panics if the data is not approximately equal.

sourceยง

impl<const D: usize> Data<usize, D>

source

pub fn from_usize<O: FromPrimitive>(self) -> Data<O, D>

Converts the usize data to a different element type.

Trait Implementationsยง

sourceยง

impl<E: Clone, const D: usize> Clone for Data<E, D>

sourceยง

fn clone(&self) -> Data<E, D>

Returns a copy 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<E: Debug, const D: usize> Debug for Data<E, D>

sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
sourceยง

impl<E: Debug, const D: usize> Display for Data<E, D>

sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
sourceยง

impl<E: Debug + Copy> From<&[E]> for Data<E, 1>

sourceยง

fn from(elems: &[E]) -> Self

Converts to this type from the input type.
sourceยง

impl<E: Clone, const D: usize> From<&DataSerialize<E>> for Data<E, D>

sourceยง

fn from(data: &DataSerialize<E>) -> Self

Converts to this type from the input type.
sourceยง

impl<E: Debug + Copy, const A: usize, const B: usize, const C: usize, const D: usize> From<[[[[E; D]; C]; B]; A]> for Data<E, 4>

sourceยง

fn from(elems: [[[[E; D]; C]; B]; A]) -> Self

Converts to this type from the input type.
sourceยง

impl<E: Debug + Copy, const A: usize, const B: usize, const C: usize> From<[[[E; C]; B]; A]> for Data<E, 3>

sourceยง

fn from(elems: [[[E; C]; B]; A]) -> Self

Converts to this type from the input type.
sourceยง

impl<E: Debug + Copy, const A: usize, const B: usize> From<[[E; B]; A]> for Data<E, 2>

sourceยง

fn from(elems: [[E; B]; A]) -> Self

Converts to this type from the input type.
sourceยง

impl<E: Debug + Copy, const A: usize> From<[E; A]> for Data<E, 1>

sourceยง

fn from(elems: [E; A]) -> Self

Converts to this type from the input type.
sourceยง

impl<E, const D: usize> From<DataSerialize<E>> for Data<E, D>

sourceยง

fn from(data: DataSerialize<E>) -> Self

Converts to this type from the input type.
sourceยง

impl<E: PartialEq, const D: usize> PartialEq for Data<E, D>

sourceยง

fn eq(&self, other: &Data<E, D>) -> 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<E: Eq, const D: usize> Eq for Data<E, D>

sourceยง

impl<E, const D: usize> StructuralPartialEq for Data<E, D>

Auto Trait Implementationsยง

ยง

impl<E, const D: usize> Freeze for Data<E, D>

ยง

impl<E, const D: usize> RefUnwindSafe for Data<E, D>
where E: RefUnwindSafe,

ยง

impl<E, const D: usize> Send for Data<E, D>
where E: Send,

ยง

impl<E, const D: usize> Sync for Data<E, D>
where E: Sync,

ยง

impl<E, const D: usize> Unpin for Data<E, D>
where E: Unpin,

ยง

impl<E, const D: usize> UnwindSafe for Data<E, D>
where E: UnwindSafe,

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, dst: *mut T)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

ยง

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ยง

default 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>,

ยง

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>,

ยง

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.
sourceยง

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

sourceยง

fn vzip(self) -> V