#[non_exhaustive]pub enum DataError {
Show 16 variants
ZeroBatchSize,
ScalarTensor,
LengthMismatch {
expected: usize,
found: usize,
component: usize,
},
IndexOutOfRange {
index: usize,
len: usize,
},
Shape(ShapeError),
Rng(RngError),
SampleShapeMismatch {
position: usize,
expected: Vec<usize>,
found: Vec<usize>,
},
EmptyBatch,
InvalidPrefetchConfig {
reason: &'static str,
},
WorkerSpawn {
reason: String,
},
WorkerFailed {
batch_index: usize,
},
EmptyConcat,
SplitLengthMismatch {
expected: usize,
found: usize,
},
InvalidSplitFraction {
index: usize,
reason: &'static str,
},
ConcatShapeMismatch {
part: usize,
expected: Vec<usize>,
found: Vec<usize>,
},
IterableStream {
reason: String,
},
}Expand description
Dataset/DataLoader 専用のエラー型。shape 起因の不整合
(要素数積のオーバーフロー等)は Tensor::new/narrow 等と同じ
ShapeError へ委譲する(From<ShapeError> 実装。rng::RngError/
creation::CreationError と同型の設計)。
#[non_exhaustive]: 公開 API 非破壊(.claude/rules/security.md)
のため後続の検査項目追加に備える。
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ZeroBatchSize
DataLoaderConfig::batch_size がゼロ(1 バッチも構成できない)。
ScalarTensor
TensorDataset::new に rank 0(スカラー)のテンソルが渡された
(スカラーにはサンプル軸がなくバッチ化できない)。
LengthMismatch
タプルデータセットの成分間で len() が一致しない
(component は先頭〈index 0〉を基準とした不一致成分の位置。
DataLoader::new の構築時検査で検出する)。
IndexOutOfRange
batch(indices) に渡された添字がデータセットの len() を
超える。
Shape(ShapeError)
shape 起因の不整合(ShapeError への委譲)。
Rng(RngError)
Sampler の抽選(RandomSampler・WeightedRandomSampler)
が crate::rng へ委譲した処理の失敗(イシュー #2182)。
SampleShapeMismatch
HookedDataLoader の collate(既定の default_collate
またはユーザー指定)に渡されたサンプル列で、position 番目の
サンプルの shape が先頭サンプル(expected)と一致しない
(イシュー #2182)。
EmptyBatch
HookedDataLoader の collate に渡されたサンプル列が空
(Sampler::next_batch が空でない添字列を返したのにサンプル
収集後の列が空になることは無いが、default_collate を直接
呼び出す利用者向けに防御的に定義する。イシュー #2182)。
InvalidPrefetchConfig
PrefetchConfig::new の構築時検査に失敗した(prefetch_depth
がゼロ、または num_workers が PREFETCH_MAX_WORKERS を
超える。イシュー #2183)。
WorkerSpawn
PrefetchDataLoader::iter が worker スレッドの起動
(std::thread::Builder::spawn)に失敗した(イシュー #2183)。
WorkerFailed
PrefetchBatches の worker が batch_index 番目の結果を
返さないまま終了した(panic 等)。§2.3 のライフサイクル契約に
従い、この位置で 1 回だけ yield し以降は None を返す
(イシュー #2183)。
EmptyConcat
ConcatDataset::new に成分が 1 件も渡されなかった(PyTorch
ConcatDataset も空列を assert で拒否する。イシュー #2661)。
SplitLengthMismatch
random_split の分割長の合計 found がデータセットの長さ
expected と一致しない(イシュー #2661)。
InvalidSplitFraction
random_split_fractions の割合の不正(index 番目が
非有限・負・1 超。合計に関する違反は index == fractions.len()。
DataError は Eq 導出のため f64 を持たせない。イシュー #2661)。
ConcatShapeMismatch
ConcatBatch::concat_batches に渡された part 番目の shape が
先頭 part と先頭軸以外で一致しない(イシュー #2661)。
IterableStream
IterableDataset の実装者が供給元の失敗(読み込み失敗等)を
型付きで伝えるための variant。ライブラリ自身は生成しない
(イシュー #2662)。
Trait Implementations§
impl Eq for DataError
Source§impl Error for DataError
impl Error for DataError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<ShapeError> for DataError
impl From<ShapeError> for DataError
Source§fn from(err: ShapeError) -> DataError
fn from(err: ShapeError) -> DataError
impl StructuralPartialEq for DataError
Auto Trait Implementations§
impl Freeze for DataError
impl RefUnwindSafe for DataError
impl Send for DataError
impl Sync for DataError
impl Unpin for DataError
impl UnsafeUnpin for DataError
impl UnwindSafe for DataError
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