1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use thiserror::Error;
use super::{
autograd::AutogradError, common::CommonError, device::DeviceError, kernel::KernelError,
memory::MemoryError, param::ParamError, random::RandomError, shape::ShapeError,
};
/// Base error type for all tensor operations
#[derive(Debug, Error)]
pub enum TensorError {
/// Shape-related errors such as dimension mismatch, broadcasting errors
#[error(transparent)]
Shape(#[from] ShapeError),
/// Device-related errors such as device not found, CUDA errors
#[error(transparent)]
Device(#[from] DeviceError),
/// Memory-related errors such as memory allocation failed, invalid memory layout
#[error(transparent)]
Memory(#[from] MemoryError),
/// Kernel-related errors such as kernel compilation failed, kernel execution failed
#[error(transparent)]
Kernel(#[from] KernelError),
/// Parameter-related errors such as invalid function arguments
#[error(transparent)]
Param(#[from] ParamError),
/// Autograd-related errors such as inplace computation is not allowed
#[error(transparent)]
Autograd(#[from] AutogradError),
/// Random distribution-related errors such as invalid distribution parameters
#[error(transparent)]
Random(#[from] RandomError),
/// Common errors such as lock failed
#[error(transparent)]
Common(#[from] CommonError),
}