Skip to main content

Ctx

Struct Ctx 

Source
pub struct Ctx<'g> { /* private fields */ }
Expand description

工人线程上的长期状态:显存池和权重缓存。

Implementations§

Source§

impl<'g> Ctx<'g>

Source

pub fn new(gpu: &'g Gpu) -> Ctx<'g>

Source

pub fn gpu(&self) -> &'g Gpu

Source

pub fn exec<'c>(&'c self, n: usize, owner: Owner) -> BatchExec<'c, 'g>

真正执行的批量执行器。owner 是拥有权重的模型。

Source

pub fn dry<'c>(&'c self, n: usize, owner: Owner) -> BatchExec<'c, 'g>

试算:不碰显存,只记显存峰值。

Source

pub fn peak_bytes(&self) -> u64

自上次 Ctx::reset_peak 以来占用显存的峰值(缓冲池 + 权重,字节)。

Source

pub fn needed_bytes(&self) -> u64

真正需要的显存峰值:在用的张量 + 权重(不含池里闲着的,字节)。

Source

pub fn reset_peak(&self)

Source

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> Move 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.