testgrad

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package testgrad provides function to test autograd.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Func

type Func struct {
	// Src declares the function (which must be named `F`) to compute the gradient of.
	Src string

	// GradOf lists all the functions for which we compute the gradient of.
	// If GradOf is empty, we compute the gradient of F.
	GradOf []string

	// Want stores the source code of the expected gradient of the function
	Want string

	// GradImportName is the name of the import of the grad package.
	// If empty, then the default import name is used.
	GradImportName string

	// Wants stores the source code of the expected synthetic auxiliary functions.
	Wants map[string]string

	// Err is the substring expected if the compiler returns an error.
	Err string
}

Func tests the computation of the gradient of a function.

func (Func) Run

func (tt Func) Run(b *testbuild.Builder) error

Run builds the declarations as a package, then compare to an expected outcome.

func (Func) Source

func (tt Func) Source() string

Source code of the declarations.

type Method added in v0.4.0

type Method struct {
	// Src declares the function (which must be named `F`) to compute the gradient of.
	Src string

	// GradOf lists all the functions for which we compute the gradient of.
	// If GradOf is empty, we compute the gradient of F.
	GradOf []string

	// Want stores the source code of the expected gradient of the function
	Want string

	// GradImportName is the name of the import of the grad package.
	// If empty, then the default import name is used.
	GradImportName string

	// Wants stores the source code of the expected synthetic auxiliary functions.
	Wants map[string]string

	// Err is the substring expected if the compiler returns an error.
	Err string
}

Method computes the gradient of methods and compare the result with an expected outcome.

func (Method) Run added in v0.4.0

func (tt Method) Run(b *testbuild.Builder) error

Run builds the declarations as a package, then compare to an expected outcome.

func (Method) Source added in v0.4.0

func (tt Method) Source() string

Source code of the declarations.

Jump to

Keyboard shortcuts

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