|
|
||
|---|---|---|
| .. | ||
| benches | ||
| src | ||
| tests | ||
| .cargo_vcs_info.json | ||
| .gitattributes | ||
| Android.bp | ||
| CHANGELOG.md | ||
| Cargo.toml | ||
| Cargo.toml.orig | ||
| LICENSE | ||
| LICENSE-APACHE | ||
| LICENSE-MIT | ||
| METADATA | ||
| MODULE_LICENSE_APACHE2 | ||
| OWNERS | ||
| README.md | ||
| TEST_MAPPING | ||
| cargo2android.json | ||
README.md
f16 and bf16 floating point types for Rust
This crate implements a half-precision floating point f16 type for Rust implementing the IEEE 754-2008 standard
binary16 a.k.a half format,
as well as a bf16 type implementing the bfloat16 format.
Usage
The f16 and bf16 types provides conversion operations as a normal Rust floating point type, but since they are primarily leveraged for
minimal floating point storage and most major hardware does not implement them, all math operations should be done as an f32 type.
This crate provides no_std support by default so can easily be used in embedded
code where a smaller float format is most useful.
Requires Rust 1.32 or greater. If you need support for older versions of Rust, use versions 1.3 and earlier of this crate.
See the crate documentation for more details.
Optional Features
-
serde- ImplementSerializeandDeserializetraits forf16andbf16. This adds a dependency on theserdecrate. -
use-intrinsics- Use hardware intrinsics forf16andbf16conversions if available on the compiler host target. By default, without this feature, conversions are done only in software, which will be the fallback if the host target does not have hardware support. Available only on Rust nightly channel. -
alloc- Enable use of thealloccrate when not using thestdlibrary.This enables the
vecmodule, which contains zero-copy conversions for theVectype. This allows fast conversion between rawVec<u16>bits andVec<f16>orVec<bf16>arrays, and vice versa. Requires Rust 1.36 or greater. -
std- Enable features that depend on the Ruststdlibrary, including everything in theallocfeature.Enabling the
stdfeature enables runtime CPU feature detection when theuse-intrsincisfeature is also enabled. Without this feature detection, intrinsics are only used when compiler host target supports them. -
num-traits- EnableToPrimitiveandFromPrimitivetrait implementations from thenum-traitscrate. -
bytemuck- EnableZeroableandPodtrait implementations from thebytemuckcrate.
More Documentation
License
This library is distributed under the terms of either of:
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
at your option.
Contributing
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.