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

revise dtype handling in cupyx.scipy.ndimage.spline_filter #4314

Merged
merged 4 commits into from
Dec 9, 2020

Conversation

grlee77
Copy link
Contributor

@grlee77 grlee77 commented Nov 23, 2020

This PR is related to #4247, but deals only with the recently implemented spline_filter functions from #4145.

The first commit here removes the allow_float32 keyword-only argument which is not present in scikit-image and has not yet appeared in a released CuPy version. It also changes the default output=np.float64 to output=None which will autoselect a floating point precision for the output. This allows computations to run in single precision by default on float16, float32 or complex64 inputs. In other words, the functionality previously provided by allow_float32=True becomes the default. update: restored default output to float64 for SciPy consistency. internal dtype behaves as if allow_float32=True.

If this type of single precision dtype handling seems okay, I would like to extend it to other functions in the ndimage module in a follow-up PR.

The second commit here adds tests for complex-valued inputs. These were previously supported, but were untested. Complex support was only recently merged upstream in SciPy and will be present in the upcoming 1.6.0 release, so for now a separate test class is used to allow this to also be tested on older SciPy versions.

@emcastillo emcastillo self-assigned this Nov 24, 2020
@emcastillo
Copy link
Member

For this PR we have decided to change the
allow_float32=False kwarg to use_intermediate_fp32=True to set this by default.

Eventually we want to have a common interface to address all these cases using a defined COMPUTE_MODE in an env var instead of just adding kwargs :).

How do you think?

@grlee77
Copy link
Contributor Author

grlee77 commented Nov 25, 2020

I can change the kwarg name and default to use_intermediate_fp32=True.

However, I am interested in extending this to most other functions in ndimage (aside from exceptions like binary morphology functions where it would not apply). It doesn't seem like it makes sense to proceed to add this same kwarg to all functions in ndimage.filters, ndimage.interpolation, etc. if the preferred solution is to move away from this and use a COMPUTE_MODE environment variable. Why not just start with the environment variable approach now? Otherwise it seems that we eventually have to go back and deprecate any unwanted keyword arguments.

@grlee77
Copy link
Contributor Author

grlee77 commented Dec 7, 2020

I reverted the change to output=None as a default. Now the output dtype will be consistent with SciPy, with the only difference being that intermediate computations can use float32 internally when the input is single precision.

@emcastillo
Copy link
Member

Jenkins, test this please

@emcastillo emcastillo added cat:enhancement Improvements to existing features st:test-and-merge (deprecated) Ready to merge after test pass. labels Dec 9, 2020
@emcastillo emcastillo added this to the v9.0.0b1 milestone Dec 9, 2020
@chainer-ci
Copy link
Member

Jenkins CI test (for commit 20d6288, target branch master) succeeded!

@mergify mergify bot merged commit 9e4cc04 into cupy:master Dec 9, 2020
@grlee77 grlee77 deleted the spline_dtype branch December 18, 2020 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:enhancement Improvements to existing features st:test-and-merge (deprecated) Ready to merge after test pass.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants