Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 13 variants Validation { op: &'static str, source: ValidationError, }, UnsupportedDTypeConversion { op: &'static str, from: DType, to: DType, message: String, }, UnsupportedDType { op: &'static str, dtype: DType, message: String, }, Unsupported { op: &'static str, message: String, }, BackendFailure { op: &'static str, message: String, }, BackendSource { op: &'static str, source: BoxError, }, IoSource { op: &'static str, source: BoxError, }, RuntimeState { op: &'static str, message: String, }, RuntimeStateSource { op: &'static str, source: BoxError, }, HostAccess { op: &'static str, source: HostAccessError, }, Extension { op: &'static str, family: &'static str, kind: ErrorKind, source: BoxError, }, MissingValue { slot: usize, }, Internal(String),
}
Expand description

Runtime failures produced by tensor execution backends and helpers.

Validation failures retain the shared tensor-core payload as a typed source. Backend and extension failures retain opaque typed sources when one exists; text-only vendor failures use Error::BackendFailure.

§Examples

let error = tenferro_tensor::Error::rank_mismatch("reshape", 2, 1);
assert!(matches!(
    error,
    tenferro_tensor::Error::Validation { op: "reshape", .. }
));

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Validation

Fields

§op: &'static str
§

UnsupportedDTypeConversion

Fields

§op: &'static str
§from: DType
§message: String
§

UnsupportedDType

Fields

§op: &'static str
§dtype: DType
§message: String
§

Unsupported

Fields

§op: &'static str
§message: String
§

BackendFailure

Fields

§op: &'static str
§message: String
§

BackendSource

Fields

§op: &'static str
§source: BoxError
§

IoSource

Fields

§op: &'static str
§source: BoxError
§

RuntimeState

Fields

§op: &'static str
§message: String
§

RuntimeStateSource

Fields

§op: &'static str
§source: BoxError
§

HostAccess

Fields

§op: &'static str
§

Extension

Fields

§op: &'static str
§family: &'static str
§source: BoxError
§

MissingValue

Fields

§slot: usize
§

Internal(String)

Implementations§

Source§

impl Error

Source

pub fn shape_mismatch( op: &'static str, lhs: impl Into<Vec<usize>>, rhs: impl Into<Vec<usize>>, ) -> Self

Construct an incompatible-shapes validation error.

§Examples
use tenferro_tensor::Error;

let error = Error::shape_mismatch("add", [2, 3], [2, 4]);
assert!(matches!(error, Error::Validation { .. }));
Source

pub fn rank_mismatch(op: &'static str, expected: usize, actual: usize) -> Self

Construct a rank-mismatch validation error.

§Examples
use tenferro_tensor::Error;

let error = Error::rank_mismatch("transpose", 2, 3);
assert!(matches!(error, Error::Validation { .. }));
Source

pub fn axis_out_of_bounds(op: &'static str, axis: usize, rank: usize) -> Self

Construct an axis-out-of-bounds validation error.

§Examples
use tenferro_tensor::Error;

let error = Error::axis_out_of_bounds("sum", 2, 2);
assert!(matches!(error, Error::Validation { .. }));
Source

pub fn duplicate_axis(op: &'static str, axis: usize, role: &'static str) -> Self

Construct a duplicate-axis validation error.

§Examples
use tenferro_tensor::Error;

let error = Error::duplicate_axis("transpose", 1, "permutation");
assert!(matches!(error, Error::Validation { .. }));
Source

pub fn dtype_mismatch(op: &'static str, expected: DType, actual: DType) -> Self

Construct a dtype-mismatch validation error.

§Examples
use tenferro_tensor::{DType, Error};

let error = Error::dtype_mismatch("add", DType::F32, DType::F64);
assert!(matches!(error, Error::Validation { .. }));
Source

pub fn validation(op: &'static str, source: ValidationError) -> Self

Wrap shared tensor validation with the operation that requested it.

§Examples
use tenferro_tensor::{Error, ValidationError};

let error = Error::validation(
    "transpose",
    ValidationError::AxisOutOfBounds { axis: 2, rank: 2 },
);
assert!(matches!(error, Error::Validation { op: "transpose", .. }));
Source

pub fn invalid_argument( op: &'static str, argument: &'static str, message: impl Into<String>, ) -> Self

Construct a structured invalid-argument validation error.

§Examples
use tenferro_tensor::{Error, ErrorKind, ValidationKind};

let error = Error::invalid_argument("slice", "step", "must be non-zero");
assert_eq!(error.kind(), ErrorKind::Validation(ValidationKind::InvalidArgument));
Source

pub fn unsupported_dtype_conversion( op: &'static str, from: DType, to: DType, message: impl Into<String>, ) -> Self

Construct an unsupported dtype conversion error.

§Examples
let error = tenferro_tensor::Error::unsupported_dtype_conversion(
    "convert",
    tenferro_tensor::DType::F64,
    tenferro_tensor::DType::I32,
    "lossy conversion is disabled",
);
assert!(matches!(
    error,
    tenferro_tensor::Error::UnsupportedDTypeConversion { .. }
));
Source

pub fn unsupported_dtype( op: &'static str, dtype: DType, message: impl Into<String>, ) -> Self

Construct an operation-level unsupported-dtype error.

This is for an operation that cannot run for the supplied dtype. It is deliberately distinct from Error::unsupported_dtype_conversion, which is reserved for an actual from-dtype to to-dtype conversion.

§Examples
let error = tenferro_tensor::Error::unsupported_dtype(
    "exp",
    tenferro_tensor::DType::I64,
    "integer exponentials are not implemented",
);
assert!(matches!(
    error,
    tenferro_tensor::Error::UnsupportedDType {
        op: "exp",
        dtype: tenferro_tensor::DType::I64,
        ..
    }
));
Source

pub fn unsupported(op: &'static str, message: impl Into<String>) -> Self

Construct a structured unsupported-operation error.

Use this for an operation or execution surface that is not implemented by the selected backend. Dtype conversion failures use Error::unsupported_dtype_conversion instead, and operation-specific typed reasons should use Error::extension with ErrorKind::Unsupported.

§Examples
let error = tenferro_tensor::Error::unsupported(
    "full_piv_lu",
    "backend has no implementation",
);
assert!(matches!(
    error,
    tenferro_tensor::Error::Unsupported { op: "full_piv_lu", .. }
));
Source

pub fn backend_failure(op: &'static str, message: impl Into<String>) -> Self

Construct a text-only backend failure.

Use Error::backend_source when a typed source is available.

§Examples
let error = tenferro_tensor::Error::backend_failure(
    "matmul",
    "backend rejected launch",
);
assert!(matches!(
    error,
    tenferro_tensor::Error::BackendFailure { op: "matmul", .. }
));
Source

pub fn backend_source<E>(op: &'static str, source: E) -> Self
where E: StdError + Send + Sync + 'static,

Construct a backend failure while preserving its typed source.

§Examples
let error = tenferro_tensor::Error::backend_source(
    "load",
    std::io::Error::other("read failed"),
);
assert!(std::error::Error::source(&error).is_some());
Source

pub fn io_source<E>(op: &'static str, source: E) -> Self
where E: StdError + Send + Sync + 'static,

Construct an I/O failure while preserving its typed source.

I/O errors are intentionally separate from backend failures: callers can classify them as ErrorKind::Io without parsing a message.

§Examples
use tenferro_tensor::{Error, ErrorKind};

let error = Error::io_source("load", std::io::Error::other("read failed"));
assert_eq!(error.kind(), ErrorKind::Io);
assert!(std::error::Error::source(&error).is_some());
Source

pub fn runtime_state(op: &'static str, message: impl Into<String>) -> Self

Construct a runtime-state failure when no typed source exists.

Use this for missing, uninitialized, or invalid execution state. It is distinct from Error::backend_failure, which is reserved for vendor/backend status text.

§Examples
use tenferro_tensor::{Error, ErrorKind};

let error = Error::runtime_state("execute", "backend session is not initialized");
assert_eq!(error.kind(), ErrorKind::RuntimeState);
Source

pub fn runtime_state_source<E>(op: &'static str, source: E) -> Self
where E: StdError + Send + Sync + 'static,

Construct a runtime-state failure while preserving a typed source.

§Examples
use tenferro_tensor::{Error, ErrorKind};

let error = Error::runtime_state_source(
    "execute",
    std::io::Error::other("executor lock poisoned"),
);
assert_eq!(error.kind(), ErrorKind::RuntimeState);
assert!(std::error::Error::source(&error).is_some());
Source

pub fn extension<E>( op: &'static str, family: &'static str, kind: ErrorKind, source: E, ) -> Self
where E: StdError + Send + Sync + 'static,

Construct an extension failure while preserving its typed source and coarse classification.

§Examples
use std::error::Error as _;
use tenferro_tensor::{Error, ErrorKind};

let error = Error::extension(
    "einsum",
    "einsum",
    ErrorKind::Internal,
    std::io::Error::other("planner failed"),
);
assert!(error.source().is_some());
Source

pub fn host_access(op: &'static str, source: HostAccessError) -> Self

Preserve a typed guarded-host-access failure.

§Examples
use tenferro_tensor::{Error, HostAccessError};

let error = Error::host_access(
    "map",
    HostAccessError::Unsupported { backend: "opaque" },
);
assert!(matches!(error, Error::HostAccess { .. }));
Source

pub fn kind(&self) -> ErrorKind

Return the stable coarse classification for this tensor failure.

§Examples
use tenferro_tensor::{Error, ErrorKind, ValidationError, ValidationKind};
use tenferro_tensor::core::DType;

let error = Error::validation(
    "add",
    ValidationError::DTypeMismatch {
        expected: DType::F32,
        actual: DType::F64,
    },
);
assert_eq!(error.kind(), ErrorKind::Validation(ValidationKind::DTypeMismatch));

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

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

Auto Trait Implementations§

§

impl Freeze 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> 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> 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
§

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

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,

§

impl<T> MaybeSync for T
where T: Sync,