Skip to main content

MixedPrecisionSupport

Trait MixedPrecisionSupport 

Source
pub trait MixedPrecisionSupport: ArrayProtocol {
    // Required methods
    fn to_precision(
        &self,
        precision: Precision,
    ) -> CoreResult<Box<dyn MixedPrecisionSupport>>;
    fn precision(&self) -> Precision;
    fn supports_precision(&self, precision: Precision) -> bool;
    fn as_array_protocol(&self) -> &dyn ArrayProtocol;
}
Expand description

Trait for arrays that support mixed-precision operations.

Required Methods§

Source

fn to_precision( &self, precision: Precision, ) -> CoreResult<Box<dyn MixedPrecisionSupport>>

Convert the array to the specified precision.

Source

fn precision(&self) -> Precision

Get the current precision of the array.

Source

fn supports_precision(&self, precision: Precision) -> bool

Check if the array supports the specified precision.

Source

fn as_array_protocol(&self) -> &dyn ArrayProtocol

Borrow this value as an ArrayProtocol trait object.

MixedPrecisionSupport has ArrayProtocol as a supertrait, but on stable Rust a &dyn MixedPrecisionSupport cannot be upcast to &dyn ArrayProtocol without the unstable trait_upcasting feature (RFC #65991). This method provides that bridge explicitly: every implementor already is an ArrayProtocol, so the default implementation simply returns self.

This allows mixed-precision arrays to be passed to operations that are generic over &dyn ArrayProtocol (such as those in crate::array_protocol::operations) on stable Rust.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T, D> MixedPrecisionSupport for GPUNdarray<T, D>
where T: Clone + Float + Send + Sync + 'static + Zero + Div<f64, Output = T>, D: Dimension + Send + Sync + 'static + RemoveAxis,

Implement MixedPrecisionSupport for GPUNdarray.

Source§

impl<T, D> MixedPrecisionSupport for MixedPrecisionArray<T, D>
where T: Clone + Float + Send + Sync + 'static, D: Dimension + Send + Sync + 'static,

Implement MixedPrecisionSupport for MixedPrecisionArray.