[−][src]Trait half::vec::HalfFloatVecExt
Extensions to Vec<f16>
and Vec<bf16>
to support reinterpret operations.
This trait is sealed and cannot be implemented outside of this crate.
Required methods
pub fn reinterpret_into(self) -> Vec<u16>
[src]
Reinterpret a vector of f16
or bf16
numbers as a vector of u16
bits.
This is a zero-copy operation. The reinterpreted vector has the same memory location as
self
.
Examples
let float_buffer = vec![f16::from_f32(1.), f16::from_f32(2.), f16::from_f32(3.)]; let int_buffer = float_buffer.reinterpret_into(); assert_eq!(int_buffer, [f16::from_f32(1.).to_bits(), f16::from_f32(2.).to_bits(), f16::from_f32(3.).to_bits()]);
pub fn from_f32_slice(slice: &[f32]) -> Self
[src]
Convert all of the elements of a [f32]
slice into a new f16
or
bf16
vector.
The conversion operation is vectorized over the slice, meaning the conversion may be more efficient than converting individual elements on some hardware that supports SIMD conversions. See crate documentation for more information on hardware conversion support.
Examples
let float_values = [1., 2., 3., 4.]; let vec: Vec<f16> = Vec::from_f32_slice(&float_values); assert_eq!(vec, vec![f16::from_f32(1.), f16::from_f32(2.), f16::from_f32(3.), f16::from_f32(4.)]);
pub fn from_f64_slice(slice: &[f64]) -> Self
[src]
Convert all of the elements of a [f64]
slice into a new f16
or
bf16
vector.
The conversion operation is vectorized over the slice, meaning the conversion may be more efficient than converting individual elements on some hardware that supports SIMD conversions. See crate documentation for more information on hardware conversion support.
Examples
let float_values = [1., 2., 3., 4.]; let vec: Vec<f16> = Vec::from_f64_slice(&float_values); assert_eq!(vec, vec![f16::from_f64(1.), f16::from_f64(2.), f16::from_f64(3.), f16::from_f64(4.)]);