pub enum TensorError {
Show 21 variants
ShapeMismatch {
operation: String,
expected: String,
got: String,
context: Option<ErrorContext>,
},
DeviceMismatch {
operation: String,
device1: String,
device2: String,
context: Option<ErrorContext>,
},
UnsupportedDevice {
operation: String,
device: String,
fallback_available: bool,
context: Option<ErrorContext>,
},
InvalidShape {
operation: String,
reason: String,
shape: Option<Vec<usize>>,
context: Option<ErrorContext>,
},
InvalidAxis {
operation: String,
axis: i32,
ndim: usize,
context: Option<ErrorContext>,
},
GradientNotEnabled {
operation: String,
suggestion: String,
context: Option<ErrorContext>,
},
InvalidArgument {
operation: String,
reason: String,
context: Option<ErrorContext>,
},
AllocationError {
operation: String,
details: String,
requested_bytes: Option<usize>,
available_bytes: Option<usize>,
context: Option<ErrorContext>,
},
UnsupportedOperation {
operation: String,
reason: String,
alternatives: Vec<String>,
context: Option<ErrorContext>,
},
DeviceError {
operation: String,
details: String,
device: String,
context: Option<ErrorContext>,
},
ComputeError {
operation: String,
details: String,
retry_possible: bool,
context: Option<ErrorContext>,
},
SerializationError {
operation: String,
details: String,
context: Option<ErrorContext>,
},
NotImplemented {
operation: String,
details: String,
planned_version: Option<String>,
context: Option<ErrorContext>,
},
InvalidOperation {
operation: String,
reason: String,
context: Option<ErrorContext>,
},
BenchmarkError {
operation: String,
details: String,
context: Option<ErrorContext>,
},
IoError {
operation: String,
details: String,
path: Option<String>,
context: Option<ErrorContext>,
},
NumericalError {
operation: String,
details: String,
suggestions: Vec<String>,
context: Option<ErrorContext>,
},
ResourceExhausted {
operation: String,
resource: String,
current_usage: Option<usize>,
limit: Option<usize>,
context: Option<ErrorContext>,
},
Timeout {
operation: String,
duration_ms: u64,
context: Option<ErrorContext>,
},
CacheError {
operation: String,
details: String,
recoverable: bool,
context: Option<ErrorContext>,
},
Other {
operation: String,
details: String,
context: Option<ErrorContext>,
},
}Expand description
Enhanced error handling with contextual information and recovery strategies
Variants§
ShapeMismatch
DeviceMismatch
UnsupportedDevice
InvalidShape
InvalidAxis
GradientNotEnabled
InvalidArgument
AllocationError
Fields
context: Option<ErrorContext>UnsupportedOperation
DeviceError
ComputeError
SerializationError
NotImplemented
Fields
context: Option<ErrorContext>InvalidOperation
BenchmarkError
IoError
NumericalError
ResourceExhausted
Fields
context: Option<ErrorContext>Timeout
CacheError
Other
Implementations§
Source§impl TensorError
impl TensorError
Sourcepub fn shape_mismatch(operation: &str, expected: &str, got: &str) -> Self
pub fn shape_mismatch(operation: &str, expected: &str, got: &str) -> Self
Create a shape mismatch error with context
Sourcepub fn device_mismatch(operation: &str, device1: &str, device2: &str) -> Self
pub fn device_mismatch(operation: &str, device1: &str, device2: &str) -> Self
Create a device mismatch error with context
Sourcepub fn unsupported_device(
operation: &str,
device: &str,
fallback_available: bool,
) -> Self
pub fn unsupported_device( operation: &str, device: &str, fallback_available: bool, ) -> Self
Create an unsupported device error with fallback information
Sourcepub fn allocation_error(
operation: &str,
details: &str,
requested: Option<usize>,
available: Option<usize>,
) -> Self
pub fn allocation_error( operation: &str, details: &str, requested: Option<usize>, available: Option<usize>, ) -> Self
Create an allocation error with memory information
Sourcepub fn numerical_error(
operation: &str,
details: &str,
suggestions: Vec<String>,
) -> Self
pub fn numerical_error( operation: &str, details: &str, suggestions: Vec<String>, ) -> Self
Create a numerical error with suggestions
Sourcepub fn invalid_argument(reason: String) -> Self
pub fn invalid_argument(reason: String) -> Self
Create an invalid argument error (for backward compatibility)
Sourcepub fn invalid_argument_op(operation: &str, reason: &str) -> Self
pub fn invalid_argument_op(operation: &str, reason: &str) -> Self
Create an invalid argument error with operation context
Sourcepub fn other(details: String) -> Self
pub fn other(details: String) -> Self
Create a generic “other” error (for backward compatibility)
Sourcepub fn other_op(operation: &str, details: &str) -> Self
pub fn other_op(operation: &str, details: &str) -> Self
Create a generic “other” error with operation context
Sourcepub fn allocation_error_simple(details: String) -> Self
pub fn allocation_error_simple(details: String) -> Self
Create an allocation error (for backward compatibility)
Sourcepub fn unsupported_operation_simple(reason: String) -> Self
pub fn unsupported_operation_simple(reason: String) -> Self
Create an unsupported operation error (for backward compatibility)
Sourcepub fn invalid_shape(operation: &str, expected: &str, got: &str) -> Self
pub fn invalid_shape(operation: &str, expected: &str, got: &str) -> Self
Create an invalid shape error with operation context
Sourcepub fn invalid_shape_simple(reason: String) -> Self
pub fn invalid_shape_simple(reason: String) -> Self
Create an invalid shape error (for backward compatibility)
Sourcepub fn device_error_simple(details: String) -> Self
pub fn device_error_simple(details: String) -> Self
Create a device error (for backward compatibility)
Sourcepub fn compute_error_simple(details: String) -> Self
pub fn compute_error_simple(details: String) -> Self
Create a compute error (for backward compatibility)
Sourcepub fn serialization_error_simple(details: String) -> Self
pub fn serialization_error_simple(details: String) -> Self
Create a serialization error (for backward compatibility)
Sourcepub fn not_implemented_simple(details: String) -> Self
pub fn not_implemented_simple(details: String) -> Self
Create a not implemented error (for backward compatibility)
Sourcepub fn invalid_operation_simple(reason: String) -> Self
pub fn invalid_operation_simple(reason: String) -> Self
Create an invalid operation error (for backward compatibility)
Sourcepub fn benchmark_error_simple(details: String) -> Self
pub fn benchmark_error_simple(details: String) -> Self
Create a benchmark error (for backward compatibility)
Sourcepub fn io_error_simple(details: String) -> Self
pub fn io_error_simple(details: String) -> Self
Create an IO error (for backward compatibility)
Sourcepub fn resource_exhausted_simple(resource: String) -> Self
pub fn resource_exhausted_simple(resource: String) -> Self
Create a resource exhausted error (for backward compatibility)
Sourcepub fn timeout_simple(duration_ms: u64) -> Self
pub fn timeout_simple(duration_ms: u64) -> Self
Create a timeout error (for backward compatibility)
Sourcepub fn with_context(self, context: ErrorContext) -> Self
pub fn with_context(self, context: ErrorContext) -> Self
Add context to an existing error
Sourcepub fn supports_fallback(&self) -> bool
pub fn supports_fallback(&self) -> bool
Check if this error supports fallback recovery
Sourcepub fn recovery_strategy(&self) -> RecoveryStrategy
pub fn recovery_strategy(&self) -> RecoveryStrategy
Get suggested recovery strategy
Trait Implementations§
Source§impl Clone for TensorError
impl Clone for TensorError
Source§fn clone(&self) -> TensorError
fn clone(&self) -> TensorError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TensorError
impl Debug for TensorError
Source§impl Display for TensorError
impl Display for TensorError
Source§impl Error for TensorError
impl Error for TensorError
1.30.0 · 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()
Source§impl From<Error> for TensorError
Convert from std::fmt::Error to TensorError
impl From<Error> for TensorError
Convert from std::fmt::Error to TensorError
Source§impl From<ShapeError> for TensorError
Convert from scirs2_core::ndarray::ShapeError to TensorError
impl From<ShapeError> for TensorError
Convert from scirs2_core::ndarray::ShapeError to TensorError
Source§fn from(err: ShapeError) -> Self
fn from(err: ShapeError) -> Self
Auto Trait Implementations§
impl Freeze for TensorError
impl RefUnwindSafe for TensorError
impl Send for TensorError
impl Sync for TensorError
impl Unpin for TensorError
impl UnsafeUnpin for TensorError
impl UnwindSafe for TensorError
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more