provider

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package provider defines the ExecutionProvider interface for routing ONNX operator execution to different compute backends (CPU, GPU). Providers are queried in priority order; the first provider that supports a given op type handles execution. CPUProvider serves as the universal fallback and should always be last in the chain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CPUProvider

type CPUProvider struct{}

CPUProvider executes all operators registered in the ops registry on the CPU. It is stateless and serves as the universal fallback provider.

func (*CPUProvider) Close

func (p *CPUProvider) Close() error

Close is a no-op for the CPU provider since it holds no resources.

func (*CPUProvider) Execute

func (p *CPUProvider) Execute(opType string, inputs []*tensor.Tensor, _, _ []string, attributes map[string]*onnx.Attribute, alloc tensor.Allocator) ([]*tensor.Tensor, error)

Execute retrieves the operator from the ops registry and delegates execution to it. The inputNames and outputNames parameters are accepted for interface compliance but ignored by the CPU provider.

func (*CPUProvider) Supports

func (p *CPUProvider) Supports(opType string) bool

Supports returns true if the ops registry contains an operator for the given op type.

type ExecutionProvider

type ExecutionProvider interface {
	// Supports reports whether this provider handles the given ONNX op type.
	Supports(opType string) bool

	// Execute runs the operator identified by opType on the given inputs.
	// inputNames and outputNames carry the ONNX graph tensor names so that
	// providers (e.g., GPUProvider) can register output buffers by name.
	Execute(opType string, inputs []*tensor.Tensor, inputNames, outputNames []string, attributes map[string]*onnx.Attribute, alloc tensor.Allocator) ([]*tensor.Tensor, error)

	// Close releases any resources held by the provider (e.g., GPU device, buffers).
	Close() error
}

ExecutionProvider abstracts operator execution across compute backends. The engine queries providers in priority order and dispatches to the first provider that reports support for the requested op type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL