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

Commit

Permalink
Benchmarks (#69)
Browse files Browse the repository at this point in the history
* chore: new coverage generation

* fix: remove old files because tests were registered twice

* chore: fix some tests and test the tests

* wip: temporary comment this test

* chore: coverage

* feat: only cover the main package

* feat: simple bench with MNIST for evaluation purpose
  • Loading branch information
owulveryck committed May 29, 2019
1 parent c5899d1 commit 8ee854b
Showing 1 changed file with 33 additions and 0 deletions.
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
}
}

0 comments on commit 8ee854b

Please sign in to comment.