pub struct DeviceManager { /* private fields */ }Expand description
Operation-level device manager wrapping a pluggable DeviceSelector.
DeviceManager is the public entry point for the device-selection framework.
Callers construct one with a selector of their choice (or use
DeviceManager::with_heuristic for the built-in heuristic), then call
DeviceManager::select once per scheduled operation.
§Examples
use tensorlogic_scirs_backend::device_manager::{
DeviceConfig, DeviceManager, OpDescriptor, OpKind,
};
let mgr = DeviceManager::with_heuristic(DeviceConfig::default());
let op = OpDescriptor { kind: OpKind::MatMul };
let dev = mgr.select(&op, &[32, 32]);
assert!(dev.is_cpu()); // GPU not available by defaultImplementations§
Source§impl DeviceManager
impl DeviceManager
Sourcepub fn new(selector: impl DeviceSelector + 'static) -> Self
pub fn new(selector: impl DeviceSelector + 'static) -> Self
Create a DeviceManager backed by any DeviceSelector implementation.
Sourcepub fn with_heuristic(config: DeviceConfig) -> Self
pub fn with_heuristic(config: DeviceConfig) -> Self
Create a DeviceManager backed by the built-in HeuristicSelector
configured with config.
Sourcepub fn select(&self, op: &OpDescriptor, shape: &[usize]) -> Device
pub fn select(&self, op: &OpDescriptor, shape: &[usize]) -> Device
Select the compute device for an operation described by op acting on
a tensor with the given shape.
Auto Trait Implementations§
impl Freeze for DeviceManager
impl !RefUnwindSafe for DeviceManager
impl Send for DeviceManager
impl Sync for DeviceManager
impl Unpin for DeviceManager
impl UnsafeUnpin for DeviceManager
impl !UnwindSafe for DeviceManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more