pub struct Ctx<'g> { /* private fields */ }Expand description
工人线程上的长期状态:显存池和权重缓存。
Implementations§
Source§impl<'g> Ctx<'g>
impl<'g> Ctx<'g>
pub fn new(gpu: &'g Gpu) -> Ctx<'g>
pub fn gpu(&self) -> &'g Gpu
Sourcepub fn exec<'c>(&'c self, n: usize, owner: Owner) -> BatchExec<'c, 'g>
pub fn exec<'c>(&'c self, n: usize, owner: Owner) -> BatchExec<'c, 'g>
真正执行的批量执行器。owner 是拥有权重的模型。
Sourcepub fn peak_bytes(&self) -> u64
pub fn peak_bytes(&self) -> u64
自上次 Ctx::reset_peak 以来占用显存的峰值(缓冲池 + 权重,字节)。
Sourcepub fn needed_bytes(&self) -> u64
pub fn needed_bytes(&self) -> u64
真正需要的显存峰值:在用的张量 + 权重(不含池里闲着的,字节)。
pub fn reset_peak(&self)
Sourcepub fn available_bytes(&self) -> Result<u64, String>
pub fn available_bytes(&self) -> Result<u64, String>
现在能用于工作内存的显存:驱动报告的空闲量加上池里闲着的。
Auto Trait Implementations§
impl<'g> !Freeze for Ctx<'g>
impl<'g> !RefUnwindSafe for Ctx<'g>
impl<'g> !Sync for Ctx<'g>
impl<'g> !UnwindSafe for Ctx<'g>
impl<'g> Forget for Ctx<'g>
impl<'g> Send for Ctx<'g>
impl<'g> Unpin for Ctx<'g>
impl<'g> UnsafeUnpin for Ctx<'g>
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