Skip to main content

TensorError

Enum TensorError 

Source
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

Fields

§operation: String
§expected: String
§

DeviceMismatch

Fields

§operation: String
§device1: String
§device2: String
§

UnsupportedDevice

Fields

§operation: String
§device: String
§fallback_available: bool
§

InvalidShape

Fields

§operation: String
§reason: String
§shape: Option<Vec<usize>>
§

InvalidAxis

Fields

§operation: String
§axis: i32
§ndim: usize
§

GradientNotEnabled

Fields

§operation: String
§suggestion: String
§

InvalidArgument

Fields

§operation: String
§reason: String
§

AllocationError

Fields

§operation: String
§details: String
§requested_bytes: Option<usize>
§available_bytes: Option<usize>
§

UnsupportedOperation

Fields

§operation: String
§reason: String
§alternatives: Vec<String>
§

DeviceError

Fields

§operation: String
§details: String
§device: String
§

ComputeError

Fields

§operation: String
§details: String
§retry_possible: bool
§

SerializationError

Fields

§operation: String
§details: String
§

NotImplemented

Fields

§operation: String
§details: String
§planned_version: Option<String>
§

InvalidOperation

Fields

§operation: String
§reason: String
§

BenchmarkError

Fields

§operation: String
§details: String
§

IoError

Fields

§operation: String
§details: String
§

NumericalError

Fields

§operation: String
§details: String
§suggestions: Vec<String>
§

ResourceExhausted

Fields

§operation: String
§resource: String
§current_usage: Option<usize>
§limit: Option<usize>
§

Timeout

Fields

§operation: String
§duration_ms: u64
§

CacheError

Fields

§operation: String
§details: String
§recoverable: bool
§

Other

Fields

§operation: String
§details: String

Implementations§

Source§

impl TensorError

Source

pub fn shape_mismatch(operation: &str, expected: &str, got: &str) -> Self

Create a shape mismatch error with context

Source

pub fn device_mismatch(operation: &str, device1: &str, device2: &str) -> Self

Create a device mismatch error with context

Source

pub fn unsupported_device( operation: &str, device: &str, fallback_available: bool, ) -> Self

Create an unsupported device error with fallback information

Source

pub fn allocation_error( operation: &str, details: &str, requested: Option<usize>, available: Option<usize>, ) -> Self

Create an allocation error with memory information

Source

pub fn numerical_error( operation: &str, details: &str, suggestions: Vec<String>, ) -> Self

Create a numerical error with suggestions

Source

pub fn invalid_argument(reason: String) -> Self

Create an invalid argument error (for backward compatibility)

Source

pub fn invalid_argument_op(operation: &str, reason: &str) -> Self

Create an invalid argument error with operation context

Source

pub fn other(details: String) -> Self

Create a generic “other” error (for backward compatibility)

Source

pub fn other_op(operation: &str, details: &str) -> Self

Create a generic “other” error with operation context

Source

pub fn allocation_error_simple(details: String) -> Self

Create an allocation error (for backward compatibility)

Source

pub fn unsupported_operation_simple(reason: String) -> Self

Create an unsupported operation error (for backward compatibility)

Source

pub fn invalid_shape(operation: &str, expected: &str, got: &str) -> Self

Create an invalid shape error with operation context

Source

pub fn invalid_shape_simple(reason: String) -> Self

Create an invalid shape error (for backward compatibility)

Source

pub fn device_error_simple(details: String) -> Self

Create a device error (for backward compatibility)

Source

pub fn compute_error_simple(details: String) -> Self

Create a compute error (for backward compatibility)

Source

pub fn serialization_error_simple(details: String) -> Self

Create a serialization error (for backward compatibility)

Source

pub fn not_implemented_simple(details: String) -> Self

Create a not implemented error (for backward compatibility)

Source

pub fn invalid_operation_simple(reason: String) -> Self

Create an invalid operation error (for backward compatibility)

Source

pub fn benchmark_error_simple(details: String) -> Self

Create a benchmark error (for backward compatibility)

Source

pub fn io_error_simple(details: String) -> Self

Create an IO error (for backward compatibility)

Source

pub fn resource_exhausted_simple(resource: String) -> Self

Create a resource exhausted error (for backward compatibility)

Source

pub fn timeout_simple(duration_ms: u64) -> Self

Create a timeout error (for backward compatibility)

Source

pub fn with_context(self, context: ErrorContext) -> Self

Add context to an existing error

Source

pub fn operation(&self) -> &str

Get the operation name for this error

Source

pub fn supports_fallback(&self) -> bool

Check if this error supports fallback recovery

Source

pub fn recovery_strategy(&self) -> RecoveryStrategy

Get suggested recovery strategy

Trait Implementations§

Source§

impl Clone for TensorError

Source§

fn clone(&self) -> TensorError

Returns a duplicate 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 TensorError

Source§

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

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

impl Display for TensorError

Source§

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

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

impl Error for TensorError

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<Error> for TensorError

Convert from std::fmt::Error to TensorError

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<ShapeError> for TensorError

Convert from scirs2_core::ndarray::ShapeError to TensorError

Source§

fn from(err: 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> 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<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