numeric

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2025 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Overview

Package numeric provides precision types, arithmetic operations, and generic constraints for the Zerfoo ML framework. It serves as the foundation layer supporting float8, float16, float32, and float64 numeric types with IEEE 754 compliance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Float16TestData

Float16TestData provides common test data for float16 operations.

func Float8TestData

Float8TestData provides common test data for float8 operations.

func TestArithmeticOp

func TestArithmeticOp[T any](t *testing.T, opName string, op func(T, T) T, equal func(T, T) bool, tests []ArithmeticTestCase[T])

TestArithmeticOp tests a binary arithmetic operation.

func TestLeakyReLUOp

func TestLeakyReLUOp[T any](t *testing.T, opName string, op func(T, float64) T, toFloat32 func(T) float32, tests []LeakyReLUTestCase[T])

TestLeakyReLUOp tests LeakyReLU operations with epsilon tolerance.

func TestSumOp

func TestSumOp[T any](t *testing.T, op func([]T) T, toFloat32 func(T) float32, tests []SumTestCase[T])

TestSumOp tests sum operations with epsilon tolerance.

func TestUnaryOp

func TestUnaryOp[T any](t *testing.T, opName string, op func(T) T, equal func(T, T) bool, tests []UnaryTestCase[T])

TestUnaryOp tests a unary operation.

Types

type Arithmetic

type Arithmetic[T any] interface {
	// Basic binary operations
	Add(a, b T) T
	Sub(a, b T) T
	Mul(a, b T) T
	Div(a, b T) T

	// Activation functions and their derivatives
	Tanh(x T) T
	Sigmoid(x T) T
	ReLU(x T) T
	LeakyReLU(x T, alpha float64) T
	TanhGrad(x T) T    // Derivative of Tanh
	SigmoidGrad(x T) T // Derivative of Sigmoid
	ReLUGrad(x T) T
	LeakyReLUGrad(x T, alpha float64) T

	// Conversion from standard types
	FromFloat32(f float32) T
	FromFloat64(f float64) T
	One() T

	// IsZero checks if a value is zero.
	IsZero(v T) bool

	// Abs returns the absolute value of x.
	Abs(x T) T
	// Sum returns the sum of all elements in the slice.
	Sum(s []T) T
	// Exp returns e**x.
	Exp(x T) T
	// Log returns the natural logarithm of x.
	Log(x T) T
	// Pow returns base**exponent.
	Pow(base, exponent T) T

	// Sqrt returns the square root of x.
	Sqrt(x T) T

	// GreaterThan returns true if a is greater than b.
	GreaterThan(a, b T) bool
}

Arithmetic defines a generic interface for all mathematical operations required by the compute engine. This allows the engine to be completely agnostic to the specific numeric type it is operating on.

type ArithmeticTestCase

type ArithmeticTestCase[T any] struct {
	// contains filtered or unexported fields
}

ArithmeticTestCase represents a test case for arithmetic operations.

type Float16Ops

type Float16Ops struct{}

Float16Ops provides the implementation of the Arithmetic interface for the float16.Float16 type.

func (Float16Ops) Abs

Abs computes the absolute value of x.

func (Float16Ops) Add

func (ops Float16Ops) Add(a, b float16.Float16) float16.Float16

Add performs element-wise addition.

func (Float16Ops) Div

func (ops Float16Ops) Div(a, b float16.Float16) float16.Float16

Div performs element-wise division.

func (Float16Ops) Exp

Exp computes the exponential of x.

func (Float16Ops) FromFloat32

func (ops Float16Ops) FromFloat32(f float32) float16.Float16

FromFloat32 converts a float32 to a float16.Float16.

func (Float16Ops) FromFloat64

func (ops Float16Ops) FromFloat64(f float64) float16.Float16

FromFloat64 converts a float64 to a float16.Float16.

func (Float16Ops) GreaterThan

func (ops Float16Ops) GreaterThan(a, b float16.Float16) bool

GreaterThan checks if a is greater than b.

func (Float16Ops) IsZero

func (ops Float16Ops) IsZero(v float16.Float16) bool

IsZero checks if the given float16.Float16 value is zero.

func (Float16Ops) LeakyReLU

func (ops Float16Ops) LeakyReLU(x float16.Float16, alpha float64) float16.Float16

LeakyReLU computes the Leaky Rectified Linear Unit function.

func (Float16Ops) LeakyReLUGrad

func (ops Float16Ops) LeakyReLUGrad(x float16.Float16, alpha float64) float16.Float16

LeakyReLUGrad computes the gradient of the Leaky Rectified Linear Unit function.

func (Float16Ops) Log

Log computes the natural logarithm of x.

func (Float16Ops) Mul

func (ops Float16Ops) Mul(a, b float16.Float16) float16.Float16

Mul performs element-wise multiplication.

func (Float16Ops) One

func (ops Float16Ops) One() float16.Float16

One returns a float16.Float16 with value 1.

func (Float16Ops) Pow

func (ops Float16Ops) Pow(base, exponent float16.Float16) float16.Float16

Pow computes base raised to the power of exponent.

func (Float16Ops) ReLU

ReLU computes the Rectified Linear Unit function.

func (Float16Ops) ReLUGrad

func (ops Float16Ops) ReLUGrad(x float16.Float16) float16.Float16

ReLUGrad computes the gradient of the Rectified Linear Unit function.

func (Float16Ops) Sigmoid

func (ops Float16Ops) Sigmoid(x float16.Float16) float16.Float16

Sigmoid computes the sigmoid function of x.

func (Float16Ops) SigmoidGrad

func (ops Float16Ops) SigmoidGrad(x float16.Float16) float16.Float16

SigmoidGrad computes the gradient of the sigmoid function.

func (Float16Ops) Sqrt

Sqrt computes the square root of x.

func (Float16Ops) Sub

func (ops Float16Ops) Sub(a, b float16.Float16) float16.Float16

Sub performs element-wise subtraction.

func (Float16Ops) Sum

func (ops Float16Ops) Sum(s []float16.Float16) float16.Float16

Sum computes the sum of elements in a slice.

func (Float16Ops) Tanh

Tanh computes the hyperbolic tangent of x.

func (Float16Ops) TanhGrad

func (ops Float16Ops) TanhGrad(x float16.Float16) float16.Float16

TanhGrad computes the gradient of the hyperbolic tangent function.

func (Float16Ops) ToFloat32

func (ops Float16Ops) ToFloat32(t float16.Float16) float32

ToFloat32 converts a float16.Float16 to a float32.

type Float32Ops

type Float32Ops struct{}

Float32Ops provides the implementation of the Arithmetic interface for the float32 type.

func (Float32Ops) Abs

func (ops Float32Ops) Abs(x float32) float32

Abs computes the absolute value of x.

func (Float32Ops) Add

func (ops Float32Ops) Add(a, b float32) float32

Add performs element-wise addition.

func (Float32Ops) Div

func (ops Float32Ops) Div(a, b float32) float32

Div performs element-wise division.

func (Float32Ops) Exp

func (ops Float32Ops) Exp(x float32) float32

Exp computes the exponential of x.

func (Float32Ops) FromFloat32

func (ops Float32Ops) FromFloat32(f float32) float32

FromFloat32 converts a float32 to a float32.

func (Float32Ops) FromFloat64

func (ops Float32Ops) FromFloat64(f float64) float32

FromFloat64 converts a float64 to a float32.

func (Float32Ops) GreaterThan

func (ops Float32Ops) GreaterThan(a, b float32) bool

GreaterThan checks if a is greater than b.

func (Float32Ops) IsZero

func (ops Float32Ops) IsZero(v float32) bool

IsZero checks if the given float32 value is zero.

func (Float32Ops) LeakyReLU

func (ops Float32Ops) LeakyReLU(x float32, alpha float64) float32

LeakyReLU computes the Leaky Rectified Linear Unit function.

func (Float32Ops) LeakyReLUGrad

func (ops Float32Ops) LeakyReLUGrad(x float32, alpha float64) float32

LeakyReLUGrad computes the gradient of the Leaky Rectified Linear Unit function.

func (Float32Ops) Log

func (ops Float32Ops) Log(x float32) float32

Log computes the natural logarithm of x.

func (Float32Ops) Mul

func (ops Float32Ops) Mul(a, b float32) float32

Mul performs element-wise multiplication.

func (Float32Ops) One

func (ops Float32Ops) One() float32

One returns a float32 with value 1.

func (Float32Ops) Pow

func (ops Float32Ops) Pow(base, exponent float32) float32

Pow computes base raised to the power of exponent.

func (Float32Ops) ReLU

func (ops Float32Ops) ReLU(x float32) float32

ReLU computes the Rectified Linear Unit function.

func (Float32Ops) ReLUGrad

func (ops Float32Ops) ReLUGrad(x float32) float32

ReLUGrad computes the gradient of the Rectified Linear Unit function.

func (Float32Ops) Sigmoid

func (ops Float32Ops) Sigmoid(x float32) float32

Sigmoid computes the sigmoid function of x.

func (Float32Ops) SigmoidGrad

func (ops Float32Ops) SigmoidGrad(x float32) float32

SigmoidGrad computes the gradient of the sigmoid function.

func (Float32Ops) Sqrt

func (ops Float32Ops) Sqrt(x float32) float32

Sqrt computes the square root of x.

func (Float32Ops) Sub

func (ops Float32Ops) Sub(a, b float32) float32

Sub performs element-wise subtraction.

func (Float32Ops) Sum

func (ops Float32Ops) Sum(s []float32) float32

Sum computes the sum of elements in a slice.

func (Float32Ops) Tanh

func (ops Float32Ops) Tanh(x float32) float32

Tanh computes the hyperbolic tangent of x.

func (Float32Ops) TanhGrad

func (ops Float32Ops) TanhGrad(x float32) float32

TanhGrad computes the gradient of the hyperbolic tangent function.

func (Float32Ops) ToFloat32

func (ops Float32Ops) ToFloat32(t float32) float32

ToFloat32 converts a float32 to a float32.

type Float64Ops

type Float64Ops struct{}

Float64Ops provides the implementation of the Arithmetic interface for the float64 type.

func (Float64Ops) Abs

func (ops Float64Ops) Abs(x float64) float64

Abs computes the absolute value of x.

func (Float64Ops) Add

func (ops Float64Ops) Add(a, b float64) float64

Add performs element-wise addition.

func (Float64Ops) Div

func (ops Float64Ops) Div(a, b float64) float64

Div performs element-wise division.

func (Float64Ops) Exp

func (ops Float64Ops) Exp(x float64) float64

Exp computes the exponential of x.

func (Float64Ops) FromFloat32

func (ops Float64Ops) FromFloat32(f float32) float64

FromFloat32 converts a float32 to a float64.

func (Float64Ops) FromFloat64

func (ops Float64Ops) FromFloat64(f float64) float64

FromFloat64 converts a float64 to a float64.

func (Float64Ops) GreaterThan

func (ops Float64Ops) GreaterThan(a, b float64) bool

GreaterThan checks if a is greater than b.

func (Float64Ops) IsZero

func (ops Float64Ops) IsZero(v float64) bool

IsZero checks if the given float64 value is zero.

func (Float64Ops) LeakyReLU

func (ops Float64Ops) LeakyReLU(x, alpha float64) float64

LeakyReLU computes the Leaky Rectified Linear Unit function.

func (Float64Ops) LeakyReLUGrad

func (ops Float64Ops) LeakyReLUGrad(x, alpha float64) float64

LeakyReLUGrad computes the gradient of the Leaky Rectified Linear Unit function.

func (Float64Ops) Log

func (ops Float64Ops) Log(x float64) float64

Log computes the natural logarithm of x.

func (Float64Ops) Mul

func (ops Float64Ops) Mul(a, b float64) float64

Mul performs element-wise multiplication.

func (Float64Ops) One

func (ops Float64Ops) One() float64

One returns a float64 with value 1.

func (Float64Ops) Pow

func (ops Float64Ops) Pow(base, exponent float64) float64

Pow computes base raised to the power of exponent.

func (Float64Ops) ReLU

func (ops Float64Ops) ReLU(x float64) float64

ReLU computes the Rectified Linear Unit function.

func (Float64Ops) ReLUGrad

func (ops Float64Ops) ReLUGrad(x float64) float64

ReLUGrad computes the gradient of the Rectified Linear Unit function.

func (Float64Ops) Sigmoid

func (ops Float64Ops) Sigmoid(x float64) float64

Sigmoid computes the sigmoid function of x.

func (Float64Ops) SigmoidGrad

func (ops Float64Ops) SigmoidGrad(x float64) float64

SigmoidGrad computes the gradient of the sigmoid function.

func (Float64Ops) Sqrt

func (ops Float64Ops) Sqrt(x float64) float64

Sqrt computes the square root of x.

func (Float64Ops) Sub

func (ops Float64Ops) Sub(a, b float64) float64

Sub performs element-wise subtraction.

func (Float64Ops) Sum

func (ops Float64Ops) Sum(s []float64) float64

Sum computes the sum of elements in a slice.

func (Float64Ops) Tanh

func (ops Float64Ops) Tanh(x float64) float64

Tanh computes the hyperbolic tangent of x.

func (Float64Ops) TanhGrad

func (ops Float64Ops) TanhGrad(x float64) float64

TanhGrad computes the gradient of the hyperbolic tangent function.

func (Float64Ops) ToFloat32

func (ops Float64Ops) ToFloat32(t float64) float32

ToFloat32 converts a float64 to a float32.

type Float8Ops

type Float8Ops struct{}

Float8Ops provides the implementation of the Arithmetic interface for the float8.Float8 type.

func (Float8Ops) Abs

func (ops Float8Ops) Abs(x float8.Float8) float8.Float8

Abs computes the absolute value of x.

func (Float8Ops) Add

func (ops Float8Ops) Add(a, b float8.Float8) float8.Float8

Add performs element-wise addition.

func (Float8Ops) Div

func (ops Float8Ops) Div(a, b float8.Float8) float8.Float8

Div performs element-wise division.

func (Float8Ops) Exp

func (ops Float8Ops) Exp(x float8.Float8) float8.Float8

Exp computes the exponential of x.

func (Float8Ops) FromFloat32

func (ops Float8Ops) FromFloat32(f float32) float8.Float8

FromFloat32 converts a float32 to a float8.Float8.

func (Float8Ops) FromFloat64

func (ops Float8Ops) FromFloat64(f float64) float8.Float8

FromFloat64 converts a float64 to a float8.Float8.

func (Float8Ops) GreaterThan

func (ops Float8Ops) GreaterThan(a, b float8.Float8) bool

GreaterThan checks if a is greater than b.

func (Float8Ops) IsZero

func (ops Float8Ops) IsZero(v float8.Float8) bool

IsZero checks if the given float8.Float8 value is zero.

func (Float8Ops) LeakyReLU

func (ops Float8Ops) LeakyReLU(x float8.Float8, alpha float64) float8.Float8

LeakyReLU computes the Leaky Rectified Linear Unit function.

func (Float8Ops) LeakyReLUGrad

func (ops Float8Ops) LeakyReLUGrad(x float8.Float8, alpha float64) float8.Float8

LeakyReLUGrad computes the gradient of the Leaky Rectified Linear Unit function.

func (Float8Ops) Log

func (ops Float8Ops) Log(x float8.Float8) float8.Float8

Log computes the natural logarithm of x.

func (Float8Ops) Mul

func (ops Float8Ops) Mul(a, b float8.Float8) float8.Float8

Mul performs element-wise multiplication.

func (Float8Ops) One

func (ops Float8Ops) One() float8.Float8

One returns a float8.Float8 with value 1.

func (Float8Ops) Pow

func (ops Float8Ops) Pow(base, exponent float8.Float8) float8.Float8

Pow computes base raised to the power of exponent.

func (Float8Ops) ReLU

func (ops Float8Ops) ReLU(x float8.Float8) float8.Float8

ReLU computes the Rectified Linear Unit function.

func (Float8Ops) ReLUGrad

func (ops Float8Ops) ReLUGrad(x float8.Float8) float8.Float8

ReLUGrad computes the gradient of the Rectified Linear Unit function.

func (Float8Ops) Sigmoid

func (ops Float8Ops) Sigmoid(x float8.Float8) float8.Float8

Sigmoid computes the sigmoid function of x.

func (Float8Ops) SigmoidGrad

func (ops Float8Ops) SigmoidGrad(x float8.Float8) float8.Float8

SigmoidGrad computes the gradient of the sigmoid function.

func (Float8Ops) Sqrt

func (ops Float8Ops) Sqrt(x float8.Float8) float8.Float8

Sqrt computes the square root of x.

func (Float8Ops) Sub

func (ops Float8Ops) Sub(a, b float8.Float8) float8.Float8

Sub performs element-wise subtraction.

func (Float8Ops) Sum

func (ops Float8Ops) Sum(s []float8.Float8) float8.Float8

Sum computes the sum of elements in a slice.

func (Float8Ops) Tanh

func (ops Float8Ops) Tanh(x float8.Float8) float8.Float8

Tanh computes the hyperbolic tangent of x.

func (Float8Ops) TanhGrad

func (ops Float8Ops) TanhGrad(x float8.Float8) float8.Float8

TanhGrad computes the gradient of the hyperbolic tangent function.

func (Float8Ops) ToFloat32

func (ops Float8Ops) ToFloat32(t float8.Float8) float32

ToFloat32 converts a float8.Float8 to a float32.

type Int8Ops added in v0.3.0

type Int8Ops struct{}

Int8Ops provides the implementation of the Arithmetic interface for the int8 type.

func (Int8Ops) Abs added in v0.3.0

func (ops Int8Ops) Abs(x int8) int8

Abs computes the absolute value of x.

func (Int8Ops) Add added in v0.3.0

func (ops Int8Ops) Add(a, b int8) int8

Add performs element-wise addition.

func (Int8Ops) Div added in v0.3.0

func (ops Int8Ops) Div(a, b int8) int8

Div performs element-wise division.

func (Int8Ops) Exp added in v0.3.0

func (ops Int8Ops) Exp(x int8) int8

Exp computes the exponential of x.

func (Int8Ops) FromFloat32 added in v0.3.0

func (ops Int8Ops) FromFloat32(f float32) int8

FromFloat32 converts a float32 to an int8.

func (Int8Ops) FromFloat64 added in v0.3.0

func (ops Int8Ops) FromFloat64(f float64) int8

FromFloat64 converts a float64 to an int8.

func (Int8Ops) GreaterThan added in v0.3.0

func (ops Int8Ops) GreaterThan(a, b int8) bool

GreaterThan checks if a is greater than b.

func (Int8Ops) IsZero added in v0.3.0

func (ops Int8Ops) IsZero(v int8) bool

IsZero checks if the given int8 value is zero.

func (Int8Ops) LeakyReLU added in v0.3.0

func (ops Int8Ops) LeakyReLU(x int8, alpha float64) int8

LeakyReLU computes the Leaky Rectified Linear Unit function.

func (Int8Ops) LeakyReLUGrad added in v0.3.0

func (ops Int8Ops) LeakyReLUGrad(x int8, alpha float64) int8

LeakyReLUGrad computes the gradient of the Leaky Rectified Linear Unit function.

func (Int8Ops) Log added in v0.3.0

func (ops Int8Ops) Log(x int8) int8

Log computes the natural logarithm of x.

func (Int8Ops) Mul added in v0.3.0

func (ops Int8Ops) Mul(a, b int8) int8

Mul performs element-wise multiplication.

func (Int8Ops) One added in v0.3.0

func (ops Int8Ops) One() int8

One returns an int8 with value 1.

func (Int8Ops) Pow added in v0.3.0

func (ops Int8Ops) Pow(base, exponent int8) int8

Pow computes base raised to the power of exponent.

func (Int8Ops) ReLU added in v0.3.0

func (ops Int8Ops) ReLU(x int8) int8

ReLU computes the Rectified Linear Unit function.

func (Int8Ops) ReLUGrad added in v0.3.0

func (ops Int8Ops) ReLUGrad(x int8) int8

ReLUGrad computes the gradient of the Rectified Linear Unit function.

func (Int8Ops) Sigmoid added in v0.3.0

func (ops Int8Ops) Sigmoid(x int8) int8

Sigmoid computes the sigmoid function of x.

func (Int8Ops) SigmoidGrad added in v0.3.0

func (ops Int8Ops) SigmoidGrad(x int8) int8

SigmoidGrad computes the gradient of the sigmoid function.

func (Int8Ops) Sqrt added in v0.3.0

func (ops Int8Ops) Sqrt(x int8) int8

Sqrt computes the square root of x.

func (Int8Ops) Sub added in v0.3.0

func (ops Int8Ops) Sub(a, b int8) int8

Sub performs element-wise subtraction.

func (Int8Ops) Sum added in v0.3.0

func (ops Int8Ops) Sum(s []int8) int8

Sum computes the sum of elements in a slice.

func (Int8Ops) Tanh added in v0.3.0

func (ops Int8Ops) Tanh(x int8) int8

Tanh computes the hyperbolic tangent of x.

func (Int8Ops) TanhGrad added in v0.3.0

func (ops Int8Ops) TanhGrad(x int8) int8

TanhGrad computes the gradient of the hyperbolic tangent function.

type IntOps

type IntOps struct{}

IntOps implements Arithmetic for int.

func (IntOps) Abs

func (IntOps) Abs(x int) int

Abs computes the absolute value of x.

func (IntOps) Add

func (IntOps) Add(a, b int) int

Add performs element-wise addition.

func (IntOps) Div

func (IntOps) Div(a, b int) int

Div performs element-wise division.

func (IntOps) Exp

func (IntOps) Exp(x int) int

Exp computes the exponential of x.

func (IntOps) FromFloat32

func (IntOps) FromFloat32(f float32) int

FromFloat32 converts a float32 to an int.

func (IntOps) FromFloat64

func (IntOps) FromFloat64(f float64) int

FromFloat64 converts a float64 to an int.

func (IntOps) GreaterThan

func (IntOps) GreaterThan(a, b int) bool

GreaterThan checks if a is greater than b.

func (IntOps) IsZero

func (IntOps) IsZero(v int) bool

IsZero checks if the given int value is zero.

func (IntOps) LeakyReLU

func (IntOps) LeakyReLU(x int, alpha float64) int

LeakyReLU computes the Leaky Rectified Linear Unit function.

func (IntOps) LeakyReLUGrad

func (IntOps) LeakyReLUGrad(x int, alpha float64) int

LeakyReLUGrad computes the gradient of the Leaky Rectified Linear Unit function.

func (IntOps) Log

func (IntOps) Log(x int) int

Log computes the natural logarithm of x.

func (IntOps) Mul

func (IntOps) Mul(a, b int) int

Mul performs element-wise multiplication.

func (IntOps) One

func (IntOps) One() int

One returns an int with value 1.

func (IntOps) Pow

func (IntOps) Pow(base, exponent int) int

Pow computes base raised to the power of exponent.

func (IntOps) ReLU

func (IntOps) ReLU(x int) int

ReLU computes the Rectified Linear Unit function.

func (IntOps) ReLUGrad

func (IntOps) ReLUGrad(x int) int

ReLUGrad computes the gradient of the Rectified Linear Unit function.

func (IntOps) Sigmoid

func (IntOps) Sigmoid(x int) int

Sigmoid computes the sigmoid function of x.

func (IntOps) SigmoidGrad

func (IntOps) SigmoidGrad(x int) int

SigmoidGrad computes the gradient of the sigmoid function.

func (IntOps) Sqrt

func (IntOps) Sqrt(x int) int

Sqrt computes the square root of x.

func (IntOps) Sub

func (IntOps) Sub(a, b int) int

Sub performs element-wise subtraction.

func (IntOps) Sum

func (IntOps) Sum(s []int) int

Sum computes the sum of elements in a slice.

func (IntOps) Tanh

func (IntOps) Tanh(x int) int

Tanh computes the hyperbolic tangent of x.

func (IntOps) TanhGrad

func (IntOps) TanhGrad(x int) int

TanhGrad computes the gradient of the hyperbolic tangent function.

func (IntOps) ToFloat32

func (IntOps) ToFloat32(t int) float32

ToFloat32 converts an int to a float32.

type LeakyReLUTestCase

type LeakyReLUTestCase[T any] struct {
	// contains filtered or unexported fields
}

LeakyReLUTestCase represents a test case for LeakyReLU operations.

type SumTestCase

type SumTestCase[T any] struct {
	// contains filtered or unexported fields
}

SumTestCase represents a test case for sum operations.

type Uint8Ops added in v0.3.0

type Uint8Ops struct{}

Uint8Ops provides the implementation of the Arithmetic interface for the uint8 type.

func (Uint8Ops) Abs added in v0.3.0

func (ops Uint8Ops) Abs(x uint8) uint8

Abs computes the absolute value of x.

func (Uint8Ops) Add added in v0.3.0

func (ops Uint8Ops) Add(a, b uint8) uint8

Add performs element-wise addition.

func (Uint8Ops) Div added in v0.3.0

func (ops Uint8Ops) Div(a, b uint8) uint8

Div performs element-wise division.

func (Uint8Ops) Exp added in v0.3.0

func (ops Uint8Ops) Exp(x uint8) uint8

Exp computes the exponential of x.

func (Uint8Ops) FromFloat32 added in v0.3.0

func (ops Uint8Ops) FromFloat32(f float32) uint8

FromFloat32 converts a float32 to a uint8.

func (Uint8Ops) FromFloat64 added in v0.3.0

func (ops Uint8Ops) FromFloat64(f float64) uint8

FromFloat64 converts a float64 to a uint8.

func (Uint8Ops) GreaterThan added in v0.3.0

func (ops Uint8Ops) GreaterThan(a, b uint8) bool

GreaterThan checks if a is greater than b.

func (Uint8Ops) IsZero added in v0.3.0

func (ops Uint8Ops) IsZero(v uint8) bool

IsZero checks if the given uint8 value is zero.

func (Uint8Ops) LeakyReLU added in v0.3.0

func (ops Uint8Ops) LeakyReLU(x uint8, alpha float64) uint8

LeakyReLU computes the Leaky Rectified Linear Unit function.

func (Uint8Ops) LeakyReLUGrad added in v0.3.0

func (ops Uint8Ops) LeakyReLUGrad(x uint8, alpha float64) uint8

LeakyReLUGrad computes the gradient of the Leaky Rectified Linear Unit function.

func (Uint8Ops) Log added in v0.3.0

func (ops Uint8Ops) Log(x uint8) uint8

Log computes the natural logarithm of x.

func (Uint8Ops) Mul added in v0.3.0

func (ops Uint8Ops) Mul(a, b uint8) uint8

Mul performs element-wise multiplication.

func (Uint8Ops) One added in v0.3.0

func (ops Uint8Ops) One() uint8

One returns a uint8 with value 1.

func (Uint8Ops) Pow added in v0.3.0

func (ops Uint8Ops) Pow(base, exponent uint8) uint8

Pow computes base raised to the power of exponent.

func (Uint8Ops) ReLU added in v0.3.0

func (ops Uint8Ops) ReLU(x uint8) uint8

ReLU computes the Rectified Linear Unit function.

func (Uint8Ops) ReLUGrad added in v0.3.0

func (ops Uint8Ops) ReLUGrad(x uint8) uint8

ReLUGrad computes the gradient of the Rectified Linear Unit function.

func (Uint8Ops) Sigmoid added in v0.3.0

func (ops Uint8Ops) Sigmoid(x uint8) uint8

Sigmoid computes the sigmoid function of x.

func (Uint8Ops) SigmoidGrad added in v0.3.0

func (ops Uint8Ops) SigmoidGrad(x uint8) uint8

SigmoidGrad computes the gradient of the sigmoid function.

func (Uint8Ops) Sqrt added in v0.3.0

func (ops Uint8Ops) Sqrt(x uint8) uint8

Sqrt computes the square root of x.

func (Uint8Ops) Sub added in v0.3.0

func (ops Uint8Ops) Sub(a, b uint8) uint8

Sub performs element-wise subtraction.

func (Uint8Ops) Sum added in v0.3.0

func (ops Uint8Ops) Sum(s []uint8) uint8

Sum computes the sum of elements in a slice.

func (Uint8Ops) Tanh added in v0.3.0

func (ops Uint8Ops) Tanh(x uint8) uint8

Tanh computes the hyperbolic tangent of x.

func (Uint8Ops) TanhGrad added in v0.3.0

func (ops Uint8Ops) TanhGrad(x uint8) uint8

TanhGrad computes the gradient of the hyperbolic tangent function.

type UnaryTestCase

type UnaryTestCase[T any] struct {
	// contains filtered or unexported fields
}

UnaryTestCase represents a test case for unary operations.

Jump to

Keyboard shortcuts

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