|
Mila
Deep Neural Network Library
|
Memory allocation breakdown for a single component. More...
Public Member Functions | |
| MemoryStats & | operator+= (const MemoryStats &rhs) noexcept |
| Accumulate another MemoryStats into this one. | |
| std::string | toString () const |
| Produce a human-readable summary of this stats instance. | |
| std::size_t | totalBytes () const noexcept |
| Total memory allocated across all categories and locations. | |
| std::size_t | totalDeviceBytes () const noexcept |
| Total device memory allocated by this component. | |
| std::size_t | totalHostBytes () const noexcept |
| Total host memory allocated by this component. | |
Public Attributes | |
| std::size_t | device_gradient_bytes { 0 } |
| Input and parameter gradient buffers. | |
| std::size_t | device_parameter_bytes { 0 } |
| Learnable parameter buffers (weights, biases). | |
| std::size_t | device_state_bytes { 0 } |
| Forward and decode output buffers, KV cache. | |
| std::size_t | host_gradient_bytes { 0 } |
| Gradient buffers on host (if any). | |
| std::size_t | host_parameter_bytes { 0 } |
| Learnable parameter buffers pinned on host (if any). | |
| std::size_t | host_state_bytes { 0 } |
| Forward and decode output buffers on host (if any). | |
Memory allocation breakdown for a single component.
Reflects the current allocation state at the moment of the call. Categories map directly onto the component build lifecycle:
After construction nothing – construction allocates no device memory After build() parameters + state After setTrainingMode() parameters + state + gradients
Parameters are allocated in onBuilding(), not in the constructor. That is what lets Component::getRequiredMemory() report a footprint from a constructed but unbuilt graph. See Specifications/MemoryFootprint.md section 3.1.
All sizes are in bytes. Device and host allocations are tracked separately as they represent distinct, independently constrained resources.
|
inlinenoexcept |
Accumulate another MemoryStats into this one.
Used by CompositeComponent and Network to aggregate child stats.
|
inlinenodiscard |
Produce a human-readable summary of this stats instance.
| std::size_t Mila::Dnn::MemoryStats::device_gradient_bytes { 0 } |
Input and parameter gradient buffers.
Allocated lazily on first setTraining(true). Retained thereafter.
| std::size_t Mila::Dnn::MemoryStats::device_parameter_bytes { 0 } |
Learnable parameter buffers (weights, biases).
Allocated at construction. Static for the component lifetime.
| std::size_t Mila::Dnn::MemoryStats::device_state_bytes { 0 } |
Forward and decode output buffers, KV cache.
Allocated at build(). Static after build().