Documentation
¶
Index ¶
- func AssertContains(t *testing.T, s, substr, msg string)
- func AssertEqual[T comparable](t *testing.T, expected, actual T, msg string)
- func AssertError(t *testing.T, err error, msg string)
- func AssertFalse(t *testing.T, condition bool, msg string)
- func AssertFloat32SliceApproxEqual(t *testing.T, expected, actual []float32, tolerance float32, msg string)
- func AssertFloat64SliceApproxEqual(t *testing.T, expected, actual []float64, tolerance float64, msg string)
- func AssertFloatEqual[T float32 | float64](t *testing.T, expected, actual, tolerance T, msg string)
- func AssertNil(t *testing.T, value interface{}, msg string)
- func AssertNoError(t *testing.T, err error, msg string)
- func AssertNotNil(t *testing.T, value interface{}, msg string)
- func AssertPanics(t *testing.T, f func(), msg string)
- func AssertTrue(t *testing.T, condition bool, msg string)
- func CompareTensorsApprox[T tensor.Addable](t *testing.T, actual, expected *tensor.TensorNumeric[T], epsilon T) bool
- func ElementsMatch(a, b []string) bool
- func Int64SliceEqual(a, b []int64) bool
- func IntSliceEqual(a, b []int) bool
- func RunTests(t *testing.T, tests []TestCase)
- type FailingInitializer
- type MockEngine
- func (e *MockEngine[T]) Add(_ context.Context, _, _ *tensor.TensorNumeric[T], ...) (*tensor.TensorNumeric[T], error)
- func (e *MockEngine[T]) Allocator() device.Allocator
- func (e *MockEngine[T]) Close() error
- func (e *MockEngine[T]) Context() context.Context
- func (e *MockEngine[T]) Copy(_ context.Context, _, _ *tensor.TensorNumeric[T]) error
- func (e *MockEngine[T]) Device() device.Device
- func (e *MockEngine[T]) Div(_ context.Context, _, _ *tensor.TensorNumeric[T], ...) (*tensor.TensorNumeric[T], error)
- func (e *MockEngine[T]) Exp(_ context.Context, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (e *MockEngine[T]) Log(_ context.Context, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (e *MockEngine[T]) MatMul(_ context.Context, _, _ *tensor.TensorNumeric[T], ...) (*tensor.TensorNumeric[T], error)
- func (e *MockEngine[T]) Mul(_ context.Context, _, _ *tensor.TensorNumeric[T], ...) (*tensor.TensorNumeric[T], error)
- func (e *MockEngine[T]) Name() string
- func (e *MockEngine[T]) Pow(_ context.Context, _, _ *tensor.TensorNumeric[T], ...) (*tensor.TensorNumeric[T], error)
- func (e *MockEngine[T]) String() string
- func (e *MockEngine[T]) Sub(_ context.Context, _, _ *tensor.TensorNumeric[T], ...) (*tensor.TensorNumeric[T], error)
- func (e *MockEngine[T]) Sum(_ context.Context, _ *tensor.TensorNumeric[T], _ int, _ bool, ...) (*tensor.TensorNumeric[T], error)
- func (e *MockEngine[T]) Transpose(_ context.Context, _ *tensor.TensorNumeric[T], _ []int, ...) (*tensor.TensorNumeric[T], error)
- func (e *MockEngine[T]) UnaryOp(_ context.Context, _ *tensor.TensorNumeric[T], _ func(T) T, ...) (*tensor.TensorNumeric[T], error)
- func (e *MockEngine[T]) Wait() error
- func (e *MockEngine[T]) WithAllocator(_ device.Allocator) compute.Engine[T]
- func (e *MockEngine[T]) WithContext(_ context.Context) compute.Engine[T]
- func (e *MockEngine[T]) WithDevice(_ device.Device) compute.Engine[T]
- func (e *MockEngine[T]) WithError(err error) *MockEngine[T]
- func (e *MockEngine[T]) WithName(_ string) compute.Engine[T]
- func (e *MockEngine[T]) Zero(_ context.Context, _ *tensor.TensorNumeric[T]) error
- type TestCase
- type TestInitializer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertContains ¶
AssertContains checks if a string contains a substring.
func AssertEqual ¶
func AssertEqual[T comparable](t *testing.T, expected, actual T, msg string)
AssertEqual checks if two values are equal.
func AssertError ¶
AssertError checks if an error is not nil.
func AssertFalse ¶
AssertFalse checks if a boolean is false.
func AssertFloat32SliceApproxEqual ¶
func AssertFloat32SliceApproxEqual(t *testing.T, expected, actual []float32, tolerance float32, msg string)
AssertFloat32SliceApproxEqual checks if two float32 slices are approximately equal element-wise.
func AssertFloat64SliceApproxEqual ¶
func AssertFloat64SliceApproxEqual(t *testing.T, expected, actual []float64, tolerance float64, msg string)
AssertFloat64SliceApproxEqual checks if two float64 slices are approximately equal element-wise.
func AssertFloatEqual ¶
AssertFloatEqual checks if two float values are approximately equal.
func AssertNoError ¶
AssertNoError checks if an error is nil.
func AssertNotNil ¶
AssertNotNil checks if a value is not nil.
func AssertPanics ¶
AssertPanics checks if a function panics.
func AssertTrue ¶
AssertTrue checks if a boolean is true.
func CompareTensorsApprox ¶
func CompareTensorsApprox[T tensor.Addable](t *testing.T, actual, expected *tensor.TensorNumeric[T], epsilon T) bool
CompareTensorsApprox checks if two tensors are approximately equal element-wise.
func ElementsMatch ¶
ElementsMatch checks if two string slices contain the same elements, regardless of order.
func Int64SliceEqual ¶
Int64SliceEqual checks if two int64 slices are equal.
func IntSliceEqual ¶
IntSliceEqual checks if two int slices are equal.
Types ¶
type FailingInitializer ¶
FailingInitializer is a test initializer that always returns an error.
func (*FailingInitializer[T]) Initialize ¶
func (f *FailingInitializer[T]) Initialize(_, _ int) ([]T, error)
Initialize always returns an error for testing error paths.
type MockEngine ¶
MockEngine is a mock implementation of the compute.Engine interface.
func NewMockEngine ¶
func NewMockEngine[T tensor.Numeric]() *MockEngine[T]
NewMockEngine creates a new mock engine for testing.
func NewMockEngineWithError ¶
func NewMockEngineWithError[T tensor.Numeric](err error) *MockEngine[T]
NewMockEngineWithError creates a new mock engine that returns the specified error.
func (*MockEngine[T]) Add ¶
func (e *MockEngine[T]) Add(_ context.Context, _, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Add performs element-wise addition of two tensors.
func (*MockEngine[T]) Allocator ¶
func (e *MockEngine[T]) Allocator() device.Allocator
Allocator returns the memory allocator for the engine.
func (*MockEngine[T]) Close ¶
func (e *MockEngine[T]) Close() error
Close closes the engine and releases resources.
func (*MockEngine[T]) Context ¶
func (e *MockEngine[T]) Context() context.Context
Context returns the context associated with the engine.
func (*MockEngine[T]) Copy ¶
func (e *MockEngine[T]) Copy(_ context.Context, _, _ *tensor.TensorNumeric[T]) error
Copy copies data from source tensor to destination tensor.
func (*MockEngine[T]) Device ¶
func (e *MockEngine[T]) Device() device.Device
Device returns the device associated with the engine.
func (*MockEngine[T]) Div ¶
func (e *MockEngine[T]) Div(_ context.Context, _, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Div performs element-wise division of two tensors.
func (*MockEngine[T]) Exp ¶
func (e *MockEngine[T]) Exp(_ context.Context, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Exp computes the exponential of tensor elements.
func (*MockEngine[T]) Log ¶
func (e *MockEngine[T]) Log(_ context.Context, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Log computes the natural logarithm of tensor elements.
func (*MockEngine[T]) MatMul ¶
func (e *MockEngine[T]) MatMul(_ context.Context, _, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
MatMul performs matrix multiplication of two tensors.
func (*MockEngine[T]) Mul ¶
func (e *MockEngine[T]) Mul(_ context.Context, _, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Mul performs element-wise multiplication of two tensors.
func (*MockEngine[T]) Name ¶
func (e *MockEngine[T]) Name() string
Name returns the name of the engine.
func (*MockEngine[T]) Pow ¶
func (e *MockEngine[T]) Pow(_ context.Context, _, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Pow computes the power of base tensor raised to exponent tensor.
func (*MockEngine[T]) String ¶
func (e *MockEngine[T]) String() string
func (*MockEngine[T]) Sub ¶
func (e *MockEngine[T]) Sub(_ context.Context, _, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Sub performs element-wise subtraction of two tensors.
func (*MockEngine[T]) Sum ¶
func (e *MockEngine[T]) Sum(_ context.Context, _ *tensor.TensorNumeric[T], _ int, _ bool, _ ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Sum computes the sum of tensor elements along the specified axis.
func (*MockEngine[T]) Transpose ¶
func (e *MockEngine[T]) Transpose(_ context.Context, _ *tensor.TensorNumeric[T], _ []int, _ ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Transpose transposes a tensor along the specified axes.
func (*MockEngine[T]) UnaryOp ¶
func (e *MockEngine[T]) UnaryOp(_ context.Context, _ *tensor.TensorNumeric[T], _ func(T) T, _ ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
UnaryOp performs a unary operation on a tensor.
func (*MockEngine[T]) Wait ¶
func (e *MockEngine[T]) Wait() error
Wait waits for all pending operations to complete.
func (*MockEngine[T]) WithAllocator ¶
func (e *MockEngine[T]) WithAllocator(_ device.Allocator) compute.Engine[T]
WithAllocator returns a new engine with the specified allocator.
func (*MockEngine[T]) WithContext ¶
func (e *MockEngine[T]) WithContext(_ context.Context) compute.Engine[T]
WithContext returns a new engine with the specified context.
func (*MockEngine[T]) WithDevice ¶
func (e *MockEngine[T]) WithDevice(_ device.Device) compute.Engine[T]
WithDevice returns a new engine with the specified device.
func (*MockEngine[T]) WithError ¶
func (e *MockEngine[T]) WithError(err error) *MockEngine[T]
WithError returns a mock engine that will return the specified error.
func (*MockEngine[T]) WithName ¶
func (e *MockEngine[T]) WithName(_ string) compute.Engine[T]
WithName returns a new engine with the specified name.
func (*MockEngine[T]) Zero ¶
func (e *MockEngine[T]) Zero(_ context.Context, _ *tensor.TensorNumeric[T]) error
Zero sets all elements of the tensor to zero.
type TestInitializer ¶
TestInitializer is a test initializer that sets all values to a specific value.
func (*TestInitializer[T]) Initialize ¶
func (t *TestInitializer[T]) Initialize(inputSize, outputSize int) ([]T, error)
Initialize sets all values to the specified value.