[Paper Review] Efficient Memory Management for Deep Neural Net Inference
This paper proposes five novel memory management strategies to minimize the runtime memory footprint of deep neural network inference on mobile and embedded devices by intelligently reusing memory buffers among intermediate tensors. By modeling tensor usage intervals and applying greedy, size- and breadth-aware allocation with strip packing heuristics, the approach reduces memory usage by up to 11% compared to state-of-the-art methods and achieves near-theoretical lower bounds on most models.
While deep neural net inference was considered a task for servers only, latest advances in technology allow the task of inference to be moved to mobile and embedded devices, desired for various reasons ranging from latency to privacy. These devices are not only limited by their compute power and battery, but also by their inferior physical memory and cache, and thus, an efficient memory manager becomes a crucial component for deep neural net inference at the edge. We explore various strategies to smartly share memory buffers among intermediate tensors in deep neural nets. Employing these can result in up to 11% smaller memory footprint than the state of the art.
Motivation & Objective
- Address the challenge of limited physical memory and cache in mobile and embedded devices for deep neural network inference.
- Reduce the memory footprint of intermediate tensors in deep neural networks without compromising inference correctness or performance.
- Optimize memory allocation for inference engines by reusing memory buffers across tensors with non-overlapping usage intervals.
- Improve cache hit rates and inference speed through efficient memory layout and buffer sharing.
- Provide practical, fast-to-compute strategies suitable for run-time exploration on resource-constrained systems.
Proposed method
- Model intermediate tensors using tensor usage records: {first_op, last_op, size}, derived from topological order of the computational graph.
- Define tensor usage intervals as [first_op, last_op] to identify non-overlapping tensors that can share memory.
- Apply greedy strategies based on tensor size (largest first) and breadth (number of overlapping intervals) to prioritize buffer reuse.
- Use strip packing heuristics (e.g., Bestfit) to solve the 2D bin packing variant of the memory allocation problem.
- Introduce two distinct allocation approaches: Shared Objects (for GPU textures) and Offset Calculation (for CPU memory pools).
- Evaluate strategies at run-time to select the optimal configuration, with sub-millisecond overhead for most models.
Experimental results
Research questions
- RQ1How can memory buffers for intermediate tensors in deep neural networks be efficiently reused to minimize total memory footprint?
- RQ2What are the most effective heuristics for allocating shared memory buffers when tensor sizes and usage intervals are known in advance?
- RQ3To what extent can memory reuse strategies reduce memory consumption compared to naive allocation and prior work?
- RQ4How do different allocation strategies (e.g., greedy by size, strip packing) compare in terms of memory efficiency and runtime performance?
- RQ5Can the proposed strategies achieve near-theoretical lower bounds on memory usage across diverse neural network architectures?
Key findings
- The Greedy by Size Improved strategy achieves up to 11% lower memory consumption than the prior state of the art across all evaluated models.
- For the Shared Objects approach, Greedy by Size Improved achieves the theoretical lower bound on MobileNet v1, PoseNet, and BlazeFace.
- For the Offset Calculation approach, Greedy by Size achieves the theoretical lower bound on all models except DeepLab v3, where it is within 8% of the bound.
- The proposed strategies reduce memory usage by up to 10.5× compared to naïve allocation, and up to 7.7% less than Strip Packing Bestfit.
- Memory reuse leads to improved cache hit rates, translating to up to 10% faster inference speed in some cases.
- The strategies are fast enough for run-time exploration (a few milliseconds), making them practical for on-device deployment.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.