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, i8–i64, u8–u64, 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§
Provided Associated Constants§
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.