Documentation
¶
Index ¶
- Constants
- func HasNvidiaGPU() bool
- func IsSupportedPlatform() bool
- func LoadModel(backend compute.Backend, r io.Reader) (compute.Executable, error)
- func New(config string) (compute.Backend, error)
- func SaveModel(backend compute.Backend, executable compute.Executable, w io.Writer, ...) error
- type Backend
- func (b *Backend) BufferFromFlatData(deviceNum compute.DeviceNum, flat any, shape shapes.Shape) (compute.Buffer, error)
- func (b *Backend) Builder(name string) compute.Builder
- func (b *Backend) Capabilities() compute.Capabilities
- func (b *Backend) Description() string
- func (b *Backend) DeviceDescription(deviceNum compute.DeviceNum) string
- func (b *Backend) Finalize()
- func (b *Backend) HasSharedBuffers() bool
- func (b *Backend) IsFinalized() bool
- func (b *Backend) KeepModelProto() bool
- func (b *Backend) Name() string
- func (b *Backend) NewSharedBuffer(deviceNum compute.DeviceNum, shape shapes.Shape) (compute.Buffer, any, error)
- func (b *Backend) NumDevices() int
- func (b *Backend) SetKeepModelProto(keep bool)
- func (b *Backend) String() string
- type Buffer
- func (b *Buffer) Backend() compute.Backend
- func (b *Buffer) CopyToDevice(deviceNum compute.DeviceNum) (compute.Buffer, error)
- func (b *Buffer) Data() (flat any, err error)
- func (b *Buffer) DeviceNum() (compute.DeviceNum, error)
- func (b *Buffer) Finalize() error
- func (b *Buffer) Shape() (shapes.Shape, error)
- func (b *Buffer) ToFlatData(flat any) error
- type Builder
- func (b *Builder) Compile() (compute.Executable, error)
- func (b *Builder) DeviceAssignment(devices ...compute.DeviceNum) error
- func (b *Builder) Main() compute.Function
- func (b *Builder) Name() string
- func (b *Builder) NewFunction(name string) (compute.Function, error)
- func (b *Builder) OpShape(op compute.Value) (shapes.Shape, error)
- type Executable
- func (e *Executable) Execute(inputs []compute.Buffer, donate []bool, defaultDevice compute.DeviceNum) ([]compute.Buffer, error)
- func (e *Executable) Finalize()
- func (e *Executable) Inputs() (names []string, inputShapes []shapes.Shape)
- func (e *Executable) ModelProto() *onnx.ModelProto
- func (e *Executable) Outputs() (outputShapes []shapes.Shape)
- type Function
- func (f *Function) Abs(x compute.Value) (compute.Value, error)
- func (f *Function) Add(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) ArgMinMax(x compute.Value, axis int, outputDType dtypes.DType, isMin bool) (compute.Value, error)
- func (f *Function) BitwiseAnd(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) BitwiseOr(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) BitwiseXor(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) BroadcastInDim(x compute.Value, outputShape shapes.Shape, broadcastAxes []int) (compute.Value, error)
- func (f *Function) Builder() compute.Builder
- func (f *Function) Ceil(x compute.Value) (compute.Value, error)
- func (f *Function) Concatenate(axis int, inputs ...compute.Value) (compute.Value, error)
- func (f *Function) Constant(flat any, dims ...int) (compute.Value, error)
- func (f *Function) ConvGeneral(input, kernel compute.Value, axes compute.ConvolveAxesConfig, strides []int, ...) (compute.Value, error)
- func (f *Function) ConvertDType(operand compute.Value, targetDType dtypes.DType) (compute.Value, error)
- func (f *Function) Cos(x compute.Value) (compute.Value, error)
- func (f *Function) Div(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) DotGeneral(lhs compute.Value, lhsContractingAxes []int, lhsBatchAxes []int, ...) (compute.Value, error)
- func (f *Function) DynamicDimensionSize(operand compute.Value, axis int) (compute.Value, error)
- func (f *Function) DynamicReshape(operand compute.Value, dimensions ...compute.DynamicDimensionSpec) (compute.Value, error)
- func (f *Function) DynamicShape(operand compute.Value) (compute.Value, error)
- func (f *Function) DynamicSlice(operand compute.Value, startIndices []compute.Value, sliceDims []int) (compute.Value, error)
- func (f *Function) DynamicUpdateSlice(operand, update compute.Value, startIndices []compute.Value) (compute.Value, error)
- func (f *Function) Equal(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) Erf(x compute.Value) (compute.Value, error)
- func (f *Function) Exp(x compute.Value) (compute.Value, error)
- func (f *Function) Floor(x compute.Value) (compute.Value, error)
- func (f *Function) FusedAttentionQKVProjection(x, wQKV, biasQ, biasK, biasV compute.Value, queryDim, keyValueDim int) (query, key, value compute.Value, err error)
- func (f *Function) FusedDense(x, weight, bias compute.Value, options compute.DenseConfig) (compute.Value, error)
- func (f *Function) FusedGelu(x compute.Value, exact bool) (compute.Value, error)
- func (f *Function) FusedLayerNorm(x compute.Value, axes []int, epsilon float64, gamma, beta compute.Value) (compute.Value, error)
- func (f *Function) FusedQuantizedDense(x, weights, bias compute.Value, weightsQuantization *compute.Quantization, ...) (compute.Value, error)
- func (f *Function) FusedScaledDotProductAttention(query, key, value compute.Value, axesLayout compute.AttentionAxesLayout, ...) (output compute.Value, statesForVJP []compute.Value, err error)
- func (f *Function) FusedScaledDotProductAttentionVJP(query, key, value compute.Value, axesLayout compute.AttentionAxesLayout, ...) (dQuery, dKey, dValue compute.Value, err error)
- func (f *Function) FusedSoftmax(x compute.Value, axis int) (compute.Value, error)
- func (f *Function) Gather(operand compute.Value, startIndices compute.Value, indexVectorAxis int, ...) (compute.Value, error)
- func (f *Function) GreaterOrEqual(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) GreaterThan(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) Identity(x compute.Value) (compute.Value, error)
- func (f *Function) Iota(shape shapes.Shape, iotaAxis int) (compute.Value, error)
- func (f *Function) LessOrEqual(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) LessThan(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) Log(x compute.Value) (compute.Value, error)
- func (f *Function) Log1p(x compute.Value) (compute.Value, error)
- func (f *Function) LogicalAnd(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) LogicalNot(x compute.Value) (compute.Value, error)
- func (f *Function) LogicalOr(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) LogicalXor(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) Logistic(x compute.Value) (compute.Value, error)
- func (f *Function) Max(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) Min(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) Mul(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) Name() string
- func (f *Function) Neg(x compute.Value) (compute.Value, error)
- func (f *Function) NotEqual(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) Parameter(name string, shape shapes.Shape, spec *compute.ShardingSpec) (compute.Value, error)
- func (f *Function) Parent() compute.Function
- func (f *Function) Pow(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) QuantizedEmbeddingLookup(data, indices compute.Value, dataQuantization *compute.Quantization) (compute.Value, error)
- func (f *Function) RNGBitGenerator(state compute.Value, shape shapes.Shape) (newState compute.Value, values compute.Value, err error)
- func (f *Function) Reduce(x compute.Value, opType compute.OpType, axes []int, keepDims bool) (compute.Value, error)
- func (f *Function) ReduceLogical(x compute.Value, opType compute.OpType, axes []int, keepDims bool) (compute.Value, error)
- func (f *Function) ReduceLogicalAnd(x compute.Value, axes ...int) (compute.Value, error)
- func (f *Function) ReduceLogicalOr(x compute.Value, axes ...int) (compute.Value, error)
- func (f *Function) ReduceLogicalXor(x compute.Value, axes ...int) (compute.Value, error)
- func (f *Function) ReduceMax(x compute.Value, axes ...int) (compute.Value, error)
- func (f *Function) ReduceMin(x compute.Value, axes ...int) (compute.Value, error)
- func (f *Function) ReduceProduct(x compute.Value, axes ...int) (compute.Value, error)
- func (f *Function) ReduceSum(x compute.Value, axes ...int) (compute.Value, error)
- func (f *Function) ReduceWindow(operand compute.Value, reductionType compute.ReduceOpType, ...) (compute.Value, error)
- func (f *Function) Rem(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) Reshape(x compute.Value, newDimensions ...int) (compute.Value, error)
- func (f *Function) Return(outputs []compute.Value, shardings []*compute.ShardingSpec) error
- func (f *Function) Reverse(x compute.Value, axes ...int) (compute.Value, error)
- func (f *Function) Round(x compute.Value) (compute.Value, error)
- func (f *Function) ScatterMax(operand, scatterIndices, updates compute.Value, indexVectorAxis int, ...) (compute.Value, error)
- func (f *Function) ScatterMin(operand, scatterIndices, updates compute.Value, indexVectorAxis int, ...) (compute.Value, error)
- func (f *Function) ScatterSum(operand, scatterIndices, updates compute.Value, indexVectorAxis int, ...) (compute.Value, error)
- func (f *Function) SchedulingBarrier(operand compute.Value, dependencies ...compute.Value) (compute.Value, error)
- func (f *Function) SelectAndScatterMax(operand compute.Value, source compute.Value, windowDimensions []int, ...) (compute.Value, error)
- func (f *Function) Shape(v compute.Value) (shapes.Shape, error)
- func (f *Function) ShiftLeft(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) ShiftRightLogical(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) Sign(x compute.Value) (compute.Value, error)
- func (f *Function) Sin(x compute.Value) (compute.Value, error)
- func (f *Function) Slice(x compute.Value, start []int, limit []int, stride []int) (compute.Value, error)
- func (f *Function) Sqrt(x compute.Value) (compute.Value, error)
- func (f *Function) Sub(lhs, rhs compute.Value) (compute.Value, error)
- func (f *Function) Tanh(x compute.Value) (compute.Value, error)
- func (f *Function) Transpose(x compute.Value, permutation ...int) (compute.Value, error)
- func (f *Function) Where(condition compute.Value, onTrue compute.Value, onFalse compute.Value) (compute.Value, error)
- type Node
Constants ¶
const (
BackendName = "onnxruntime"
)
const NoAutoInstallEnv = "GOMLX_NO_AUTO_INSTALL"
Variables ¶
This section is empty.
Functions ¶
func HasNvidiaGPU ¶
func HasNvidiaGPU() bool
HasNvidiaGPU tries to guess if there is an actual Nvidia GPU installed.
func IsSupportedPlatform ¶
func IsSupportedPlatform() bool
IsSupportedPlatform returns true if the host OS and CPU architecture are supported by ONNX Runtime binaries.
func LoadModel ¶
LoadModel loads an ONNX model from an io.Reader and compiles it into a runnable compute.Executable. It parses input and output tensor shapes and data types directly from the ONNX ModelProto and creates an ONNX Runtime session ready for execution.
func SaveModel ¶
func SaveModel(backend compute.Backend, executable compute.Executable, w io.Writer, inputNames []string, outputNames []string) error
SaveModel exports the computation graph associated with the given executable as an ONNX model file/stream. It verifies that both backend and executable belong to the ONNX backend package. If inputNames or outputNames are provided (non-empty), they rename the graph's inputs and outputs and update all corresponding internal node edge references before saving. If inputNames or outputNames are nil or empty, default or pre-existing graph names (e.g., "arg_0", "output_0") are retained.
Note: The backend must have had KeepModelProto set to true prior to compiling the executable, otherwise SaveModel will return an error indicating that the graph proto was discarded.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend represents a ONNX Runtime backed compute.Backend.
func (*Backend) BufferFromFlatData ¶
func (*Backend) Capabilities ¶
func (b *Backend) Capabilities() compute.Capabilities
func (*Backend) Description ¶
func (*Backend) DeviceDescription ¶
func (*Backend) HasSharedBuffers ¶
func (*Backend) IsFinalized ¶
func (*Backend) KeepModelProto ¶
KeepModelProto returns whether compiled Executable instances retain their graph *onnx.ModelProto.
func (*Backend) NewSharedBuffer ¶
func (*Backend) NumDevices ¶
func (*Backend) SetKeepModelProto ¶
SetKeepModelProto controls whether compiled Executable instances retain the graph *onnx.ModelProto. When set to true, executables compiled by this backend store their ONNX ModelProto struct, allowing the computation graph to be exported via SaveModel.
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer implements compute.Buffer for ONNX Runtime.
func (*Buffer) CopyToDevice ¶
func (*Buffer) ToFlatData ¶
type Builder ¶
type Builder struct {
notimplemented.Builder
// contains filtered or unexported fields
}
func NewBuilder ¶
func (*Builder) DeviceAssignment ¶
type Executable ¶
type Executable struct {
// contains filtered or unexported fields
}
func (*Executable) Finalize ¶
func (e *Executable) Finalize()
func (*Executable) Inputs ¶
func (e *Executable) Inputs() (names []string, inputShapes []shapes.Shape)
func (*Executable) ModelProto ¶
func (e *Executable) ModelProto() *onnx.ModelProto
ModelProto returns the ONNX ModelProto struct if Backend.KeepModelProto was enabled during compilation, or nil otherwise.
func (*Executable) Outputs ¶
func (e *Executable) Outputs() (outputShapes []shapes.Shape)
type Function ¶
type Function struct {
notimplemented.Function
// contains filtered or unexported fields
}
func NewFunction ¶
func (*Function) BitwiseAnd ¶
func (*Function) BitwiseXor ¶
func (*Function) BroadcastInDim ¶
func (*Function) Concatenate ¶
func (*Function) ConvGeneral ¶
func (*Function) ConvertDType ¶
func (*Function) DotGeneral ¶
func (f *Function) DotGeneral( lhs compute.Value, lhsContractingAxes []int, lhsBatchAxes []int, rhs compute.Value, rhsContractingAxes []int, rhsBatchAxes []int, config compute.DotGeneralConfig, ) (compute.Value, error)
DotGeneral performs a general dot product (matrix multiplication) of lhs and rhs. It maps the generalized contracting and batching axes of XLA semantics to ONNX Einsum.
func (*Function) DynamicDimensionSize ¶
func (*Function) DynamicReshape ¶
func (*Function) DynamicShape ¶
func (*Function) DynamicSlice ¶
func (*Function) DynamicUpdateSlice ¶
func (*Function) FusedAttentionQKVProjection ¶
func (f *Function) FusedAttentionQKVProjection( x, wQKV, biasQ, biasK, biasV compute.Value, queryDim, keyValueDim int) (query, key, value compute.Value, err error)
FusedAttentionQKVProjection performs fused Query-Key-Value projection.
func (*Function) FusedDense ¶
func (f *Function) FusedDense(x, weight, bias compute.Value, options compute.DenseConfig) (compute.Value, error)
FusedDense performs fused matmul + optional bias + optional activation.
func (*Function) FusedGelu ¶
FusedGelu computes Gaussian Error Linear Unit activation using ONNX Gelu (opset 20+).
func (*Function) FusedLayerNorm ¶
func (f *Function) FusedLayerNorm(x compute.Value, axes []int, epsilon float64, gamma, beta compute.Value) (compute.Value, error)
FusedLayerNorm applies layer normalization over specified axes using ONNX LayerNormalization (opset 17+).
func (*Function) FusedQuantizedDense ¶
func (f *Function) FusedQuantizedDense(x, weights, bias compute.Value, weightsQuantization *compute.Quantization, activation compute.ActivationType) (compute.Value, error)
FusedQuantizedDense performs fused dequantization + matmul + optional bias + optional activation.
func (*Function) FusedScaledDotProductAttention ¶
func (f *Function) FusedScaledDotProductAttention( query, key, value compute.Value, axesLayout compute.AttentionAxesLayout, options *compute.ScaledDotProductAttentionConfig) (output compute.Value, statesForVJP []compute.Value, err error)
FusedScaledDotProductAttention computes multi-head scaled dot-product attention.
func (*Function) FusedScaledDotProductAttentionVJP ¶
func (f *Function) FusedScaledDotProductAttentionVJP( query, key, value compute.Value, axesLayout compute.AttentionAxesLayout, options *compute.ScaledDotProductAttentionConfig, output compute.Value, statesForVJP []compute.Value, dOutput compute.Value) (dQuery, dKey, dValue compute.Value, err error)
FusedScaledDotProductAttentionVJP computes gradients of FusedScaledDotProductAttention.
func (*Function) FusedSoftmax ¶
FusedSoftmax computes softmax along the specified axis using ONNX Softmax.
func (*Function) Gather ¶
func (f *Function) Gather( operand compute.Value, startIndices compute.Value, indexVectorAxis int, offsetOutputAxes []int, collapsedSliceAxes []int, startIndexMap []int, sliceSizes []int, indicesAreSorted bool, ) (compute.Value, error)
Gather gathers slices from operand using coordinates specified by startIndices. It maps the generalized XLA Gather semantics to ONNX GatherND, Reshape, and Transpose.
func (*Function) GreaterOrEqual ¶
func (*Function) GreaterThan ¶
func (*Function) LessOrEqual ¶
func (*Function) LogicalAnd ¶
func (*Function) LogicalXor ¶
func (*Function) QuantizedEmbeddingLookup ¶
func (f *Function) QuantizedEmbeddingLookup(data, indices compute.Value, dataQuantization *compute.Quantization) (compute.Value, error)
QuantizedEmbeddingLookup performs a quantized embedding lookup with on-the-fly dequantization.
func (*Function) RNGBitGenerator ¶
func (f *Function) RNGBitGenerator(state compute.Value, shape shapes.Shape) (newState compute.Value, values compute.Value, err error)
RNGBitGenerator generates a tensor of the requested shape filled with random bits. It receives a state of shape [3]uint64 containing [seed/key, counter_low, counter_high]. It implements SplitMix64 PRNG algorithm inside the ONNX graph.
func (*Function) ReduceLogical ¶
func (*Function) ReduceLogicalAnd ¶
func (*Function) ReduceLogicalOr ¶
func (*Function) ReduceLogicalXor ¶
func (*Function) ReduceProduct ¶
func (*Function) ReduceWindow ¶
func (*Function) ScatterMax ¶
func (*Function) ScatterMin ¶
func (*Function) ScatterSum ¶
func (*Function) SchedulingBarrier ¶
func (f *Function) SchedulingBarrier(operand compute.Value, dependencies ...compute.Value) (compute.Value, error)
SchedulingBarrier introduces a scheduling barrier. Returned value is identity to the operand, but it is guaranteed to depend on all the dependencies.
Since ONNX Runtime doesn't natively support a scheduling barrier op, we "hack" it by means of a no-op: taking a scalar of each dependency, multiplying by 0, and adding them to the operand.
func (*Function) SelectAndScatterMax ¶
func (*Function) ShiftRightLogical ¶
Source Files
¶
- backend.go
- buffer.go
- builder.go
- compile.go
- executable.go
- function.go
- gpu_detect_linux.go
- ops.go
- ops_binary.go
- ops_comparison.go
- ops_convgeneral.go
- ops_dotgeneral.go
- ops_fused.go
- ops_gather.go
- ops_logical.go
- ops_reducewindow.go
- ops_reduction.go
- ops_rng.go
- ops_scatter.go
- ops_selectandscatter.go
- ops_special.go
- ops_unary.go
- save.go
- schedulingbarrier.go
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
onnxruntime_installer
module
|
|
|
internal
|
|
|
cmd/update_c_ort
command
|
|
|
cmd/update_protos
command
|
|
|
protos
Package protos contains the protobuf generated code for the ONNX format.
|
Package protos contains the protobuf generated code for the ONNX format. |
|
support
|
|