Documentation
¶
Overview ¶
Package operators implements ONNX operator mapping to Born tensor operations.
The package provides a registry of operator handlers that convert ONNX nodes to equivalent Born operations. Each handler validates inputs and attributes, then delegates to the appropriate backend operation.
Supported operator tiers:
- Tier 1 (Essential): Basic math, activations, convolutions - for ResNet, MobileNet
- Tier 2 (Extended): Advanced ops for transformers and attention models
Package operators provides ONNX operator implementations.
Index ¶
- Constants
- func GetAttrFloat(node *Node, name string, defaultVal float32) float32
- func GetAttrInt(node *Node, name string, defaultVal int64) int64
- func GetAttrInts(node *Node, name string) []int64
- func GetAttrString(node *Node, name, defaultVal string) string
- type Attribute
- type Context
- type Node
- type OpHandler
- type Registry
Constants ¶
const ( TensorProtoUndefined = 0 TensorProtoFloat = 1 // float32 TensorProtoUint8 = 2 // uint8 TensorProtoInt8 = 3 // int8 TensorProtoUint16 = 4 // uint16 TensorProtoInt16 = 5 // int16 TensorProtoInt32 = 6 // int32 TensorProtoInt64 = 7 // int64 TensorProtoString = 8 // string TensorProtoBool = 9 // bool TensorProtoFloat16 = 10 // float16 TensorProtoDouble = 11 // float64 TensorProtoUint32 = 12 // uint32 TensorProtoUint64 = 13 // uint64 )
ONNX data types (TensorProto.DataType).
Variables ¶
This section is empty.
Functions ¶
func GetAttrFloat ¶
GetAttrFloat returns a float attribute or default value.
func GetAttrInt ¶
GetAttrInt returns an integer attribute or default value.
func GetAttrInts ¶
GetAttrInts returns an integer array attribute.
func GetAttrString ¶
GetAttrString returns a string attribute or default value.
Types ¶
type Attribute ¶
type Attribute struct {
Name string // Attribute name
Type int32 // Attribute type
F float32 // FLOAT value
I int64 // INT value
S []byte // STRING value
T *tensor.RawTensor // TENSOR value
Floats []float32 // FLOATS array
Ints []int64 // INTS array
Strings [][]byte // STRINGS array
}
Attribute represents a node attribute.
type Node ¶
type Node struct {
Name string // Node name (optional)
OpType string // Operation type (e.g., "Conv", "MatMul", "Relu")
Inputs []string // Input tensor names
Outputs []string // Output tensor names
Attributes []Attribute // Operation attributes
Domain string // Custom domain (empty for default)
}
Node represents an ONNX operation node. This is a local copy of the relevant fields from onnx.NodeProto to avoid import cycles between onnx and operators packages.
type OpHandler ¶
type OpHandler func(ctx *Context, node *Node, inputs []*tensor.RawTensor) ([]*tensor.RawTensor, error)
OpHandler processes an ONNX node and returns output tensors.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry maps ONNX operator types to handler functions.
func NewRegistry ¶
func NewRegistry() *Registry
NewRegistry creates a new operator registry with all supported operators.
func (*Registry) Execute ¶
func (r *Registry) Execute(ctx *Context, node *Node, inputs []*tensor.RawTensor) ([]*tensor.RawTensor, error)
Execute runs an operator with the given inputs.
func (*Registry) SupportedOps ¶
SupportedOps returns a list of all supported operator types.