|
Mila 0.13.48
Deep Neural Network Library
|
A memory resource wrapper that tracks allocation and deallocation statistics. More...


Public Member Functions | |
| TrackedMemoryResource (MemoryResource *underlying, std::string_view name="") | |
| Constructs a new tracked memory resource. | |
| ~TrackedMemoryResource () | |
| Destructor that properly cleans up the underlying resource. | |
| const MemoryResource * | getUnderlying () const |
| Gets access to the underlying memory resource. | |
| std::string_view | name () const |
| Copies memory between potentially different memory spaces, delegating to underlying resource. | |
| Public Member Functions inherited from Mila::Dnn::Compute::MemoryResource | |
| virtual | ~MemoryResource ()=default |
| Virtual destructor for proper cleanup of derived classes. | |
Protected Member Functions | |
| void * | do_allocate (std::size_t bytes, std::size_t alignment) override |
| Allocates memory and updates tracking statistics. | |
| void | do_deallocate (void *p, std::size_t bytes, std::size_t alignment) override |
| Deallocates memory and updates tracking statistics. | |
| bool | do_is_equal (const std::pmr::memory_resource &other) const noexcept override |
| Checks if this memory resource is equal to another. | |
Private Attributes | |
| std::string | name_ |
| Optional name for debugging/logging. | |
| MemoryResource * | underlying_ |
| The wrapped memory resource (owned). | |
Additional Inherited Members | |
| Static Public Attributes inherited from Mila::Dnn::Compute::MemoryResource | |
| static constexpr bool | is_device_accessible = false |
| Checks if the memory is accessible from device code. | |
| static constexpr bool | is_host_accessible = true |
| Checks if the memory is accessible from host code. | |
A memory resource wrapper that tracks allocation and deallocation statistics.
This class wraps another memory resource and intercepts all allocation, deallocation, memcpy, and memset calls to maintain global memory usage statistics.
|
inlineexplicit |
Constructs a new tracked memory resource.
| underlying | The memory resource to track (takes ownership). |
| name | Optional name for this memory resource for logging purposes. |


|
inline |
Destructor that properly cleans up the underlying resource.
|
inlineoverrideprotectedvirtual |
Allocates memory and updates tracking statistics.
| bytes | Number of bytes to allocate |
| alignment | Memory alignment requirement |
Implements Mila::Dnn::Compute::MemoryResource.
|
inlineoverrideprotectedvirtual |
Deallocates memory and updates tracking statistics.
| p | Pointer to memory to deallocate |
| bytes | Size of memory block |
| alignment | Alignment used during allocation |
Implements Mila::Dnn::Compute::MemoryResource.
|
inlineoverrideprotectedvirtualnoexcept |
Checks if this memory resource is equal to another.
| other | The other memory resource to compare with |
Implements Mila::Dnn::Compute::MemoryResource.

|
inline |
Gets access to the underlying memory resource.
|
inline |
Copies memory between potentially different memory spaces, delegating to underlying resource.
| dst | Destination pointer |
| src | Source pointer |
| size_bytes | Number of bytes to copy |
Sets memory to a specific byte value, delegating to underlying resource.
| ptr | Pointer to the memory block to fill |
| value | Byte value to set (0-255) |
| size_bytes | Number of bytes to set |
Gets the name of this tracked memory resource.

|
private |
Optional name for debugging/logging.
|
private |
The wrapped memory resource (owned).