testbackend

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package testbackend provides a set of testing helper functions that test backend interface implementations. The tests are extracted and converted from the onnx test set

Example
package main

import (
	"testing"

	"github.com/tynrol/onnx-go/backend"
	"github.com/tynrol/onnx-go/backend/testbackend"
)

func main() {
	// The backend you want to test
	var backend backend.ComputationBackend
	// Replace this line in your code by:
	// func TestConv(t i*testing.T) {
	testConv := func(t *testing.T) {
		for _, tc := range testbackend.GetOpTypeTests("Conv") {
			tc := tc // capture range variable
			t.Run(tc().GetInfo(), tc().RunTest(backend, false))
		}
	}
	_ = testConv
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindAllTestsMatching

func FindAllTestsMatching(re *regexp.Regexp) []func() *TestCase

FindAllTestsMatching tests matching the regexp

func GetAllRegisteredTests

func GetAllRegisteredTests() []func() *TestCase

GetAllRegisteredTests ...

func GetOpTypeTests

func GetOpTypeTests(optype string) []func() *TestCase

GetOpTypeTests returns all the tests of the OpType passed as argument

func Register

func Register(optype, testTitle string, constructor func() *TestCase)

Register a test

Types

type TestCase

type TestCase struct {
	OpType         string
	Title          string
	ModelB         []byte
	Input          []tensor.Tensor
	ExpectedOutput []tensor.Tensor
	Tested         bool // true if the test has be executed
	Skipped        bool // true if the test has been executed and skipped
	Failed         bool // true if the test failed
}

TestCase describes an integration test

func (*TestCase) Dump

func (tc *TestCase) Dump(w io.Writer) error

Dump a raw version of the onnx data decoded in the protobuf structure. Useful for debugging

func (*TestCase) GetInfo

func (tc *TestCase) GetInfo() string

GetInfo ...

func (*TestCase) RunTest

func (tc *TestCase) RunTest(b backend.ComputationBackend, parallel bool) func(t *testing.T)

RunTest Returns a function to be executed against the ComputationBackend. The return function should be executed via a call to testing.Run(...) If parallel is true, a t.Parallel() is added at the beginning of the test

Directories

Path Synopsis
Package onnxtest contains an export of the onnx test files
Package onnxtest contains an export of the onnx test files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL