Mila 0.13.48
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Dnn::Compute::MetalMemoryResource Class Referenceexport

Stub implementation for non-Apple platforms. More...

Inheritance diagram for Mila::Dnn::Compute::MetalMemoryResource:
Collaboration diagram for Mila::Dnn::Compute::MetalMemoryResource:

Public Member Functions

 MetalMemoryResource ()
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 bool is_device_accessible = false
static constexpr bool is_host_accessible = false
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, std::size_t) override
 Allocates memory with specified size and alignment.
void do_deallocate (void *, std::size_t, std::size_t) override
 Deallocates previously allocated memory.
bool do_is_equal (const std::pmr::memory_resource &) const noexcept override
 Compares this memory resource with another for equality.

Detailed Description

Stub implementation for non-Apple platforms.

Provides compilation compatibility on non-Apple platforms where Metal is not available. Always throws runtime_error when instantiated.

Constructor & Destructor Documentation

◆ MetalMemoryResource()

Mila::Dnn::Compute::MetalMemoryResource::MetalMemoryResource ( )
inline

Member Function Documentation

◆ do_allocate()

void * Mila::Dnn::Compute::MetalMemoryResource::do_allocate ( std::size_t bytes,
std::size_t alignment )
inlineoverrideprotectedvirtual

Allocates memory with specified size and alignment.

Pure virtual function that must be implemented by derived classes to provide device-specific memory allocation. Implementation should handle device-specific allocation strategies and error conditions.

Parameters
bytesNumber of bytes to allocate
alignmentMemory alignment requirement
Returns
Pointer to allocated memory
Exceptions
std::bad_allocIf allocation fails

Implements Mila::Dnn::Compute::MemoryResource.

◆ do_deallocate()

void Mila::Dnn::Compute::MetalMemoryResource::do_deallocate ( void * ptr,
std::size_t bytes,
std::size_t alignment )
inlineoverrideprotectedvirtual

Deallocates previously allocated memory.

Pure virtual function that must be implemented by derived classes to provide device-specific memory deallocation. Implementation should handle proper cleanup and device synchronization if necessary.

Parameters
ptrPointer to memory to deallocate
bytesSize of memory block (may be used for debugging/validation)
alignmentAlignment that was used during allocation

Implements Mila::Dnn::Compute::MemoryResource.

◆ do_is_equal()

bool Mila::Dnn::Compute::MetalMemoryResource::do_is_equal ( const std::pmr::memory_resource & other) const
inlineoverrideprotectedvirtualnoexcept

Compares this memory resource with another for equality.

Two memory resources are equal if they can be used interchangeably for allocation and deallocation. Typically this means they are the same type and manage the same underlying memory pool or device.

Parameters
otherThe other memory resource to compare with
Returns
true if the memory resources are equivalent

Implements Mila::Dnn::Compute::MemoryResource.

Member Data Documentation

◆ is_device_accessible

bool Mila::Dnn::Compute::MetalMemoryResource::is_device_accessible = false
staticconstexpr

◆ is_host_accessible

bool Mila::Dnn::Compute::MetalMemoryResource::is_host_accessible = false
staticconstexpr

The documentation for this class was generated from the following file: