Giter Site home page Giter Site logo

ebell495 / half-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from starkat99/half-rs

0.0 0.0 0.0 349 KB

Half-precision floating point types f16 and bf16 for Rust.

Home Page: https://docs.rs/half/

License: Other

Rust 99.90% Dockerfile 0.10%

half-rs's Introduction

f16 and bf16 floating point types for Rust

Crates.io Documentation Crates.io Build status

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 are done as an f32 type under the hood. Complex arithmetic should manually convert to and from f32 for better performance.

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.58 or greater. If you need support for older versions of Rust, use 1.x versions of this crate.

See the crate documentation for more details.

Optional Features

  • serde - Implement Serialize and Deserialize traits for f16 and bf16. This adds a dependency on the serde crate.

  • use-intrinsics - Use hardware intrinsics for f16 and bf16 conversions 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 the alloc crate when not using the std library.

    This enables the vec module, which contains zero-copy conversions for the Vec type. This allows fast conversion between raw Vec<u16> bits and Vec<f16> or Vec<bf16> arrays, and vice versa.

  • std - Enable features that depend on the Rust std library, including everything in the alloc feature.

    Enabling the std feature enables runtime CPU feature detection when the use-intrsincis feature is also enabled. Without this feature detection, intrinsics are only used when compiler host target supports them.

  • num-traits - Enable ToPrimitive, FromPrimitive, Num, Float, FloatCore and Bounded trait implementations from the num-traits crate.

  • bytemuck - Enable Zeroable and Pod trait implementations from the bytemuck crate.

  • zerocopy - Enable AsBytes and FromBytes trait implementations from the zerocopy crate.

More Documentation

License

This library is distributed under the terms of either of:

at your option.

This project is REUSE-compliant. Copyrights are retained by their contributors. Some files may include explicit copyright notices and/or license SPDX identifiers. For full authorship information, see the version control history.

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.

half-rs's People

Contributors

starkat99 avatar tspiteri avatar charles-r-earp avatar johannesvollmer avatar samcrow avatar gyunghee-park avatar ma2bd avatar noratrieb avatar pthariensflame avatar bzm3r avatar jfrimmel avatar kali avatar pseitz avatar klosspeter avatar sylvestre avatar fogti avatar ebell495 avatar joseluis avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.