hpt_common/error/
kernel.rs1use std::panic::Location;
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum KernelError {
8 #[error("Kernel compilation failed: {message} at {location}")]
10 CompilationFailed {
11 message: String,
13 location: &'static Location<'static>,
15 },
16
17 #[error("Kernel execution failed: {message} at {location}")]
19 ExecutionFailed {
20 message: String,
22 location: &'static Location<'static>,
24 },
25
26 #[error("CUDA kernel region info not found for module: {module}, func_name: {func_name}")]
28 CudaKernelRegInfoNotFound {
29 module: String,
31 func_name: String,
33 location: &'static Location<'static>,
35 },
36
37 #[error(
39 "CUDA kernel meta data not found for module: {module}, func_name: {func_name}, cap: {cap}"
40 )]
41 CudaKernelMetaNotFound {
42 cap: usize,
44 module: String,
46 func_name: String,
48 location: &'static Location<'static>,
50 },
51
52 #[error("CUDA kernel launch config error: {msg}")]
54 LaunchConfigError {
55 msg: String,
57 location: &'static Location<'static>,
59 },
60}
61
62#[cfg(feature = "cuda")]
63mod impls {
64 use crate::error::base::TensorError;
65 use crate::error::kernel::KernelError;
66 use std::panic::Location;
67 impl From<cudarc::nvrtc::CompileError> for TensorError {
68 fn from(source: cudarc::nvrtc::CompileError) -> Self {
69 Self::Kernel(KernelError::CompilationFailed {
70 message: source.to_string(),
71 location: Location::caller(),
72 })
73 }
74 }
75}