#[non_exhaustive]pub enum Error {
Show 22 variants
ShapeMismatch {
expected: Vec<usize>,
got: Vec<usize>,
},
BroadcastError {
lhs: Vec<usize>,
rhs: Vec<usize>,
},
InvalidDimension {
dim: isize,
ndim: usize,
},
UnsupportedDType {
dtype: DType,
op: &'static str,
},
DTypeMismatch {
lhs: DType,
rhs: DType,
},
DeviceMismatch,
OutOfMemory {
size: usize,
},
AllocFailed {
shape: Vec<usize>,
dtype: String,
device: String,
source: Box<Error>,
},
IndexOutOfBounds {
index: usize,
size: usize,
},
InvalidArgument {
arg: &'static str,
reason: String,
},
NotContiguous,
HostReadTypeMismatch {
dtype: &'static str,
dtype_bytes: usize,
elem_bytes: usize,
},
MissingGradient,
Backend(String),
BackendLimitation {
backend: &'static str,
operation: &'static str,
reason: String,
},
Msg(String),
Internal(String),
NotImplemented {
feature: &'static str,
},
FeatureRequired {
dtype: DType,
feature: &'static str,
},
AllocatorBusy {
active_allocations: usize,
},
AllocatorFrozen,
ArenaExhausted {
requested: usize,
used: usize,
capacity: usize,
},
}Expand description
Errors that can occur in numr operations
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ShapeMismatch
Shape mismatch in an operation
BroadcastError
Shapes cannot be broadcast together
InvalidDimension
Invalid dimension index
UnsupportedDType
Unsupported dtype for an operation
DTypeMismatch
DType mismatch between operands
DeviceMismatch
Device mismatch between operands
OutOfMemory
Out of memory
AllocFailed
Tensor allocation failed, with the shape/dtype/device context
Wraps the underlying allocation error (usually Error::OutOfMemory)
so the message names what was being allocated, not only a byte count.
Fields
device: StringDevice name (from Device::name)
IndexOutOfBounds
Index out of bounds
InvalidArgument
Invalid argument provided to an operation
NotContiguous
Tensor is not contiguous when contiguous memory is required
HostReadTypeMismatch
A host read names an element type whose width differs from the dtype.
A width mismatch sizes the copy wrong, so it would read past the buffer.
Fields
MissingGradient
Missing gradient in backward pass
Backend(String)
Backend-specific error
BackendLimitation
Backend limitation - operation valid but exceeds backend capabilities
Fields
Msg(String)
Generic message error
Internal(String)
Generic internal error
NotImplemented
Feature not yet implemented
FeatureRequired
Cargo feature required but not enabled
Fields
AllocatorBusy
Allocator cannot reset while allocations are still live
AllocatorFrozen
Allocator is frozen — no new allocations permitted
ArenaExhausted
A CUDA graph capture arena ran out of room for an intermediate allocation.
Carries the numbers a caller needs to size a retry: the request that
failed, the bytes the arena had already handed out, and the arena’s
total capacity. Raised during capture_graph_into_with_arena when an
intermediate allocation inside the capture overruns the pre-sized
arena; the caller can recapture with a larger arena sized from
used + requested.
Implementations§
Source§impl Error
impl Error
Sourcepub fn as_arena_exhausted(&self) -> Option<(usize, usize, usize)>
pub fn as_arena_exhausted(&self) -> Option<(usize, usize, usize)>
The arena-exhaustion fields, if this error is
Error::ArenaExhausted or wraps one as an
Error::AllocFailed source.
A CUDA graph intermediate is normally allocated through
Tensor::empty/Tensor::zeros, which wraps every allocation failure
in AllocFailed for shape/dtype/device context. This walks that one
layer of wrapping so a caller can react to arena exhaustion without
matching on message text.
Source§impl Error
impl Error
Sourcepub fn shape_mismatch(expected: &[usize], got: &[usize]) -> Self
pub fn shape_mismatch(expected: &[usize], got: &[usize]) -> Self
Create a shape mismatch error
Sourcepub fn unsupported_dtype(dtype: DType, op: &'static str) -> Self
pub fn unsupported_dtype(dtype: DType, op: &'static str) -> Self
Create an unsupported dtype error
Sourcepub fn is_out_of_memory(&self) -> bool
pub fn is_out_of_memory(&self) -> bool
Returns true when an allocation fails for lack of memory.
This holds for Error::OutOfMemory, and for Error::AllocFailed
that wraps it. A caller can then name the next action, such as a smaller
input, without reading the message.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl Forget for Error
impl Freeze for Error
impl Move for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe for Error
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.