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

RFC 100 text: Add RFC for float16 support #10146

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

eschnett
Copy link
Contributor

@eschnett eschnett commented Jun 6, 2024

See #10144.

@rouault
Copy link
Member

rouault commented Jun 6, 2024

@eschnett Once you're happy with the RFC, it would also be appropriate to mention it by an email to the gdal-dev mailing list (https://lists.osgeo.org/pipermail/gdal-dev/). Cf https://lists.osgeo.org/pipermail/gdal-dev/2024-February/058548.html for an example.
Typically the RFC lifecycle is:

@eschnett
Copy link
Contributor Author

eschnett commented Jun 6, 2024

Thinking about automatically converting float16 to float32 a bit more: I think it would be confusing to choose GDAL's behaviour in this respect on which compiler flags and versions were used to build GDAL. It would probably be better to make GDAL be consistent – it should either always automatically convert to float32, or never do that automatically. And given the current behaviour, it would be quite inconvenient if one was suddenly presented with a float16 dataset.

Maybe there should be a new flag, passed to GDAL when opening a dataset, that specifies whether float16 data should be automatically converted to float32 (the default setting), or should be preserved as float16?

@rouault
Copy link
Member

rouault commented Jun 6, 2024

Thinking about automatically converting float16 to float32 a bit more: I think it would be confusing to choose GDAL's behaviour in this respect on which compiler flags and versions were used to build GDAL

That's a good point. To give some perspective: in the past when we have introduced GDT_Int64 and GDT_UInt64, before their addition, the Zarr driver automatically exposed arrays with those types as Float64, as that was the closest (somewhat) compatible available data type. And we didn't add an option to allow int64/uint64 to be presented when we added those types. That was documented as a change with some breaking potential in the MIGRATION_GUIDE.TXT file. Similarly when GDT_Int8 has been introduced, such data type was handled in a very clumsy way before (it was presented as unsigned byte + a metadata item saying "actually it is signed"). After the change, those datasets were returned with the new type. So the practice up to now has been to adopt the new data type. I think it would be fine to do the same here, that is when the GDAL build has _Float16 support and the dataset is Float16, then use GDT_Float16 as the declared data type. Float16 datasets are sufficiently esoteric (at least that's my perspective) that it is likely acceptable to do so.
Having a specific flag to allow/disable Float16 adds some long term complications in GDAL internals (also probably minor given that drivers having Float16 capabilities still need to handle both exposing as Float16 or promotion to Float32 depending on if the GDAL build as Float16 capabilities). Also to be noted that the HDF5 library, when built with Float16 support, automatically uses it by default (which broke GDAL which didn't expect this new data type, but I found that acceptable)

@rouault
Copy link
Member

rouault commented Jun 27, 2024

@eschnett not sure what your plans are, but at that point, I believe that working on a candidate implementation would be the appropriate step forward

@eschnett
Copy link
Contributor Author

@rouault I have an implementation but got stuck writing tests. It turns out to be difficult to test from Python because SWIG doesn't support Float16. I was looking into some C++ tests but got sidetracked by another project. I'll push my current state.

Any preference whether this should be a separate PR from the one with the RFC?

@rouault
Copy link
Member

rouault commented Jun 27, 2024

Thanks for the update. No rush, just wanted to know how things were progressing

because SWIG doesn't support Float16.

is it itself an issue? I don't anticipate a lot of GDAL API methods to actually return Float16 scalars. Most Float16 specific tests should be around RasterIO(), and RasterIO() at the SWIG level is handle by the swig/include/python specifics (and swig/include/gdal_array.i) with dedicate C wrapping code and Python code.

Any preference whether this should be a separate PR from the one with the RFC?

yes, the candidate implementation would be better into a separate PR

Copy link

The GDAL project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 28 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular link
    to any issues which this pull request fixes

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in 2 weeks.

@github-actions github-actions bot added the stale label Jul 26, 2024
Copy link

github-actions bot commented Aug 9, 2024

While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 6 weeks. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the GDAL project can do to help push this PR forward please let us know how we can assist.

@github-actions github-actions bot closed this Aug 9, 2024
@eschnett
Copy link
Contributor Author

eschnett commented Aug 9, 2024

Just leaving a comment here – yes, I am still interested in this, and I am still working on it, but there's another higher-priority project taking up my time at the moment.

@rouault rouault reopened this Aug 10, 2024
@stale stale bot removed the stale label Aug 10, 2024
Copy link

github-actions bot commented Sep 8, 2024

The GDAL project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 28 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular link
    to any issues which this pull request fixes

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in 2 weeks.

@github-actions github-actions bot added the stale label Sep 8, 2024
Copy link

While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 6 weeks. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the GDAL project can do to help push this PR forward please let us know how we can assist.

@github-actions github-actions bot closed this Sep 23, 2024
@rouault
Copy link
Member

rouault commented Sep 23, 2024

(keep alive)

@rouault rouault reopened this Sep 23, 2024
@github-actions github-actions bot removed the stale label Sep 24, 2024
Copy link

The GDAL project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 28 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular link
    to any issues which this pull request fixes

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in 2 weeks.

@github-actions github-actions bot added the stale label Oct 23, 2024
@rouault
Copy link
Member

rouault commented Oct 23, 2024

(keep alive)

@rouault rouault changed the title Add RFC for float16 support RFC 100 text: Add RFC for float16 support Nov 7, 2024
MIGRATION_GUIDE.TXT Outdated Show resolved Hide resolved
-------

This RFC adds support for the IEEE 16-bit floating point data type
(aka ``half``, ``float16``). It adds new pixel data types
Copy link
Member

Choose a reason for hiding this comment

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

What is this two back quote style?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A double backquote is rendered as "code" style, similar to a single backquote in Github markdown. I've taken it from RFC 99.

doc/source/development/rfc/rfc100_float16_support.rst Outdated Show resolved Hide resolved
doc/source/development/rfc/rfc100_float16_support.rst Outdated Show resolved Hide resolved
@rouault
Copy link
Member

rouault commented Nov 7, 2024

For the remaining spelling issues (once you've americanized behaviour->behavior), you can add suppressions like in

.. below is an allow-list for spelling checker.

routines. This type should be supported without converting to
float32.

- C++23 will introduce native support for ``std::float16_t``. However,
Copy link
Member

Choose a reason for hiding this comment

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

eschnett#1 is an attempt of aliasing GFloat16 on std::float16_t if it is available

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I'll probably merge it and then hash out the details.

Copy link
Member

Choose a reason for hiding this comment

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

Once the RFC text has been updated taking into account above to reflect how C++23 std::float16_t will be handled, I'd be happy to give my +1 to the RFC.

Copy link
Member

Choose a reason for hiding this comment

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

Woohoo! Thank you both! I'm the same as Even for a +1.

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.

3 participants