Trait BackendPrimitive
pub trait BackendPrimitive<B>where
B: Backend,{
type Primitive;
// Required methods
fn try_into_primitive(
tensor: BackendTensor<B>,
) -> Result<Self::Primitive, PrimitiveConversionError>;
fn from_primitive(primitive: Self::Primitive) -> BackendTensor<B>;
}Expand description
Trait to safely extract and wrap backend-specific primitives based on the high-level tensor kind.
This trait functions as a type-level map linking frontend kinds (Float, Int, Bool)
to their corresponding backend-associated types (B::FloatTensorPrimitive, B::IntTensorPrimitive, etc.).
Required Associated Types§
type Primitive
type Primitive
The backend tensor primitive.
Required Methods§
fn try_into_primitive(
tensor: BackendTensor<B>,
) -> Result<Self::Primitive, PrimitiveConversionError>
fn try_into_primitive( tensor: BackendTensor<B>, ) -> Result<Self::Primitive, PrimitiveConversionError>
Attempts to unpack the type-erased BackendTensor enum wrapper into the concrete
variant expected by this kind.
§Errors
Returns an error if there is a variant type mismatch (e.g., attempting to extract an
Int primitive out of a BackendTensor::Float enum variant).
fn from_primitive(primitive: Self::Primitive) -> BackendTensor<B>
fn from_primitive(primitive: Self::Primitive) -> BackendTensor<B>
Wraps a backend tensor primitive into its corresponding BackendTensor enum variant.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".