Mila
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Dnn::Compute::IExecutionContext Class Referenceabstractexport

Type-erased execution context interface. More...

Inheritance diagram for Mila::Dnn::Compute::IExecutionContext:
Mila::Dnn::Compute::ExecutionContext< DeviceType::Cpu > Mila::Dnn::Compute::ExecutionContext< DeviceType::Cuda > Mila::Dnn::Compute::ExecutionContext< DeviceType::Metal > Mila::Dnn::Compute::ExecutionContext< DeviceType::Vulkan >

Public Member Functions

virtual DeviceId getDeviceId () const noexcept=0
 Get the device identifier.
virtual std::size_t getScratchHighWaterBytes () const noexcept
 High-water mark of context-owned scratch device memory, in bytes.
virtual void synchronize ()=0
 Synchronize all pending operations.

Detailed Description

Type-erased execution context interface.

Provides a minimal virtual interface for execution contexts. Specializations (CPU, CUDA, Metal, ROCm) inherit from this to enable polymorphic usage when the device type is not known at compile time.

For performance-critical code where the device type is known statically, use the templated ExecutionContext<TDeviceType> directly or cast_context<>() to avoid runtime overhead.

Member Function Documentation

◆ getDeviceId()

virtual DeviceId Mila::Dnn::Compute::IExecutionContext::getDeviceId ( ) const
nodiscardpure virtualnoexcept

◆ getScratchHighWaterBytes()

virtual std::size_t Mila::Dnn::Compute::IExecutionContext::getScratchHighWaterBytes ( ) const
inlinenodiscardvirtualnoexcept

High-water mark of context-owned scratch device memory, in bytes.

Scratch is allocated lazily during forward passes and grows without shrinking, so no build-time contract sees it – it is the largest identified component of the gap between a reported footprint and what the driver says was consumed (Specifications/MemoryFootprint.md section 6.4).

Zero for contexts that allocate no scratch, which includes every CPU context.

Reimplemented in Mila::Dnn::Compute::ExecutionContext< DeviceType::Cuda >.

◆ synchronize()

virtual void Mila::Dnn::Compute::IExecutionContext::synchronize ( )
pure virtual

Synchronize all pending operations.

Blocks until all operations submitted to this context complete. For CPU contexts, this is typically a no-op.

Implemented in Mila::Dnn::Compute::ExecutionContext< DeviceType::Cpu >, Mila::Dnn::Compute::ExecutionContext< DeviceType::Cuda >, Mila::Dnn::Compute::ExecutionContext< DeviceType::Metal >, and Mila::Dnn::Compute::ExecutionContext< DeviceType::Vulkan >.


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