Skip to content

promote 8 and 16-bit integer dtypes to float32#7521

Open
grlee77 wants to merge 8 commits intoscikit-image:mainfrom
grlee77:promote-small-ints-to-float32
Open

promote 8 and 16-bit integer dtypes to float32#7521
grlee77 wants to merge 8 commits intoscikit-image:mainfrom
grlee77:promote-small-ints-to-float32

Conversation

@grlee77
Copy link
Copy Markdown
Contributor

@grlee77 grlee77 commented Sep 1, 2024

Description

closes #6310

modifies convert_to_float and _supported_float type to cast small integer dtypes (np.uint8, np.int8, np.uint16, np.int16) to float32 instead of float64.

most changes are to the expected types and tolerances in test cases

we may want to wait until skimage2 to merge this change

TODO

  • may also want to change img_as_float to return float32 for small integer inputs

Release note

8-bit and 16-bit integer types (np.int8, np.uint8, np.int16, np.uint16) will now promote to float32 rather than float64. This will preserve memory and may provide some performance benefit. If 64-bit precision is truly needed, the user should explicitly cast to float64 (or rescaled via `skimage.utils.img_as_float64`)

- modify convert_to_float and _supported_float type to cast small
integer dtypes (np.uint8, np.int8, np.uint16, np.int16) to float32
instead of float64.
@grlee77 grlee77 force-pushed the promote-small-ints-to-float32 branch from 35204fb to 9e16668 Compare September 1, 2024 12:55
@hmaarrfk
Copy link
Copy Markdown
Member

hmaarrfk commented Sep 1, 2024

I understand that this may break « exact tests » but I feel like it would be for the greater good.

I’ve started to remove some scikit image imports from my codebase because of the float64 promotion.

With the rise of ML (we’re the same code running on different hardware produces different results for my personal work)

I feel like this change would help scikit image maintain relevance

@stefanv
Copy link
Copy Markdown
Member

stefanv commented Nov 19, 2024

@grlee77 Sorry that this did not receive the attention it deserved; I think we should definitely get this in for 2.0. @lagru, thoughts?

@stefanv stefanv added the 🥾 Path to skimage2 A step towards the new "API 2.0" label Nov 19, 2024
@stefanv stefanv added this to the 2.0 milestone Nov 19, 2024
@lagru
Copy link
Copy Markdown
Member

lagru commented Nov 20, 2024

Yes, sounds like a good idea to incorporate this into 7521. I'll remove the "Path to skimage2" tag since I view that more as "API stuff that can be done before skimage2". It's on the 2.0 milestone so we won't forget it. :)

@lagru lagru removed the 🥾 Path to skimage2 A step towards the new "API 2.0" label Nov 20, 2024
@stefanv stefanv added this to skimage2 Mar 1, 2025
@stefanv stefanv moved this to To Do in skimage2 Mar 1, 2025
@stefanv stefanv removed this from skimage2 Mar 1, 2025
@stefanv stefanv moved this to To Do in skimage2 Mar 1, 2025
@stefanv stefanv added this to skimage2 Mar 1, 2025
@stefanv stefanv moved this from To Do to To Review in skimage2 Mar 1, 2025
@lagru lagru moved this from To Review to Stalled / Waiting in skimage2 Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Stalled / Waiting

Development

Successfully merging this pull request may close these issues.

proposal: cast small integer types to single precision

5 participants