Skip to content

Removes allocations with get_tmp that occur in some cases #125

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

Merged
merged 3 commits into from
Aug 9, 2022

Conversation

thomvet
Copy link
Contributor

@thomvet thomvet commented Aug 9, 2022

Specifically when get_tmp(cache::PreallocationTools.DiffCache, u:LArray{T, ...} where T is not a ForwardDiff.Dual, the method defined for Duals is used (which uses ArrayInterfaceCore.restructure --> allocations, even though we should just get the normal cache back, not the dual cache).

The changes introduced dispatch the present get_tmp only on Duals, so that for T <: Number the fallback method for u::AbstractArray in PreallocationTools is used (https://github.com/SciML/PreallocationTools.jl/blob/addfd170cb69f98778f7e5f40a3d9ab352c99b10/src/PreallocationTools.jl#L61)

thomvet and others added 3 commits August 9, 2022 16:41
Not doing so leads to this method also being used for non-Dual LArrays, which currently incurs (unnecessary) allocations.
Bumped patch version; added ForwardDiff to dependencies (need just the type definition...)
@ChrisRackauckas ChrisRackauckas merged commit 497a2e9 into SciML:master Aug 9, 2022
@thomvet thomvet deleted the thomvet-patch-1 branch August 10, 2022 09:50
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.

2 participants