pub trait ExecutionProvider: Send + Sync {
Show 18 methods
// Required methods
fn name(&self) -> &str;
fn device_type(&self) -> DeviceType;
fn device_id(&self) -> DeviceId;
fn initialize(&mut self, config: &EpConfig) -> Result<()>;
fn shutdown(&mut self) -> Result<()>;
fn supports_op(
&self,
op: &Node,
shapes: &[Shape],
layouts: &[TensorLayout],
) -> KernelMatch;
fn get_kernel(
&self,
op: &Node,
shapes: &[Vec<usize>],
opset: u64,
) -> Result<Box<dyn Kernel>>;
fn allocate(&self, size: usize, alignment: usize) -> Result<DeviceBuffer>;
fn deallocate(&self, buffer: DeviceBuffer) -> Result<()>;
fn copy(
&self,
src: &DeviceBuffer,
dst: &mut DeviceBuffer,
size: usize,
) -> Result<()>;
fn copy_async(
&self,
src: &DeviceBuffer,
dst: &mut DeviceBuffer,
size: usize,
) -> Result<Fence>;
fn sync(&self) -> Result<()>;
// Provided methods
fn as_ort_plugin(&self) -> Option<OrtPluginExport> { ... }
fn custom_passes(&self) -> Vec<Box<dyn OptimizerPass>> { ... }
fn claim_nodes(&self, graph: &Graph) -> Vec<NodeId> { ... }
fn context_source_keys(&self) -> Vec<String> { ... }
fn save_context(&self) -> Result<EpContext> { ... }
fn load_context(&self, ctx: &EpContext) -> Result<()> { ... }
}Expand description
The core EP interface. Every backend crate implements this (§4.1).
Required Methods§
fn device_type(&self) -> DeviceType
fn device_id(&self) -> DeviceId
Sourcefn initialize(&mut self, config: &EpConfig) -> Result<()>
fn initialize(&mut self, config: &EpConfig) -> Result<()>
Initialize device resources / load libraries.
Sourcefn supports_op(
&self,
op: &Node,
shapes: &[Shape],
layouts: &[TensorLayout],
) -> KernelMatch
fn supports_op( &self, op: &Node, shapes: &[Shape], layouts: &[TensorLayout], ) -> KernelMatch
Whether this EP can run op with the given input shapes and layouts,
and at what cost.
Sourcefn get_kernel(
&self,
op: &Node,
shapes: &[Vec<usize>],
opset: u64,
) -> Result<Box<dyn Kernel>>
fn get_kernel( &self, op: &Node, shapes: &[Vec<usize>], opset: u64, ) -> Result<Box<dyn Kernel>>
Get or create a kernel for op specialized to concrete shapes.
opset is the effective operator-set version for op’s domain in the
owning graph. EPs use it to select opset-specialized kernels (e.g. the
opset-13 per-axis vs. the legacy opset-<13 2D-coercion Softmax).
Sourcefn allocate(&self, size: usize, alignment: usize) -> Result<DeviceBuffer>
fn allocate(&self, size: usize, alignment: usize) -> Result<DeviceBuffer>
Allocate device memory.
Sourcefn deallocate(&self, buffer: DeviceBuffer) -> Result<()>
fn deallocate(&self, buffer: DeviceBuffer) -> Result<()>
Free device memory.
Sourcefn copy(
&self,
src: &DeviceBuffer,
dst: &mut DeviceBuffer,
size: usize,
) -> Result<()>
fn copy( &self, src: &DeviceBuffer, dst: &mut DeviceBuffer, size: usize, ) -> Result<()>
Synchronous copy (host↔device or device↔device).
Sourcefn copy_async(
&self,
src: &DeviceBuffer,
dst: &mut DeviceBuffer,
size: usize,
) -> Result<Fence>
fn copy_async( &self, src: &DeviceBuffer, dst: &mut DeviceBuffer, size: usize, ) -> Result<Fence>
Asynchronous copy; returns a Fence to await.
Provided Methods§
Sourcefn as_ort_plugin(&self) -> Option<OrtPluginExport>
fn as_ort_plugin(&self) -> Option<OrtPluginExport>
Export this EP as an ORT C ABI plugin, if supported (Phase 2).
Sourcefn custom_passes(&self) -> Vec<Box<dyn OptimizerPass>>
fn custom_passes(&self) -> Vec<Box<dyn OptimizerPass>>
EP-specific optimization passes, run after the generic optimizer.
Sourcefn claim_nodes(&self, graph: &Graph) -> Vec<NodeId>
fn claim_nodes(&self, graph: &Graph) -> Vec<NodeId>
Nodes this EP claims unconditionally (bypassing cost-model placement).
Sourcefn context_source_keys(&self) -> Vec<String>
fn context_source_keys(&self) -> Vec<String>
The EPContext node source key(s) this EP accepts for compiled-context
dispatch (docs/ORT2.md §55.6). The keys come from the EP’s own
config/data — never hardcoded in loader/session dispatch. An empty
list (the default) means the EP does not participate in EPContext
(e.g. the pure-Rust CPU EP has no compile step).
Sourcefn save_context(&self) -> Result<EpContext>
fn save_context(&self) -> Result<EpContext>
Produce the runtime EpContext for this EP’s freshly compiled subgraph
(the §55.4 dump path calls this). Default: unsupported — an EP with no
compile step returns EpError::UnsupportedContext.
Sourcefn load_context(&self, ctx: &EpContext) -> Result<()>
fn load_context(&self, ctx: &EpContext) -> Result<()>
Restore this EP from a runtime EpContext, skipping convert+compile
(the §55.3 load path calls this). Default: unsupported — an EP that does
not consume EPContext returns EpError::UnsupportedContext.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".