onnx_runtime_ep_api/
lib.rs1pub mod abi;
23pub mod epcontext;
24pub mod kernel;
25pub mod provider;
26pub mod registry;
27pub mod tensor;
28pub mod weight;
29
30pub use epcontext::{EpContext, EpContextRegistry, build_ep_context_registry};
31pub use error::{EpError, Result};
32pub use kernel::{
33 ARG_KERNEL_VARIANT, ARG_KERNEL_VARIANT_REASON, CaptureSupport, Cost, Kernel, KernelInput,
34 KernelMatch, KernelVariantSelection, ViewOutput, kernel_variant_tracing_enabled,
35 record_kernel_variant_selection, record_kernel_variant_stage_selection,
36};
37pub use onnx_runtime_optimizer::OptimizationPass as OptimizerPass;
38pub use provider::{DeviceBuffer, EpConfig, EpId, ExecutionProvider, Fence, OrtPluginExport};
39pub use registry::{EpRegistry, KernelFactory, OpKey, OpRegistry};
40pub use tensor::{
41 DevicePtr, DevicePtrMut, ExternalMmapRegion, TensorBacking, TensorMut, TensorView,
42};
43pub use weight::{
44 ExecutionProviderCapabilities, LazyDeviceWeightBinder, LazyWeight, LazyWeightBoundary,
45 NXRT_WEIGHT_PAGING_CAPABILITY, NegotiatedWeight, Phase3aHostOnlyBinder, ResidentWeight,
46 ResidentWeightMaterializer, WeightHandle, WeightHandleError,
47};
48
49pub use onnx_runtime_ir::{DeviceId, DeviceType};
51
52mod error {
53 use std::path::PathBuf;
54
55 pub type Result<T> = std::result::Result<T, EpError>;
57
58 #[derive(Debug, thiserror::Error)]
61 pub enum EpError {
62 #[error("no EP handler for {domain}::{op_type} at opset {opset} on any available device")]
63 NoEpForOp {
64 domain: String,
65 op_type: String,
66 opset: u64,
67 },
68
69 #[error("kernel execution failed: {0}")]
70 KernelFailed(String),
71
72 #[error("EP panicked during execution")]
73 EpPanicked,
74
75 #[error("EP plugin load failed: {path}: {reason}")]
76 EpLoadFailed { path: PathBuf, reason: String },
77
78 #[error("device OOM: requested {requested} bytes, available {available}")]
79 OutOfMemory { requested: usize, available: usize },
80
81 #[error("allocation alignment mismatch")]
82 AlignmentError,
83
84 #[error("invalid tensor view: {reason}")]
85 InvalidTensorView { reason: String },
86
87 #[error("EP not initialized")]
88 NotInitialized,
89
90 #[error("no EP is registered for EPContext source key {source_key:?}")]
91 NoEpForContext { source_key: Option<String> },
92
93 #[error("EP {ep} does not support EPContext save/load")]
94 UnsupportedContext { ep: String },
95
96 #[error(
97 "duplicate EPContext source key {source_key:?}: already registered to {existing:?}, \
98 cannot re-register to {new:?}"
99 )]
100 DuplicateContextSource {
101 source_key: String,
102 existing: crate::provider::EpId,
103 new: crate::provider::EpId,
104 },
105
106 #[error(transparent)]
107 Ir(#[from] onnx_runtime_ir::IrError),
108
109 #[error(transparent)]
110 WeightHandle(#[from] crate::weight::WeightHandleError),
111 }
112}