When optimizing deep neural networks, engineers often focus heavily on reducing model weights through quantization or pruning. However, in many real-world applications—such as high-resolution computer vision, long-context language modeling, or deployment on edge microcontrollers—the true bottleneck is not the weights, but the intermediate activations.
Traditional deep learning frameworks manage memory via "double-buffering": to compute a layer's output, they read from an input buffer and write to a completely separate output buffer. When processing high-resolution data or deep architectures, this approach leads to massive memory overhead, as multiple full-sized feature maps must reside in memory simultaneously.
To break this bottleneck, a powerful paradigm has emerged: in-place activation overwriting and buffer reuse. Instead of treating memory as a static sequence of isolated allocations, this approach treats memory as a dynamic, shared pool. By understanding the precise lifecycles and spatial access patterns of tensors, systems can safely overwrite input data with output data the moment it becomes "stale," allowing massive models to run within incredibly tight hardware constraints.
The Core Intuition: Exploiting Data Lifecycles
Why is traditional double-buffering wasteful? The answer lies in data locality and lifecycles. In a standard feed-forward network, once a layer finishes processing an input tensor, that input tensor is often never accessed again. Even within a single layer's computation—such as a sliding-window convolution—individual elements of the input tensor become redundant long before the entire layer finishes executing.
Once a piece of data has contributed to all dependent downstream operations, it is considered stale. If we can precisely map when data becomes stale, we can immediately reuse its physical memory address to store incoming output values.
Traditional Double-Buffering:
[ Input Buffer (Layer N) ] -------> [ Output Buffer (Layer N+1) ] (Double Space Required)
In-Place Overwriting:
[ Shared Buffer: Input N ] --(Compute)--> [ Shared Buffer: Overwritten with Output N+1 ] (Half Space Required)
In-Place Overwriting via Safe Pointer Offsets
The most direct application of this insight is executing a single layer's computation within a single shared buffer. For element-wise operations or batch normalization, this is straightforward because one input element maps directly to one output element. Lorenzo Porzi et al. leveraged this in In-Place Activated BatchNorm for Memory-Optimized Training of DNNs, demonstrating that fusing batch normalization and activation functions within the same input buffer halves the required storage during training.
For sliding-window operations like convolutions, however, in-place execution is significantly harder. A single output pixel depends on a local neighborhood of input pixels; writing an output value too early could corrupt input data that a neighboring window still needs to read.
To solve this, Petar Jokic et al. demonstrated in Improving Memory Utilization in Convolutional Neural Network Accelerators that it is mathematically possible to calculate a minimum safe offset between read and write pointers. Because a convolutional kernel moves predictably across an image, the top-left pixels of the input neighborhood become stale as the window moves right and down. By delaying the write pointer by a precise number of memory addresses, the output tensor can safely chase the read pointer through the exact same buffer without causing data corruption, cutting activation memory requirements by nearly 50%.
Shared Buffer:
[ Stale Input (Safe to Overwrite) ] [ Active Input Neighborhood ] [ Unread Input ]
^ ^
Write Pointer Read Pointer
This strategy can be pushed to extreme granularities. Albert Gural et al. introduced a "herringbone" pixel-ordering strategy in Memory-Optimal Direct Convolutions for Maximizing Classification Accuracy in Embedded Applications, optimizing the exact sequence of local operations to maximize immediate staleness. This allowed high-accuracy CNNs to run entirely within a 2KB RAM footprint. Similarly, Ji Lin et al. showed in MCUNet: Tiny Deep Learning on IoT Devices that combining global buffer scheduling with in-place depth-wise convolutions reduces peak SRAM requirements on microcontrollers by nearly half.
Memory Pooling Across Non-Concurrent Lifecycles
We can expand this concept beyond adjacent layers to the entire network graph. A neural network is a directed acyclic graph (DAG) of operations. By analyzing the execution timeline of this graph, we can determine the exact birth and death of every tensor. Two layers that execute at different times do not need separate allocations; they can share a single global memory pool.
Miguel de Prado et al. formalized this in Automated Design Space Exploration for Optimized Deployment of DNN on Arm Cortex-A CPUs, showing that allocating memory pools for layers with non-overlapping execution lifecycles can reduce activation memory footprints by up to 88% without sacrificing model accuracy or speed.
This greedy reclamation strategy scales seamlessly from microcontrollers up to massive generative models and distributed systems:
- Generative AI: In Scaling On-Device GPU Inference for Large Generative Models, Jiuqiang Tang et al. developed a framework that greedily reclaims and reuses buffers based on tensor size, slashing the runtime memory footprint of massive generative models on mobile devices by over 90%.
- Transformers: Gongzheng Li et al. implemented an activation reuse strategy across non-concurrent operators in Easy and Efficient Transformer: Scalable Inference Solution For Large NLP Model, allowing significantly larger language models to fit on a single GPU.
- Pipeline Parallelism: In distributed training, Zheng Zhang et al. developed MPipeMoE: Memory Efficient MoE for Pre-trained Models with Adaptive Pipeline Parallelism, which reuses the exact same physical memory addresses for sequential micro-batches within a pipeline, eliminating idle memory bubbles.
- Training Offloading: When buffers must be preserved for backpropagation, systems can prioritize what to evict. Xinyi Wan et al. showed in PipeOffload: Improving Scalability of Pipeline Parallelism with Memory Optimization that tracking the lifespan of activations—the duration between forward and backward passes—allows systems to selectively offload only the longest-lived tensors to CPU memory, maximizing peak memory savings while minimizing data transfer overhead. During the forward pass itself, Ayan Chakrabarti et al. demonstrated in Backprop with Approximate Activations for Memory-efficient Network Training that high-precision activations can be overwritten in shared global buffers immediately after computing the next layer, provided a compressed, low-precision copy is saved for the backward pass.
Interleaved and Patch-Based Execution Schedules
Instead of changing where tensors are stored, we can fundamentally alter the order of computation to prevent large tensors from ever existing in the first place.
Standard execution computes an entire layer's feature map before moving to the next layer. If a feature map is $H \times W$, the memory footprint scales with the full image area. However, if we interleave the execution of consecutive layers, we can process the data in smaller, localized chunks.
Tibor Schneider et al. applied this to edge devices in Q-EEGNet: an Energy-Efficient 8-bit Quantized Parallel EEGNet Implementation for Edge Motor-Imagery Brain-Machine Interfaces. By interleaving consecutive convolutional layers, their system processes data in vertical slices or columns. The output of a small column in Layer 1 is immediately consumed by Layer 2, bypassing the need to ever materialize or store the full intermediate feature map in RAM and reducing the memory footprint by up to 85%.
Layer-by-Layer Execution (High Memory):
[ Full Layer 1 Map ] ---> [ Full Layer 2 Map ]
Interleaved Column Execution (Low Memory):
[ Slice ] -> [ Slice ]
[ Slice ] -> [ Slice ] --> (Only one slice buffered at a time)
[ Slice ] -> [ Slice ]
This concept can be extended to spatial patches and sliding windows:
- Spatial Patches: In Memory-efficient Patch-based Inference for Tiny Deep Learning, Ji Lin et al. introduced a patch-based inference schedule that breaks the initial, memory-heavy layers of a network into small spatial sub-regions. This shifts the peak memory requirement from the size of the entire image down to the size of a single patch.
- Windowed Pooling: Zhaolan Huang et al. utilized this in TinyChirp: Bird Song Recognition Using TinyML Models on Low-power Wireless Acoustic Sensors, performing iterative pooling operations over small sliding windows to calculate averages incrementally, drastically lowering the buffer requirements for intermediate layers.
- Persistent Registers: For real-time tasks, Grzegorz Stefański et al. developed Short-Term Memory Convolutions, which utilizes layer-wise shift registers to cache only the minimal past context required for temporal operations, allowing the model to process much smaller active data chunks.
Co-Designing Hardware, Scheduling, and Architectures
To unlock the full potential of buffer overwriting, memory management must be tightly integrated with hardware dataflows and network architectures.
At the hardware level, Yu Feng et al. showed in ASV: Accelerated Stereo Vision System that when multiple sub-convolutions share an input feature map, a dynamic programming optimizer can schedule operations to ensure shared activations remain in fast on-chip buffers, eliminating energy-intensive DRAM accesses. For hardware accelerators utilizing in-memory computing, Martino Dazzi et al. explored how varying activation storage from pixel-level to kernel-level interleaving balances bit-masking complexity against consistent access times.
At the architectural level, network design can be tailored to minimize concurrent data lifespans:
- Linear Bottlenecks: Mark Sandler et al. demonstrated in MobileNetV2: Inverted Residuals and Linear Bottlenecks that placing residual shortcut connections exclusively between narrow bottleneck layers—rather than high-dimensional expansion layers—drastically reduces the amount of tensor data that must be held in memory simultaneously.
- Interleaved Memory Access: In Do Transformers Need Deep Long-Range Memory?, Jack W. Rae et al. proved that full-depth activation caching in Transformers is highly redundant; spacing out layers with long-range memory access evenly throughout the network maintains performance while significantly decreasing the peak memory required for activation caching.
- Asymmetric Activation Sharing: To optimize hardware-friendly training without standard backpropagation, Sunghyeon Woo et al. proposed organizing layers into blocks where every layer in the group shares a single activation from a lower layer for its weight updates, simplifying communication and reducing storage overhead.
By treating memory as a dynamic canvas where data is continuously written, reclaimed, and overwritten, these techniques prove that the boundaries of deep learning deployment are determined not just by hardware capacity, but by the intelligence of the execution schedule.
Key Foundational Work
Memory-Optimal Direct Convolutions for Maximizing Classification Accuracy in Embedded Applications (2019) — contributed 2 concept elements to this direction.
In-Place Activated BatchNorm for Memory-Optimized Training of DNNs (2018) — contributed 1 concept elements to this direction.
Backprop with Approximate Activations for Memory-efficient Network Training (2019) — contributed 1 concept elements to this direction.