Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Benchmarks #69

Merged
merged 8 commits into from
May 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions bench_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package onnx_test

import (
"testing"

"github.com/owulveryck/onnx-go"
"github.com/owulveryck/onnx-go/backend/x/gorgonnx"
"github.com/owulveryck/onnx-go/internal/examples/mnist"
"gorgonia.org/tensor"
)

func BenchmarkUnmarshalBinary(b *testing.B) {
for n := 0; n < b.N; n++ {
// Create a backend receiver
backend := gorgonnx.NewGraph()
// Create a model and set the execution backend
model := onnx.NewModel(backend)

// Decode it into the model
err := model.UnmarshalBinary(mnist.GetMnist())
if err != nil {
b.Fatal(err)
}
// Set the first input, the number depends of the model
input := tensor.New(tensor.WithShape(1, 1, 28, 28), tensor.Of(tensor.Float32))
model.SetInput(0, input)
err = backend.Run()
if err != nil {
b.Fatal(err)
}
// Check error
}
}