1use std::path::PathBuf;
2
3use tenferro_tensor::DType;
4
5#[derive(Debug, thiserror::Error)]
23pub enum Error {
24 #[error("XLA lowering does not support dtype {dtype:?} in {context}")]
25 UnsupportedDType { dtype: DType, context: &'static str },
26 #[error("XLA lowering does not support ExecOp::{op}: {reason}")]
27 UnsupportedOp {
28 op: &'static str,
29 reason: &'static str,
30 },
31 #[error(
32 "XLA lowering supports only exact static shapes; ExecOp::{op} output {output_index} axis {axis} is {kind}"
33 )]
34 NonStaticShape {
35 op: &'static str,
36 output_index: usize,
37 axis: usize,
38 kind: &'static str,
39 },
40 #[error("invalid XLA program: {message}")]
41 InvalidProgram { message: String },
42 #[error("PJRT support requires enabling the tenferro-xla `pjrt` feature")]
43 PjrtFeatureDisabled,
44 #[error("PJRT execution requires an executor created from a loaded plugin")]
45 PjrtPluginNotLoaded,
46 #[error("PJRT call {call} failed: {message}")]
47 PjrtCall { call: &'static str, message: String },
48 #[error("environment variable {var} is not set; set it to a PJRT plugin .so path")]
49 MissingEnv { var: &'static str },
50 #[error("failed to load PJRT plugin from {path}: {message}")]
51 PluginLoad { path: PathBuf, message: String },
52}
53
54pub type Result<T> = std::result::Result<T, Error>;