Documentation ¶
Overview ¶
Example (Gorgonia) ¶
package main import ( "fmt" "io/ioutil" "log" "github.com/tynrol/onnx-go" "github.com/tynrol/onnx-go/backend/x/gorgonnx" "gorgonia.org/tensor" ) var input tensor.Tensor func main() { // Create a backend receiver backend := gorgonnx.NewGraph() // Create a model and set the execution backend model := onnx.NewModel(backend) // read the onnx model b, _ := ioutil.ReadFile("model.onnx") // Decode it into the model err := model.UnmarshalBinary(b) if err != nil { log.Fatal(err) } // Set the first input, the number depends of the model model.SetInput(0, input) err = backend.Run() if err != nil { log.Fatal(err) } // Check error output, _ := model.GetOutputTensors() // write the first output to stdout fmt.Println(output[0]) }
Output:
Example (Simple) ¶
// START SIMPLE // Create a backend receiver backend := simple.NewSimpleGraph() // Create a model and set the execution backend model := onnx.NewModel(backend) // read the onnx model b, _ := ioutil.ReadFile("model.onnx") // Decode it into the model err := model.UnmarshalBinary(b) // END SIMPLE if err != nil { log.Fatal(err) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Backend ¶
type Backend interface { OperationCarrier graph.DirectedWeightedBuilder }
Backend represent any backend able to receive a computation graph
type DataCarrier ¶
DataCarrier is node with the ability to carry a tensor data
type Documenter ¶
Documenter is an interface that describe any object able to document itself
type ErrNotImplemented ¶
type ErrNotImplemented struct { Operator string AttributeName string AttributeValue interface{} Message string }
ErrNotImplemented is returned for any operator or attribute
func (*ErrNotImplemented) Error ¶
func (e *ErrNotImplemented) Error() string
type InvalidUnmarshalError ¶
An InvalidUnmarshalError describes an invalid argument passed to Unmarshal. (The argument to Unmarshal must be a non-nil pointer.)
func (*InvalidUnmarshalError) Error ¶
func (e *InvalidUnmarshalError) Error() string
type Model ¶
Model is a wrapper around a computation graph. Input and Output are containing the ID of the corresponding nodes.
func (*Model) GetInputTensors ¶
GetInpuTensors from the graph. This function is useful to get informations if the tensor is a placeholder and does not contain any data yet.
func (*Model) GetNodeByName ¶
GetNodeByName is a utility method that returns a node of the computation graph
func (*Model) GetOutputTensors ¶
GetOutputTensors of the graph
func (*Model) UnmarshalBinary ¶
UnmarshalBinary decodes the binary data in onnx format into the model
type OperationCarrier ¶
type OperationCarrier interface { // ApplyOperation on the graph nodes // graph.Node is an array because it allows to handle multiple output // for example a split operation returns n nodes... ApplyOperation(Operation, ...graph.Node) error }
OperationCarrier should be a method of the graph because the operation needs the topology of the graph to check the arity of the node for example
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
simple
Package simple holds a very simple graph structure suitable to receive an onnx model
|
Package simple holds a very simple graph structure suitable to receive an onnx model |
testbackend
Package testbackend provides a set of testing helper functions that test backend interface implementations.
|
Package testbackend provides a set of testing helper functions that test backend interface implementations. |
testbackend/onnx
Package onnxtest contains an export of the onnx test files
|
Package onnxtest contains an export of the onnx test files |
x/gorgonnx
Package gorgonnx creates a temporary graph that is compatible with backend.ComputationBackend.
|
Package gorgonnx creates a temporary graph that is compatible with backend.ComputationBackend. |
doc
|
|
introduction
Present displays slide presentations and articles.
|
Present displays slide presentations and articles. |
examples
|
|
internal
|
|
misc
|
|