Skip to main content

ExecutionProvider

Trait ExecutionProvider 

Source
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§

Source

fn name(&self) -> &str

EP identifier (snake_case, e.g. "cpu_ep", "cuda_ep").

Source

fn device_type(&self) -> DeviceType

Source

fn device_id(&self) -> DeviceId

Source

fn initialize(&mut self, config: &EpConfig) -> Result<()>

Initialize device resources / load libraries.

Source

fn shutdown(&mut self) -> Result<()>

Release device resources.

Source

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.

Source

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).

Source

fn allocate(&self, size: usize, alignment: usize) -> Result<DeviceBuffer>

Allocate device memory.

Source

fn deallocate(&self, buffer: DeviceBuffer) -> Result<()>

Free device memory.

Source

fn copy( &self, src: &DeviceBuffer, dst: &mut DeviceBuffer, size: usize, ) -> Result<()>

Synchronous copy (host↔device or device↔device).

Source

fn copy_async( &self, src: &DeviceBuffer, dst: &mut DeviceBuffer, size: usize, ) -> Result<Fence>

Asynchronous copy; returns a Fence to await.

Source

fn sync(&self) -> Result<()>

Block until all pending work on this EP completes.

Provided Methods§

Source

fn as_ort_plugin(&self) -> Option<OrtPluginExport>

Export this EP as an ORT C ABI plugin, if supported (Phase 2).

Source

fn custom_passes(&self) -> Vec<Box<dyn OptimizerPass>>

EP-specific optimization passes, run after the generic optimizer.

Source

fn claim_nodes(&self, graph: &Graph) -> Vec<NodeId>

Nodes this EP claims unconditionally (bypassing cost-model placement).

Source

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).

Source

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.

Source

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".

Implementors§