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