AutoOptimize.jl icon indicating copy to clipboard operation
AutoOptimize.jl copied to clipboard

Utilize AutoPreallocation.jl

Open ChrisRackauckas opened this issue 5 years ago • 4 comments

https://github.com/oxinabox/AutoPreallocation.jl

ChrisRackauckas avatar Jul 06 '20 04:07 ChrisRackauckas

@oxinabox is AutoPreallocation safe for ForwardDiff, i.e. does it use DualCaches?

ChrisRackauckas avatar Jul 16 '20 13:07 ChrisRackauckas

AutoPreallocation hijacks the construction of new Arrays, to reuse ones that it has already allocated earlier. It kind of negates the need to use DualCache which exist to do the same thing as a special case, right? But it should work find to use on top of that, since it will see the array being created in the DualCache and then capture that one only.

The main problem with AutoPreallocation.jl is Cassette related inferrence failures, which can some times dominate the costs saved by avoiding the allocations

oxinabox avatar Jul 17 '20 12:07 oxinabox

It kind of negates the need to use DualCache which exist to do the same thing as a special case, right?

If the user runs AutoPreallocation and then runs it with dual numbers, it'll automatically use different caches than with Float64, and that's done via type inference?

ChrisRackauckas avatar Jul 17 '20 13:07 ChrisRackauckas

If the user runs AutoPreallocation and then runs it with dual numbers, it'll automatically use different caches than with Float64, and that's done via type inference?

I'm not sure i understand. Nothing in AutoPreallocation has to do with type inference; except that because AutoPreallocation uses Cassette sometimes type-inference breaks, causing things to act type-unstable. Standard problem with Cassette.

But in general if your code allocates differently between two calls, then AutoPreallocation will fail. If it allocates the same it will work


Probably just read these two short files and you will see how Autopreallocation.jl works

  • https://github.com/oxinabox/AutoPreallocation.jl/blob/master/src/recording.jl
  • https://github.com/oxinabox/AutoPreallocation.jl/blob/master/src/replaying.jl

oxinabox avatar Jul 17 '20 19:07 oxinabox