|
Mila
Deep Neural Network Library
|
Type-erased execution context interface. More...
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. | |
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.
|
nodiscardpure virtualnoexcept |
|
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 >.
|
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 >.