Skip to main content

PrefetchConfig

Struct PrefetchConfig 

Source
pub struct PrefetchConfig { /* private fields */ }
Expand description

マルチワーカー prefetch(イシュー #2183・親 #2131)の設定。 PrefetchDataLoader::new に渡す。

§rayon ではなく std::thread を使う理由

crates/tensor-core/Cargo.toml の直接依存は [crate::element:: Element] が要求する half のみであり、rayon を追加すると .claude/rules/deps-policy.md の許容依存区分への新規追加になる (ユーザー承認が必要な変更であり本イシューのスコープ外。 docs/tensor-core-data-prefetch-decision.md §1.1・§8 に承認事項として 記録する)。加えて backend-cpu の GEMM 等は rayon のグローバル pool を使うため、loader の worker を同じ pool に載せると学習ステップの カーネルと prefetch 用の worker が競合する。専用の OS スレッド (std::thread::Builder::spawn)ならこの競合を避けられる。

Implementations§

Source§

impl PrefetchConfig

Source

pub fn new( num_workers: usize, prefetch_depth: usize, ) -> Result<PrefetchConfig, DataError>

num_workers(起動する worker スレッド数。0 は PrefetchDataLoader を逐次経路〈スレッドを起動せず呼び出し スレッド上で処理する。PyTorch num_workers=0 と同じ意味〉に する)・prefetch_depth(in-flight で許容するバッチ数の上限。 メモリ使用量はおおよそ prefetch_depth バッチ分に収まる)を 検証してから構築する。prefetch_depth == 0(先読み無しは非対応)・ prefetch_depth が PREFETCH_MAX_DEPTH を超える・num_workers が PREFETCH_MAX_WORKERS を超える場合は DataError::InvalidPrefetchConfig。

Source

pub fn num_workers(&self) -> usize

設定された worker スレッド数。

Source

pub fn prefetch_depth(&self) -> usize

設定された prefetch 深さ(in-flight バッチ数の上限)。

Trait Implementations§

Source§

impl Clone for PrefetchConfig

Source§

fn clone(&self) -> PrefetchConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PrefetchConfig

Source§

impl Debug for PrefetchConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for PrefetchConfig

Source§

impl PartialEq for PrefetchConfig

Source§

fn eq(&self, other: &PrefetchConfig) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PrefetchConfig

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V