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
impl PrefetchConfig
Sourcepub fn new(
num_workers: usize,
prefetch_depth: usize,
) -> Result<PrefetchConfig, DataError>
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。
Sourcepub fn num_workers(&self) -> usize
pub fn num_workers(&self) -> usize
設定された worker スレッド数。
Sourcepub fn prefetch_depth(&self) -> usize
pub fn prefetch_depth(&self) -> usize
設定された prefetch 深さ(in-flight バッチ数の上限)。
Trait Implementations§
Source§impl Clone for PrefetchConfig
impl Clone for PrefetchConfig
Source§fn clone(&self) -> PrefetchConfig
fn clone(&self) -> PrefetchConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PrefetchConfig
Source§impl Debug for PrefetchConfig
impl Debug for PrefetchConfig
impl Eq for PrefetchConfig
Source§impl PartialEq for PrefetchConfig
impl PartialEq for PrefetchConfig
impl StructuralPartialEq for PrefetchConfig
Auto Trait Implementations§
impl Freeze for PrefetchConfig
impl RefUnwindSafe for PrefetchConfig
impl Send for PrefetchConfig
impl Sync for PrefetchConfig
impl Unpin for PrefetchConfig
impl UnsafeUnpin for PrefetchConfig
impl UnwindSafe for PrefetchConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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