Skip to main content

Scalar

Trait Scalar 

Source
pub trait Scalar:
    Copy
    + Send
    + Sync
    + 'static {
    // Required method
    fn to_f32(&self) -> f32;
}
Expand description

A scalar value usable in tensors. Every scalar projects to f32 for cross-backend interop.

Backends pick their own concrete scalar set; the framework ships universal primitive impls for f32 + f64 only. Concrete backends may add impls for i32, i64, u32, u64, bool, f16 (bf16, fp8 variants), etc.

Required Methods§

Source

fn to_f32(&self) -> f32

Projection to f32. Lossy for wider types (f64, i64); faithful for f32 + smaller integers.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Scalar for f32

Source§

fn to_f32(&self) -> f32

Source§

impl Scalar for f64

Source§

fn to_f32(&self) -> f32

Implementors§