Skip to main content

DataError

Enum DataError 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

ZeroBatchSize

DataLoaderConfig::batch_size がゼロ(1 バッチも構成できない)。

§

ScalarTensor

TensorDataset::new に rank 0(スカラー)のテンソルが渡された (スカラーにはサンプル軸がなくバッチ化できない)。

§

LengthMismatch

タプルデータセットの成分間で len() が一致しない (component は先頭〈index 0〉を基準とした不一致成分の位置。 DataLoader::new の構築時検査で検出する)。

Fields

§expected: usize
§found: usize
§component: usize
§

IndexOutOfRange

batch(indices) に渡された添字がデータセットの len() を 超える。

Fields

§index: usize
§len: usize
§

Shape(ShapeError)

shape 起因の不整合(ShapeError への委譲)。

§

Rng(RngError)

Sampler の抽選(RandomSampler・WeightedRandomSampler) が crate::rng へ委譲した処理の失敗(イシュー #2182)。

§

SampleShapeMismatch

HookedDataLoader の collate(既定の default_collate またはユーザー指定)に渡されたサンプル列で、position 番目の サンプルの shape が先頭サンプル(expected)と一致しない (イシュー #2182)。

Fields

§position: usize
§expected: Vec<usize>
§found: Vec<usize>
§

EmptyBatch

HookedDataLoader の collate に渡されたサンプル列が空 (Sampler::next_batch が空でない添字列を返したのにサンプル 収集後の列が空になることは無いが、default_collate を直接 呼び出す利用者向けに防御的に定義する。イシュー #2182)。

§

InvalidPrefetchConfig

PrefetchConfig::new の構築時検査に失敗した(prefetch_depth がゼロ、または num_workers が PREFETCH_MAX_WORKERS を 超える。イシュー #2183)。

Fields

§reason: &'static str
§

WorkerSpawn

PrefetchDataLoader::iter が worker スレッドの起動 (std::thread::Builder::spawn)に失敗した(イシュー #2183)。

Fields

§reason: String
§

WorkerFailed

PrefetchBatches の worker が batch_index 番目の結果を 返さないまま終了した(panic 等)。§2.3 のライフサイクル契約に 従い、この位置で 1 回だけ yield し以降は None を返す (イシュー #2183)。

Fields

§batch_index: usize
§

EmptyConcat

ConcatDataset::new に成分が 1 件も渡されなかった(PyTorch ConcatDataset も空列を assert で拒否する。イシュー #2661)。

§

SplitLengthMismatch

random_split の分割長の合計 found がデータセットの長さ expected と一致しない(イシュー #2661)。

Fields

§expected: usize
§found: usize
§

InvalidSplitFraction

random_split_fractions の割合の不正(index 番目が 非有限・負・1 超。合計に関する違反は index == fractions.len()。 DataError は Eq 導出のため f64 を持たせない。イシュー #2661)。

Fields

§index: usize
§reason: &'static str
§

ConcatShapeMismatch

ConcatBatch::concat_batches に渡された part 番目の shape が 先頭 part と先頭軸以外で一致しない(イシュー #2661)。

Fields

§part: usize
§expected: Vec<usize>
§found: Vec<usize>
§

IterableStream

IterableDataset の実装者が供給元の失敗(読み込み失敗等)を 型付きで伝えるための variant。ライブラリ自身は生成しない (イシュー #2662)。

Fields

§reason: String

Trait Implementations§

Source§

impl Clone for DataError

Source§

fn clone(&self) -> DataError

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 Debug for DataError

Source§

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

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

impl Display for DataError

Source§

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

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

impl Eq for DataError

Source§

impl Error for DataError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<RngError> for DataError

Source§

fn from(err: RngError) -> DataError

Converts to this type from the input type.
Source§

impl From<ShapeError> for DataError

Source§

fn from(err: ShapeError) -> DataError

Converts to this type from the input type.
Source§

impl PartialEq for DataError

Source§

fn eq(&self, other: &DataError) -> 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 DataError

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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