Internal Functions

This page documents internal functions that are not part of the public API but may be encountered during debugging or when extending PreallocationTools.jl functionality.

Warning

These are internal implementation details and may change without notice in any release. They should not be relied upon for user code.

Internal Helper Functions

PreallocationTools.enlargediffcache!Function
enlargediffcache!(dc::DiffCache, nelem::Integer)

Enlarges the dual cache array in a DiffCache when it's found to be too small.

This function is called internally when automatic differentiation requires a larger dual cache than initially allocated. It resizes dc.dual_du to accommodate nelem elements and issues a one-time warning suggesting an appropriate chunk size for optimal performance.

Arguments

  • dc: The DiffCache object to enlarge
  • nelem: The new required number of elements

Notes

The warning is shown only once per DiffCache instance to avoid spam. For optimal performance in production code, pre-allocate with the suggested chunk size to avoid runtime allocations.

source