Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for half-precision (16-bit) floating-point datasets #587

Merged
merged 5 commits into from Jun 8, 2022
Merged

Support for half-precision (16-bit) floating-point datasets #587

merged 5 commits into from Jun 8, 2022

Conversation

ssbotelh
Copy link
Contributor

@ssbotelh ssbotelh commented Jun 4, 2022

Description

Although 16-bit float is not a native C++ type, it is widely used to save runtime and disk space in situations where high precision is not needed, most notably in deep-learning applications. Python's h5py trivially supports the creation of float16 datasets (type "<f2"). This PR adds optional support for half-precision in HighFive.

Code change summary

  • The main code change is in include/highfive/bits/H5DataType_misc.hpp, where the AtomicType constructor was specialized for float16_t
  • The type list numerical_test_types was augmented by adding float16_t (if enabled)
  • Added example code create_dataset_half_float.cpp in src/examples
  • A few makefile changes

How to test this?

Download the (single-header) Half library from http://half.sourceforge.net/, and copy half.hpp into /usr/local/include/.
Then build and run unit tests:

cmake .. -DHIGHFIVE_USE_HALF_FLOAT=ON
make -j8
make test

You should see tests with numerical_test_types - 13, which corresponds to float16_t

Test System

  • OS: Ubuntu 18.04
  • Compiler: GNU g++ 10.3.0
  • Dependency versions: tested with HDF5 1.10.5, boost 1.65.1, and Half 2.2.0

@alkino
Copy link
Member

alkino commented Jun 8, 2022

clang-format is version 12 here: https://github.com/BlueBrain/HighFive#code-formatting

@matz-e
Copy link
Member

matz-e commented Jun 8, 2022

clang-format is version 12 here: https://github.com/BlueBrain/HighFive#code-formatting

#588 begs to differ.

Copy link
Member

@matz-e matz-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for all the work!

@codecov-commenter
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@f3ce0be). Click here to learn what that means.
The diff coverage is n/a.

@@            Coverage Diff            @@
##             master     #587   +/-   ##
=========================================
  Coverage          ?   80.57%           
=========================================
  Files             ?       66           
  Lines             ?     3572           
  Branches          ?        0           
=========================================
  Hits              ?     2878           
  Misses            ?      694           
  Partials          ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f3ce0be...051c25f. Read the comment docs.

@alkino alkino merged commit b2f49c0 into BlueBrain:master Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants