Struct candle_core::shape::Shape

source ·
pub struct Shape(/* private fields */);

Implementations§

source§

impl Shape

source

pub fn from_dims(dims: &[usize]) -> Self

source

pub fn rank(&self) -> usize

The rank is the number of dimensions, 0 for a scalar value, 1 for a vector, etc.

source

pub fn into_dims(self) -> Vec<usize>

source

pub fn dims(&self) -> &[usize]

The dimensions as a slice of usize.

source

pub fn elem_count(&self) -> usize

The total number of elements, this is the product of all dimension sizes.

source

pub fn is_contiguous(&self, stride: &[usize]) -> bool

Returns true if the strides are C contiguous (aka row major).

source

pub fn is_fortran_contiguous(&self, stride: &[usize]) -> bool

Returns true if the strides are Fortran contiguous (aka column major).

source

pub fn extend(self, additional_dims: &[usize]) -> Self

Modifies the shape by adding a list of additional dimensions at the end of the existing dimensions.

source

pub fn broadcast_shape_binary_op( &self, rhs: &Self, op: &'static str ) -> Result<Shape>

Check whether the two shapes are compatible for broadcast, and if it is the case return the broadcasted shape. This is to be used for binary pointwise ops.

source§

impl Shape

source

pub fn dims0(&self) -> Result<()>

source§

impl Shape

source

pub fn dims1(&self) -> Result<usize>

source§

impl Shape

source

pub fn dims2(&self) -> Result<(usize, usize)>

source§

impl Shape

source

pub fn dims3(&self) -> Result<(usize, usize, usize)>

source§

impl Shape

source

pub fn dims4(&self) -> Result<(usize, usize, usize, usize)>

source§

impl Shape

source

pub fn dims5(&self) -> Result<(usize, usize, usize, usize, usize)>

Trait Implementations§

source§

impl Clone for Shape

source§

fn clone(&self) -> Shape

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 Debug for Shape

source§

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

Formats the value using the given formatter. Read more
source§

impl From<&[usize]> for Shape

source§

fn from(dims: &[usize]) -> Self

Converts to this type from the input type.
source§

impl<const C: usize> From<&[usize; C]> for Shape

source§

fn from(dims: &[usize; C]) -> Self

Converts to this type from the input type.
source§

impl From<&Shape> for Shape

source§

fn from(shape: &Shape) -> Self

Converts to this type from the input type.
source§

impl From<()> for Shape

source§

fn from(_: ()) -> Self

Converts to this type from the input type.
source§

impl From<(usize,)> for Shape

source§

fn from(d1: (usize,)) -> Self

Converts to this type from the input type.
source§

impl From<(usize, usize)> for Shape

source§

fn from(d12: (usize, usize)) -> Self

Converts to this type from the input type.
source§

impl From<(usize, usize, usize)> for Shape

source§

fn from(d123: (usize, usize, usize)) -> Self

Converts to this type from the input type.
source§

impl From<(usize, usize, usize, usize)> for Shape

source§

fn from(d1234: (usize, usize, usize, usize)) -> Self

Converts to this type from the input type.
source§

impl From<(usize, usize, usize, usize, usize)> for Shape

source§

fn from(d12345: (usize, usize, usize, usize, usize)) -> Self

Converts to this type from the input type.
source§

impl From<(usize, usize, usize, usize, usize, usize)> for Shape

source§

fn from(d123456: (usize, usize, usize, usize, usize, usize)) -> Self

Converts to this type from the input type.
source§

impl From<Vec<usize>> for Shape

source§

fn from(dims: Vec<usize>) -> Self

Converts to this type from the input type.
source§

impl From<usize> for Shape

source§

fn from(d1: usize) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Shape

source§

fn eq(&self, other: &Shape) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryInto<()> for Shape

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<(), Self::Error>

Performs the conversion.
source§

impl TryInto<(usize, usize)> for Shape

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<(usize, usize), Self::Error>

Performs the conversion.
source§

impl TryInto<(usize, usize, usize)> for Shape

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<(usize, usize, usize), Self::Error>

Performs the conversion.
source§

impl TryInto<(usize, usize, usize, usize)> for Shape

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<(usize, usize, usize, usize), Self::Error>

Performs the conversion.
source§

impl TryInto<(usize, usize, usize, usize, usize)> for Shape

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<(usize, usize, usize, usize, usize), Self::Error>

Performs the conversion.
source§

impl TryInto<usize> for Shape

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<usize, Self::Error>

Performs the conversion.
source§

impl Eq for Shape

source§

impl StructuralPartialEq for Shape

Auto Trait Implementations§

§

impl RefUnwindSafe for Shape

§

impl Send for Shape

§

impl Sync for Shape

§

impl Unpin for Shape

§

impl UnwindSafe for Shape

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

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<S> ShapeWithOneHole for S
where S: Into<Shape>,

source§

fn into_shape(self, _el_count: usize) -> Result<Shape, Error>

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

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

§

fn vzip(self) -> V

source§

impl<T> ErasedDestructor for T
where T: 'static,