Skip to main content

Error

Enum Error 

pub enum Error {
Show 26 variants Validation { op: &'static str, phase: ErrorPhase, source: ValidationError, }, MissingInput(String), NonScalarGrad { shape: Vec<usize>, }, Unsupported { op: &'static str, phase: ErrorPhase, message: String, }, TensorRuntime(Error), Extension { op: &'static str, phase: ErrorPhase, family: &'static str, kind: ErrorKind, source: Box<dyn Error + Send + Sync>, }, RuntimeState { op: &'static str, phase: ErrorPhase, message: String, }, RuntimeStateSource { op: &'static str, phase: ErrorPhase, source: Box<dyn Error + Send + Sync>, }, WithSuppressed { primary: Box<Error>, suppressed: Box<Error>, }, EventDomain { source: EventDomainError, }, UnexpectedBinding { binding_index: usize, }, UnboundPlaceholder { input_key: String, }, GraphInputCountMismatch { expected: usize, actual: usize, }, DuplicateBinding { input_key: String, }, PlaceholderDtypeMismatch { expected: DType, actual: DType, }, PlaceholderShapeMismatch { expected: Vec<usize>, actual: Vec<usize>, }, PlaceholderShapeBoundExceeded { axis: usize, bound: usize, actual: usize, }, PlaceholderRankMismatch { expected: usize, actual: usize, }, ContextMismatch { lhs: ContextId, rhs: ContextId, }, UnsupportedAdRule { transform: &'static str, op: String, }, AdRuleSource { transform: &'static str, source: Box<dyn Error + Send + Sync>, }, ShapeConstraintViolation { family: &'static str, instruction_index: Option<usize>, relation: ShapeRelation, lhs_expr: String, rhs_expr: String, lhs_value: usize, rhs_value: usize, }, ShapeConstraintEvaluation { family: &'static str, instruction_index: Option<usize>, relation: ShapeRelation, expression: String, cause: ShapeConstraintEvalError, }, SymbolicShapeConversion { op: &'static str, phase: ErrorPhase, source: SymDimConversionError, }, ShapeExpressionEvaluation { expression: String, cause: ShapeConstraintEvalError, }, Internal(String),
}
Expand description

Errors produced by einsum, eval, and other tenferro operations.

§Examples

use tenferro_runtime::error::{Error, ErrorPhase};

let err = Error::invalid_argument(
    "einsum",
    ErrorPhase::GraphBuild,
    "subscripts",
    "rank mismatch",
);

Variants§

§

Validation

A shared tensor validation fact, annotated with the runtime phase.

Fields

§op: &'static str

Public operation name.

§phase: ErrorPhase

Phase that discovered the validation fact.

§source: ValidationError

Machine-readable validation payload.

§

MissingInput(String)

A required input tensor is missing from the inputs map.

§

NonScalarGrad

Reverse-mode gradient requires a scalar output.

Fields

§shape: Vec<usize>
§

Unsupported

The operation is known not to support the requested input or configuration at the phase where it was requested.

Fields

§op: &'static str

Operation that does not provide the requested behavior.

§phase: ErrorPhase

Phase that established the unsupported combination.

§message: String

Human-readable unsupported-operation detail.

§

TensorRuntime(Error)

Runtime tensor execution failed in the backend layer.

§

Extension

A typed extension-domain error crossed a runtime registry boundary.

Fields

§op: &'static str

Operation that discovered the extension failure.

§phase: ErrorPhase

Phase that discovered the extension failure.

§family: &'static str

Stable extension family identifier.

§kind: ErrorKind

Coarse classification supplied by the extension owner.

§source: Box<dyn Error + Send + Sync>

Original extension-domain source.

§

RuntimeState

Executor, cache, registry, or device state is unavailable or invalid.

Fields

§op: &'static str

Operation whose state was unavailable.

§phase: ErrorPhase

Phase that discovered the invalid state.

§message: String

Human-readable state detail.

§

RuntimeStateSource

A runtime-state failure retaining a typed source.

Fields

§op: &'static str

Operation whose state was unavailable.

§phase: ErrorPhase

Phase that discovered the invalid state.

§source: Box<dyn Error + Send + Sync>

Typed state source.

§

WithSuppressed

A primary error with a second typed error retained as suppressed metadata.

The standard error source chain follows primary. The suppressed error is intentionally exposed through Error::suppressed because StdError::source can represent only one source without losing the primary error’s semantics.

Fields

§primary: Box<Error>

The operation’s primary failure and the standard error-chain source.

§suppressed: Box<Error>

A typed secondary failure retained for diagnostics and recovery.

§

EventDomain

A runtime event-domain provenance or admission contract failed.

Fields

§source: EventDomainError

Structured event-domain failure with expected/actual provenance.

§

UnexpectedBinding

A TracedTensor supplied as a compiled-graph input binding is not a placeholder (has attached data).

Fields

§binding_index: usize
§

UnboundPlaceholder

A placeholder appearing in the graph has no binding supplied.

Fields

§input_key: String
§

GraphInputCountMismatch

The number of ordered tensors supplied to a compiled graph is invalid.

Fields

§expected: usize
§actual: usize
§

DuplicateBinding

The same placeholder was bound more than once in the bindings slice.

Fields

§input_key: String
§

PlaceholderDtypeMismatch

A binding tensor’s dtype does not match the placeholder’s dtype.

Fields

§expected: DType
§actual: DType
§

PlaceholderShapeMismatch

A binding tensor’s shape does not match an input_concrete_shape placeholder’s fixed shape.

Fields

§expected: Vec<usize>
§actual: Vec<usize>
§

PlaceholderShapeBoundExceeded

A binding tensor dimension exceeds a semantic input’s declared bound.

Fields

§axis: usize

Axis whose runtime extent exceeded the bound.

§bound: usize

Evaluated upper bound.

§actual: usize

Runtime extent.

§

PlaceholderRankMismatch

A binding tensor’s rank does not match an input_symbolic_shape placeholder’s declared rank.

Fields

§expected: usize
§actual: usize
§

ContextMismatch

Operation attempted to mix tensors from different eager contexts.

Fields

§

UnsupportedAdRule

An AD transform requires a primitive or extension rule that is not registered for the requested operation.

Fields

§transform: &'static str

AD transform that requested the rule, such as grad or backward.

§op: String

Operation or extension family identifier that has no applicable rule.

§

AdRuleSource

A typed AD rule source that crossed an external message-only callback.

Fields

§transform: &'static str

AD transform that requested the rule.

§source: Box<dyn Error + Send + Sync>

Original typed source from the AD rule context.

§

ShapeConstraintViolation

A symbolic extension shape equality evaluated to unequal dimensions.

Fields

§family: &'static str

Stable extension family identifier.

§instruction_index: Option<usize>

Stable compiled instruction provenance, when assigned.

§relation: ShapeRelation

Shape relation that failed.

§lhs_expr: String

Normalized left-hand expression.

§rhs_expr: String

Normalized right-hand expression.

§lhs_value: usize

Concrete left-hand value.

§rhs_value: usize

Concrete right-hand value.

§

ShapeConstraintEvaluation

A symbolic extension shape expression could not be evaluated safely.

Fields

§family: &'static str

Stable extension family identifier.

§instruction_index: Option<usize>

Stable compiled instruction provenance, when assigned.

§relation: ShapeRelation

Shape relation whose expression failed.

§expression: String

Normalized expression that failed.

§cause: ShapeConstraintEvalError

Typed evaluation failure.

§

SymbolicShapeConversion

A symbolic dimension could not be converted into the graph’s local dimension-expression vocabulary.

Fields

§op: &'static str

Operation that requested the symbolic shape conversion.

§phase: ErrorPhase

Phase that discovered the invalid symbolic reference.

§source: SymDimConversionError

Typed symbolic-dimension conversion failure.

§

ShapeExpressionEvaluation

A runtime dimension expression could not be evaluated for concrete input shapes.

Fields

§expression: String

Expression that failed during execution.

§cause: ShapeConstraintEvalError

Typed evaluation failure.

§

Internal(String)

An unexpected internal error.

Implementations§

§

impl Error

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

Wrap a shared validation payload with its operation and discovery phase.

§Errors

This constructor does not fail; callers receive the returned Error value and can inspect its Error::kind and Error::phase.

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

let error = Error::validation(
    "reshape",
    ErrorPhase::GraphBuild,
    ShapeMismatch::ReshapeElementCount { from: 2, to: 3 }.into(),
);
assert_eq!(
    error.kind(),
    ErrorKind::Validation(ValidationKind::ShapeMismatch)
);
assert_eq!(error.phase(), Some(ErrorPhase::GraphBuild));

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

Construct a validation error for a caller-controlled argument whose failure does not have a more specific shared payload.

§Examples
use tenferro_runtime::{Error, ErrorPhase};

let error = Error::invalid_argument(
    "broadcast_in_dim",
    ErrorPhase::GraphBuild,
    "dims",
    "dimension mapping has the wrong length",
);
assert!(matches!(error, Error::Validation { .. }));

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

Construct a dtype-mismatch validation error using the runtime dtype vocabulary.

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

let error = Error::dtype_mismatch(
    "add",
    ErrorPhase::GraphBuild,
    DType::F32,
    DType::F64,
);
assert_eq!(error.kind(), ErrorKind::Validation(ValidationKind::DTypeMismatch));

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

Preserve a typed extension-domain source at the runtime boundary.

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

let source = std::io::Error::new(std::io::ErrorKind::Other, "extension failed");
let error = Error::extension(
    "einsum",
    ErrorPhase::GraphBuild,
    "example.extension.v1",
    ErrorKind::RuntimeState,
    source,
);
assert_eq!(error.kind(), ErrorKind::RuntimeState);
assert!(error.source().is_some());

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

Construct a runtime-state failure for an unavailable or invalid executor, cache, registry, or device state.

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

let error = Error::runtime_state(
    "executor",
    ErrorPhase::Execution,
    "the executor is not initialized",
);
assert_eq!(error.kind(), ErrorKind::RuntimeState);

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

Preserve a typed source for an unavailable or invalid runtime state.

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

let error = Error::runtime_state_source(
    "metadata",
    ErrorPhase::Compile,
    std::io::Error::other("registry lock poisoned"),
);
assert_eq!(error.kind(), ErrorKind::RuntimeState);
assert!(error.source().is_some());

pub fn with_suppressed(primary: Error, suppressed: Error) -> Error

Retain a typed secondary error while preserving the primary error’s classification and standard source chain.

§Examples
use tenferro_runtime::{Error, ErrorPhase};

let error = Error::with_suppressed(
    Error::unsupported("backend", ErrorPhase::Execution, "primary"),
    Error::runtime_state("runtime", ErrorPhase::Execution, "suppressed"),
);
assert!(error.primary().is_some());
assert!(error.suppressed().is_some());

pub fn primary(&self) -> Option<&Error>

Return the primary error when this value is a suppressed-error aggregate.

§Examples
use tenferro_runtime::{Error, ErrorPhase};

let error = Error::with_suppressed(
    Error::unsupported("backend", ErrorPhase::Execution, "primary"),
    Error::runtime_state("runtime", ErrorPhase::Execution, "suppressed"),
);
assert_eq!(error.primary().unwrap().phase(), Some(ErrorPhase::Execution));

pub fn suppressed(&self) -> Option<&Error>

Return the typed suppressed error when this value is an aggregate.

§Examples
use tenferro_runtime::{Error, ErrorPhase};

let error = Error::with_suppressed(
    Error::unsupported("backend", ErrorPhase::Execution, "primary"),
    Error::runtime_state("runtime", ErrorPhase::Execution, "suppressed"),
);
assert_eq!(error.suppressed().unwrap().phase(), Some(ErrorPhase::Execution));

pub fn ad_rule_source<E>(transform: &'static str, source: E) -> Error
where E: Error + Send + Sync + 'static,

Preserve a typed source returned by an AD rule through a callback protocol that can carry only a rendered message.

§Examples
use std::error::Error as _;
use tenferro_runtime::Error;

let error = Error::ad_rule_source(
    "jvp",
    std::io::Error::other("shape metadata missing"),
);
assert!(error.source().is_some());

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

Construct an operation-level unsupported error with an explicit discovery phase.

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

let error = Error::unsupported(
    "compare",
    ErrorPhase::Compile,
    "complex values have no total order",
);
assert_eq!(error.kind(), ErrorKind::Unsupported);
assert_eq!(error.phase(), Some(ErrorPhase::Compile));

pub fn kind(&self) -> ErrorKind

Return the stable coarse classification of this runtime failure.

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

let error = Error::validation(
    "transpose",
    ErrorPhase::GraphBuild,
    ValidationError::AxisOutOfBounds { axis: 2, rank: 2 },
);
assert_eq!(error.kind(), ErrorKind::Validation(ValidationKind::AxisOutOfBounds));

pub fn phase(&self) -> Option<ErrorPhase>

Return the discovery phase when this error has one.

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

let error = Error::validation(
    "reshape",
    ErrorPhase::Compile,
    ValidationError::RankMismatch { expected: 2, actual: 1 },
);
assert_eq!(error.phase(), Some(ErrorPhase::Compile));

Trait Implementations§

§

impl Debug for Error

§

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

Formats the value using the given formatter. Read more
§

impl Display for Error

§

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

Formats the value using the given formatter. Read more
§

impl Error for Error

§

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
§

impl From<Error> for Error

§

fn from(source: Error) -> Error

Converts to this type from the input type.
§

impl From<EventDomainError> for Error

§

fn from(source: EventDomainError) -> Error

Converts to this type from the input type.

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
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

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, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

§

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,