onnx_runtime_ep_api/
lib.rs1pub mod abi;
22pub mod epcontext;
23pub mod kernel;
24pub mod provider;
25pub mod registry;
26pub mod tensor;
27
28pub use epcontext::{build_ep_context_registry, EpContext, EpContextRegistry};
29pub use error::{EpError, Result};
30pub use kernel::{Cost, Kernel, KernelMatch, ViewOutput};
31pub use provider::{
32 DeviceBuffer, EpConfig, EpId, ExecutionProvider, Fence, OptimizerPass, OrtPluginExport,
33};
34pub use registry::{EpRegistry, KernelFactory, OpKey, OpRegistry};
35pub use tensor::{DevicePtr, DevicePtrMut, TensorMut, TensorView};
36
37pub use onnx_runtime_ir::{DeviceId, DeviceType};
39
40mod error {
41 use std::path::PathBuf;
42
43 pub type Result<T> = std::result::Result<T, EpError>;
45
46 #[derive(Debug, thiserror::Error)]
49 pub enum EpError {
50 #[error("no EP supports op {op_type} on any available device")]
51 NoEpForOp { op_type: String },
52
53 #[error("kernel execution failed: {0}")]
54 KernelFailed(String),
55
56 #[error("EP panicked during execution")]
57 EpPanicked,
58
59 #[error("EP plugin load failed: {path}: {reason}")]
60 EpLoadFailed { path: PathBuf, reason: String },
61
62 #[error("device OOM: requested {requested} bytes, available {available}")]
63 OutOfMemory { requested: usize, available: usize },
64
65 #[error("allocation alignment mismatch")]
66 AlignmentError,
67
68 #[error("invalid tensor view: {reason}")]
69 InvalidTensorView { reason: String },
70
71 #[error("EP not initialized")]
72 NotInitialized,
73
74 #[error("no EP is registered for EPContext source key {source_key:?}")]
75 NoEpForContext { source_key: Option<String> },
76
77 #[error("EP {ep} does not support EPContext save/load")]
78 UnsupportedContext { ep: String },
79
80 #[error(
81 "duplicate EPContext source key {source_key:?}: already registered to {existing:?}, \
82 cannot re-register to {new:?}"
83 )]
84 DuplicateContextSource {
85 source_key: String,
86 existing: crate::provider::EpId,
87 new: crate::provider::EpId,
88 },
89
90 #[error(transparent)]
91 Ir(#[from] onnx_runtime_ir::IrError),
92 }
93}