ShapeError

Enum ShapeError 

Source
pub enum ShapeError {
Show 16 variants InvalidSize { message: String, location: &'static Location<'static>, }, InvalidDimension { message: String, location: &'static Location<'static>, }, BroadcastError { message: String, location: &'static Location<'static>, }, MatmulMismatch { lhs: Shape, rhs: Shape, expected: i64, location: &'static Location<'static>, }, DimMismatch { expected: usize, actual: usize, location: &'static Location<'static>, }, DimOutOfRange { expected: Range<i64>, actual: i64, location: &'static Location<'static>, }, GeomSpaceError { start: f64, end: f64, location: &'static Location<'static>, }, ConcatDimMismatch { expected: usize, actual: usize, location: &'static Location<'static>, }, NdimNotEnough { message: String, expected: usize, actual: usize, location: &'static Location<'static>, }, SqueezeError { axis: usize, shape: Shape, location: &'static Location<'static>, }, ContiguousError { message: String, shape: Shape, strides: Strides, location: &'static Location<'static>, }, ConvError { message: String, location: &'static Location<'static>, }, TopkError { message: String, location: &'static Location<'static>, }, InplaceReshapeError { message: String, location: &'static Location<'static>, }, ExpandError { old_dim: i64, location: &'static Location<'static>, }, InvalidShape { message: String, location: &'static Location<'static>, },
}
Expand description

Errors related to tensor shapes and dimensions

Variants§

§

InvalidSize

Error that occurs when there is size problem

Fields

§message: String

Message describing the size mismatch

§location: &'static Location<'static>

Location where the error occurred

§

InvalidDimension

Error that occurs when the dimension of a tensor is invalid

Fields

§message: String

Message describing the invalid dimension

§location: &'static Location<'static>

Location where the error occurred

§

BroadcastError

Error that occurs when broadcasting fails

Fields

§message: String

Message describing the broadcasting failure

§location: &'static Location<'static>

Location where the error occurred

§

MatmulMismatch

Error that occurs when the shape of two tensors does not match for matrix multiplication

Fields

§lhs: Shape

Left-hand side shape

§rhs: Shape

Right-hand side shape

§expected: i64

Expected shape for the right-hand side

§location: &'static Location<'static>

Location where the error occurred

§

DimMismatch

Error that occurs when the dimension of two tensors does not match

Fields

§expected: usize

Expected dimension

§actual: usize

Actual dimension

§location: &'static Location<'static>

Location where the error occurred

§

DimOutOfRange

Error that occurs when the dimension is out of range

Fields

§expected: Range<i64>

Expected range

§actual: i64

Actual dimension

§location: &'static Location<'static>

Location where the error occurred

§

GeomSpaceError

Error that occurs when geomspace parameters are invalid

Fields

§start: f64

Start value

§end: f64

End value

§location: &'static Location<'static>

Location where error occurred

§

ConcatDimMismatch

Error that occurs when concat dimensions don’t match

Fields

§expected: usize

Expected dimension

§actual: usize

Actual dimension

§location: &'static Location<'static>

Location where error occurred

§

NdimNotEnough

Error that occurs when the number of dimensions of a tensor is less than the expected value

Fields

§message: String

Message describing the error

§expected: usize

Expected dimension

§actual: usize

Actual dimension

§location: &'static Location<'static>

Location where error occurred

§

SqueezeError

Error that occurs when the axis is not 1

Fields

§axis: usize

Axis that is not 1

§shape: Shape

Shape of the tensor

§location: &'static Location<'static>

Location where error occurred

§

ContiguousError

Error that occurs when the tensor is not contiguous

Fields

§message: String

message

§shape: Shape

Shape of the tensor

§strides: Strides

Strides of the tensor

§location: &'static Location<'static>

Location where error occurred

§

ConvError

Error that occurs when the input shape is invalid for conv2d

Fields

§message: String

Message describing the invalid input shape

§location: &'static Location<'static>

Location where error occurred

§

TopkError

Error that occurs when the topk operation is invalid

Fields

§message: String

Message describing the invalid topk operation

§location: &'static Location<'static>

Location where error occurred

§

InplaceReshapeError

Error that occurs when the inplace reshape is invalid

Fields

§message: String

Message describing the invalid inplace reshape

§location: &'static Location<'static>

Location where error occurred

§

ExpandError

Error that occurs when the dimention to expand is not 1

Fields

§old_dim: i64

Old dimention

§location: &'static Location<'static>

Location where error occurred

§

InvalidShape

Error that occurs when the shape is invalid

Fields

§message: String

Message describing the invalid shape

§location: &'static Location<'static>

Location where error occurred

Implementations§

Source§

impl ShapeError

Source

pub fn check_matmul(lhs: &Shape, rhs: &Shape) -> Result<(), Self>

Check if the shapes of two tensors match for matrix multiplication

Source

pub fn check_dim(expected: usize, actual: usize) -> Result<(), Self>

Check if the dimensions of two tensors match

Source

pub fn check_ndim_enough( msg: String, expected: usize, actual: usize, ) -> Result<(), Self>

Check if the number of dimensions of a tensor is greater than the expected value

Source

pub fn check_contiguous(msg: String, layout: &Layout) -> Result<(), Self>

Check if the tensor is contiguous

Source

pub fn check_size_match(expected: i64, actual: i64) -> Result<(), Self>

Check if the size of two tensors match

Source

pub fn check_size_gt(expected: i64, actual: i64) -> Result<(), Self>

Check if the size of two tensors match

Source

pub fn check_inplace_out_layout_valid( out_shape: &Shape, inplace_layout: &Layout, ) -> Result<(), Self>

Check if the output layout is valid for computation with inplace operation

Source

pub fn check_index_out_of_range(index: i64, dim: i64) -> Result<(), Self>

Check if the index is out of range

Trait Implementations§

Source§

impl Debug for ShapeError

Source§

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

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

impl Display for ShapeError

Source§

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

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

impl Error for ShapeError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<ShapeError> for TensorError

Source§

fn from(source: ShapeError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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.

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