Struct Data

Source
pub struct Data<E, const D: usize> {
    pub value: Vec<E>,
    pub shape: Shape,
}
๐Ÿ‘Ž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
๐Ÿ‘Ž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) -> 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, 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>>(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) -> 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, 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 + Element, 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, dest: *mut u8)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Sourceยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Sourceยง

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Sourceยง

const ALIGN: usize

The alignment of pointer.
Sourceยง

type Init = T

The type for initializers.
Sourceยง

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Sourceยง

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Sourceยง

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Sourceยง

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Sourceยง

impl<T> ToOwned for T
where T: Clone,

Sourceยง

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

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

Sourceยง

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

Sourceยง

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