Skip to main content

TensorElement

Trait TensorElement 

Source
pub trait TensorElement:
    Sized
    + Default
    + Clone
    + 'static {
    const DTYPE: DType;
    const SIZE: usize = _;
}
Expand description

Trait for types that can be safely read from tensor byte data.

Each implementing type declares its corresponding DType at compile time. Implemented for f32, f64, i8i64, u8u64, bool, half::f16, and half::bf16.

§Examples

use ztensor::TensorElement;
use ztensor::DType;

assert_eq!(f32::DTYPE, DType::F32);
assert_eq!(f32::SIZE, 4);
assert_eq!(u8::DTYPE, DType::U8);

Required Associated Constants§

Source

const DTYPE: DType

The DType that corresponds to this Rust type.

Provided Associated Constants§

Source

const SIZE: usize = _

Size of one element in bytes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl TensorElement for bool

Source§

const DTYPE: DType = DType::Bool

Source§

impl TensorElement for f32

Source§

const DTYPE: DType = DType::F32

Source§

impl TensorElement for f64

Source§

const DTYPE: DType = DType::F64

Source§

impl TensorElement for i8

Source§

const DTYPE: DType = DType::I8

Source§

impl TensorElement for i16

Source§

const DTYPE: DType = DType::I16

Source§

impl TensorElement for i32

Source§

const DTYPE: DType = DType::I32

Source§

impl TensorElement for i64

Source§

const DTYPE: DType = DType::I64

Source§

impl TensorElement for u8

Source§

const DTYPE: DType = DType::U8

Source§

impl TensorElement for u16

Source§

const DTYPE: DType = DType::U16

Source§

impl TensorElement for u32

Source§

const DTYPE: DType = DType::U32

Source§

impl TensorElement for u64

Source§

const DTYPE: DType = DType::U64

Source§

impl TensorElement for bf16

Source§

const DTYPE: DType = DType::BF16

Source§

impl TensorElement for f16

Source§

const DTYPE: DType = DType::F16

Implementors§