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 ¶
- Variables
- func BuildTestBackend() compute.Backend
- func GetOfficialBackend(name string) compute.Backend
- func IsInDelta(want, got any, delta float64) (ok bool, diff string)
- func IsInRelativeDelta(want, got any, relDelta float64) (ok bool, diff string)
- func TestOfficialBackends(t *testing.T, testFn func(t *testing.T, backend compute.Backend), ...)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func BuildTestBackend ¶
BuildTestBackend and sets compute.DefaultConfig to "xla:cpu" -- it can be overwritten by GOMLX_BACKEND environment variable.
func GetOfficialBackend ¶
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 ¶
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 ¶
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.