cubecl_convolution/components/
error.rs1use core::fmt::Debug;
2use cubecl_core::server::LaunchError;
3use cubecl_matmul::components::{MatmulAvailabilityError, MatmulSetupError};
4
5#[allow(clippy::large_enum_variant)]
6pub enum ConvSetupError {
7 Matmul(MatmulSetupError),
8 Groups(usize),
9 Unknown,
10 Launch(LaunchError),
11}
12
13impl From<LaunchError> for ConvSetupError {
14 fn from(value: LaunchError) -> Self {
15 Self::Launch(value)
16 }
17}
18
19impl Debug for ConvSetupError {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 match self {
22 ConvSetupError::Matmul(err) => {
23 write!(f, "{err:?}")
24 }
25 ConvSetupError::Groups(groups) => {
26 writeln!(
27 f,
28 "Unable to launch matmul because groups must be one, is actually {groups}",
29 )
30 }
31 ConvSetupError::Unknown => write!(f, "Unknown"),
32 ConvSetupError::Launch(err) => write!(f, "Launch error {err:?}"),
33 }
34 }
35}
36
37impl From<MatmulSetupError> for ConvSetupError {
38 fn from(value: MatmulSetupError) -> Self {
39 Self::Matmul(value)
40 }
41}
42
43impl From<MatmulAvailabilityError> for ConvSetupError {
44 fn from(value: MatmulAvailabilityError) -> Self {
45 Self::Matmul(MatmulSetupError::Unavailable(value))
46 }
47}
48
49#[allow(clippy::from_over_into)]
50impl Into<String> for ConvSetupError {
51 fn into(self) -> String {
52 format!("{self:?}")
53 }
54}