|
Mila 0.13.48
Deep Neural Network Library
|
CPU memory resource for host-accessible memory allocation. More...


Public Member Functions | |
| CpuMemoryResource (int device_id=0) | |
| Constructs CPU memory resource. | |
| Public Member Functions inherited from Mila::Dnn::Compute::MemoryResource | |
| virtual | ~MemoryResource ()=default |
| Virtual destructor for proper cleanup of derived classes. | |
Static Public Attributes | |
| static constexpr DeviceType | device_type = DeviceType::Cpu |
| static constexpr bool | is_device_accessible = false |
| Indicates CPU memory is not accessible from device code. | |
| static constexpr bool | is_host_accessible = HostAccessible::is_host_accessible |
| Indicates CPU memory is accessible from host code. | |
| 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. | |
Protected Member Functions | |
| void * | do_allocate (std::size_t bytes, std::size_t alignment) override |
| Allocates aligned CPU memory. | |
| void | do_deallocate (void *ptr, std::size_t, std::size_t) override |
| Deallocates CPU memory using platform-specific functions. | |
| bool | do_is_equal (const std::pmr::memory_resource &other) const noexcept override |
| Compares CPU memory resources for equality. | |
CPU memory resource for host-accessible memory allocation.
Provides optimized CPU memory allocation with proper alignment support for tensor data. CPU memory allocation doesn't require device selection, so the device_id parameter is unused but maintained for interface consistency with other memory resource types.
|
inlineexplicit |
Constructs CPU memory resource.
| device_id | Device identifier (unused for CPU, maintained for interface consistency) |

|
inlineoverrideprotectedvirtual |
Allocates aligned CPU memory.
Uses platform-specific aligned allocation functions to ensure proper memory alignment for optimal CPU performance and SIMD operations.
| bytes | Number of bytes to allocate |
| alignment | Memory alignment requirement |
| std::bad_alloc | If allocation fails |
Implements Mila::Dnn::Compute::MemoryResource.
|
inlineoverrideprotectedvirtual |
Deallocates CPU memory using platform-specific functions.
Properly releases memory allocated with platform-specific aligned allocation functions.
| ptr | Pointer to memory to deallocate |
| bytes | Size of memory block (unused, kept for interface compatibility) |
| alignment | Alignment used during allocation (unused, kept for interface compatibility) |
Implements Mila::Dnn::Compute::MemoryResource.
|
inlineoverrideprotectedvirtualnoexcept |
Compares CPU memory resources for equality.
CPU memory resources are equal if they are both CpuMemoryResource instances, since they all manage the same underlying host memory pool.
| other | The other memory resource to compare with |
Implements Mila::Dnn::Compute::MemoryResource.

|
staticconstexpr |
|
staticconstexpr |
Indicates CPU memory is not accessible from device code.
|
staticconstexpr |
Indicates CPU memory is accessible from host code.