testutil

package
v0.28.39 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testutil provides utility functions for testing.

They are used within GoMLX for testing, but may be useful for other GoMLX-based library developers.

Index

Constants

This section is empty.

Variables

View Source
var (
	OfficialTestBackendNames []string = []string{
		"go",
	}
	OfficialTestBackends = make(map[string]compute.Backend)
)

Functions

func BuildTestBackend

func BuildTestBackend() compute.Backend

BuildTestBackend and sets compute.DefaultConfig to "xla:cpu" -- it can be overwritten by GOMLX_BACKEND environment variable.

func GetOfficialBackend

func GetOfficialBackend(name string) compute.Backend

GetOfficialBackend returns the named official backend if it was successfully initialized, or nil if it is not available in this environment. Callers should skip the test on nil:

b := testutil.GetOfficialBackend("xla:cuda")
if b == nil { t.Skip("xla:cuda backend not available") }

func IsInDelta

func IsInDelta(want, got any, delta float64) (ok bool, diff string)

IsInDelta reports if want and got are equal within a given absolute delta. If they are not equal, it returns the diff using the format "-want +got").

func IsInRelativeDelta

func IsInRelativeDelta(want, got any, relDelta float64) (ok bool, diff string)

IsInRelativeDelta reports if want and got are equal within a given relative delta. If they are not equal, it returns the diff using the format "-want +got").

func TestOfficialBackends

func TestOfficialBackends(t *testing.T, testFn func(t *testing.T, backend compute.Backend), excludeBackends ...string)

TestOfficialBackends iterates over list of backends and calls testFn for each of them. If GOMLX_BACKEND environment variable is set, it will only iterate over the one set. If GOMLX_BACKEND is not set, it will iterate over all official backends, except those in excludecompute. (for tests known not to work on those backends)

Types

This section is empty.

Jump to

Keyboard shortcuts

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