|
Mila
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 |
| Gets the name of this tracked memory 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. | |
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. |
|
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.