Mila
Deep Neural Network Library
Loading...
Searching...
No Matches
Component.MemoryStats.ixx File Reference

Memory allocation statistics for component inspection. More...

#include <cstddef>
#include <string>
#include <format>
import Dnn.TensorDataTypeTraits;
import Dnn.TensorDataType;
import Dnn.TensorTypes;

Classes

struct  Mila::Dnn::MemoryStats
 Memory allocation breakdown for a single component. More...

Namespaces

namespace  Mila
 Mila main API namespace.

Functions

MemoryStats Mila::Dnn::operator+ (MemoryStats lhs, const MemoryStats &rhs) noexcept
 Aggregate two MemoryStats instances.
template<TensorDataType TDataType>
constexpr std::size_t Mila::Dnn::storageBytes (dim_t element_count) noexcept
 Storage bytes occupied by an element count of a given tensor data type.

Detailed Description

Memory allocation statistics for component inspection.

Provides a breakdown of GPU and host memory allocated by a component across the three lifecycle-defined allocation categories: parameters, state, and gradients.

Function Documentation

◆ storageBytes()

template<TensorDataType TDataType>
std::size_t Mila::Dnn::storageBytes ( dim_t element_count)
constexprexportnoexcept

Storage bytes occupied by an element count of a given tensor data type.

The counterpart to Tensor::getStorageSize() for buffers that do not exist yet – getRequiredMemory() sizes allocations before build() makes them. Sub-byte types are the reason this cannot be a multiply: FP4 packs two elements per byte, so element_count * size_in_bytes overstates a packed weight by exactly 2x.

Parameters
element_countLogical elements, not bytes.