Documentation ¶
Index ¶
- Variables
- func NdDotFma(a, b nd.NdArray[float32]) nd.NdArray[float32]
- func NdDotSep(a, b nd.NdArray[float32]) nd.NdArray[float32]
- func NdTensorDot(a, b nd.NdArray[float32], axes_a, axes_b nd.Dims) nd.NdArray[float32]
- type AddFunc
- type Buffer
- func (b *Buffer) BinaryOp(op Op, y *Buffer) *Buffer
- func (b *Buffer) Dot(y *Buffer, baxes, yaxes []int) *Buffer
- func (b *Buffer) Expand(newShape Shape) *Buffer
- func (b *Buffer) Flip(axes []Dim) *Buffer
- func (b *Buffer) Get(idxs ...Dim) float32
- func (b *Buffer) MovementOp(op Op, arg any) *Buffer
- func (b *Buffer) Nd() nd.NdArray[float32]
- func (b *Buffer) Pad(padding []SliceBound) *Buffer
- func (b *Buffer) Permute(order []Dim) *Buffer
- func (b *Buffer) ProcessingOp(op Op, w *Buffer, arg any) *Buffer
- func (b *Buffer) ReduceOp(op Op, nsh Shape) *Buffer
- func (b *Buffer) Reshape(newShape Shape) *Buffer
- func (b *Buffer) Shape() Shape
- func (b *Buffer) Slice(bounds ...SliceBound) *Buffer
- func (b *Buffer) Strides() Strides
- func (b *Buffer) Transpose(order []Dim) *Buffer
- func (b *Buffer) UnaryOp(op Op) *Buffer
- type Conv2dFunc
- type ConvArgs
- type ConvOpts
- type Dim
- type ExpFunc
- type ExpandFunc
- type Func
- type FuncContext
- type Lazy
- type LazyBuffer
- func (b *LazyBuffer) BinaryOp(op Op, y *LazyBuffer) *LazyBuffer
- func (b *LazyBuffer) MovementOp(op Op, arg any) *LazyBuffer
- func (b *LazyBuffer) ProcessingOp(op Op, w *LazyBuffer, arg any) *LazyBuffer
- func (b *LazyBuffer) Realize() *Buffer
- func (b *LazyBuffer) ReduceOp(op Op, newShape Shape) *LazyBuffer
- func (b *LazyBuffer) Shape() Shape
- func (b *LazyBuffer) UnaryOp(op Op) *LazyBuffer
- type LazyOp
- type LogFunc
- type MaxFunc
- type MulFunc
- type Op
- type OpType
- type PermuteFunc
- type PowFunc
- type RealizedOp
- type ReluFunc
- type ReshapeFunc
- type Shape
- type ShapeStride
- type ShapeTracker
- func (st *ShapeTracker) Clone() *ShapeTracker
- func (st *ShapeTracker) Contiguous() bool
- func (st *ShapeTracker) Expand(newShape Shape)
- func (st *ShapeTracker) Flip(axes ...Dim)
- func (st *ShapeTracker) MovementOp(op Op, arg any)
- func (st *ShapeTracker) Offset() Dim
- func (st *ShapeTracker) Permute(axis ...Dim)
- func (st *ShapeTracker) Reshape(newShape Shape)
- func (st *ShapeTracker) Shape() Shape
- func (st *ShapeTracker) Stride(mul ...Dim)
- func (st *ShapeTracker) Strides() Strides
- type SliceBound
- type Strides
- type SubFunc
- type SumFunc
- type Tensor
- func (t *Tensor) Add(y *Tensor) *Tensor
- func (t *Tensor) Assign(x *Tensor)
- func (t *Tensor) Backward()
- func (t *Tensor) ClearGrad()
- func (t *Tensor) Conv2d(weight *Tensor, bias *Tensor, opts ConvOpts) *Tensor
- func (t *Tensor) Data() *LazyBuffer
- func (t *Tensor) Dot(w *Tensor) *Tensor
- func (t *Tensor) Exp() *Tensor
- func (t *Tensor) Expand(shape Shape) *Tensor
- func (t *Tensor) FullSoftmax() TensorSoftmax
- func (t *Tensor) Grad() *Tensor
- func (t *Tensor) Log() *Tensor
- func (t *Tensor) LogSoftmax() *Tensor
- func (t *Tensor) Matmul(w *Tensor) *Tensor
- func (t *Tensor) Max(axis []int, keepDim bool) *Tensor
- func (t *Tensor) Mean(axis []int, keepDim bool) *Tensor
- func (t *Tensor) Mul(y *Tensor) *Tensor
- func (t *Tensor) Permute(order []Dim) *Tensor
- func (t *Tensor) Relu() *Tensor
- func (t *Tensor) RequiresGrad() bool
- func (t *Tensor) Reshape(shape Shape) *Tensor
- func (t *Tensor) Shape() Shape
- func (t *Tensor) Sub(y *Tensor) *Tensor
- func (t *Tensor) Sum(axis []int, keepDim bool) *Tensor
- func (t *Tensor) Transpose(order []Dim) *Tensor
- type TensorSoftmax
- type View
Constants ¶
This section is empty.
Variables ¶
View Source
var NdDot = NdDotFma
var NdDot = NdDotSep
Functions ¶
Types ¶
type AddFunc ¶
type AddFunc struct{}
func (AddFunc) Backward ¶
func (a AddFunc) Backward(ctx *FuncContext, g *LazyBuffer) []*LazyBuffer
func (AddFunc) Forward ¶
func (a AddFunc) Forward(ctx *FuncContext, bs []*LazyBuffer) *LazyBuffer
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
func MakeConstBuffer ¶
func (*Buffer) Pad ¶
func (b *Buffer) Pad(padding []SliceBound) *Buffer
func (*Buffer) Slice ¶
func (b *Buffer) Slice(bounds ...SliceBound) *Buffer
type Conv2dFunc ¶
type Conv2dFunc struct {
// contains filtered or unexported fields
}
func (Conv2dFunc) Backward ¶
func (f Conv2dFunc) Backward(ctx *FuncContext, g *LazyBuffer) []*LazyBuffer
func (Conv2dFunc) Forward ¶
func (f Conv2dFunc) Forward(ctx *FuncContext, bs []*LazyBuffer) *LazyBuffer
type ConvArgs ¶
type ConvArgs struct {
// contains filtered or unexported fields
}
func BuildConvArgs ¶
type ExpFunc ¶
type ExpFunc struct{}
func (ExpFunc) Backward ¶
func (f ExpFunc) Backward(ctx *FuncContext, g *LazyBuffer) []*LazyBuffer
func (ExpFunc) Forward ¶
func (f ExpFunc) Forward(ctx *FuncContext, bs []*LazyBuffer) *LazyBuffer
type ExpandFunc ¶
type ExpandFunc struct {
Shape Shape
}
func (ExpandFunc) Backward ¶
func (f ExpandFunc) Backward(ctx *FuncContext, g *LazyBuffer) []*LazyBuffer
func (ExpandFunc) Forward ¶
func (f ExpandFunc) Forward(ctx *FuncContext, bs []*LazyBuffer) *LazyBuffer
type Func ¶
type Func interface { Forward(ctx *FuncContext, bs []*LazyBuffer) *LazyBuffer Backward(ctx *FuncContext, g *LazyBuffer) []*LazyBuffer }
type FuncContext ¶
type FuncContext struct {
// contains filtered or unexported fields
}
func NewFuncContext ¶
func NewFuncContext(fn Func, parents []*Tensor) *FuncContext
type LazyBuffer ¶
func ElementwiseOp ¶
func ElementwiseOp(op Op, srcs ...*LazyBuffer) *LazyBuffer
func MakeLoadBuffer ¶
func MakeLoadBuffer(data *Buffer) *LazyBuffer
func MakeLoadConstBuffer ¶
func MakeLoadConstBuffer(c float32, shape Shape) *LazyBuffer
func NewLazyBuffer ¶
func NewLazyBuffer(st *ShapeTracker, ot OpType, op *LazyOp) *LazyBuffer
func (*LazyBuffer) BinaryOp ¶
func (b *LazyBuffer) BinaryOp(op Op, y *LazyBuffer) *LazyBuffer
func (*LazyBuffer) MovementOp ¶
func (b *LazyBuffer) MovementOp(op Op, arg any) *LazyBuffer
func (*LazyBuffer) ProcessingOp ¶
func (b *LazyBuffer) ProcessingOp(op Op, w *LazyBuffer, arg any) *LazyBuffer
func (*LazyBuffer) Realize ¶
func (b *LazyBuffer) Realize() *Buffer
func (*LazyBuffer) ReduceOp ¶
func (b *LazyBuffer) ReduceOp(op Op, newShape Shape) *LazyBuffer
func (*LazyBuffer) Shape ¶
func (b *LazyBuffer) Shape() Shape
func (*LazyBuffer) UnaryOp ¶
func (b *LazyBuffer) UnaryOp(op Op) *LazyBuffer
type LazyOp ¶
func (*LazyOp) ForEachBuffer ¶
func (o *LazyOp) ForEachBuffer(fn func(*LazyBuffer) bool) bool
func (*LazyOp) GetBuffers ¶
func (o *LazyOp) GetBuffers() []*LazyBuffer
type LogFunc ¶
type LogFunc struct{}
func (LogFunc) Backward ¶
func (f LogFunc) Backward(ctx *FuncContext, g *LazyBuffer) []*LazyBuffer
func (LogFunc) Forward ¶
func (f LogFunc) Forward(ctx *FuncContext, bs []*LazyBuffer) *LazyBuffer
type MaxFunc ¶
type MaxFunc struct {
// contains filtered or unexported fields
}
func (MaxFunc) Backward ¶
func (f MaxFunc) Backward(ctx *FuncContext, g *LazyBuffer) []*LazyBuffer
func (MaxFunc) Forward ¶
func (f MaxFunc) Forward(ctx *FuncContext, bs []*LazyBuffer) *LazyBuffer
type MulFunc ¶
type MulFunc struct{}
func (MulFunc) Backward ¶
func (a MulFunc) Backward(ctx *FuncContext, g *LazyBuffer) []*LazyBuffer
func (MulFunc) Forward ¶
func (a MulFunc) Forward(ctx *FuncContext, bs []*LazyBuffer) *LazyBuffer
type PermuteFunc ¶
type PermuteFunc struct {
Order []Dim
}
func (PermuteFunc) Backward ¶
func (f PermuteFunc) Backward(ctx *FuncContext, g *LazyBuffer) []*LazyBuffer
func (PermuteFunc) Forward ¶
func (f PermuteFunc) Forward(ctx *FuncContext, bs []*LazyBuffer) *LazyBuffer
type PowFunc ¶
type PowFunc struct{}
func (PowFunc) Backward ¶
func (a PowFunc) Backward(ctx *FuncContext, g *LazyBuffer) []*LazyBuffer
func (PowFunc) Forward ¶
func (a PowFunc) Forward(ctx *FuncContext, bs []*LazyBuffer) *LazyBuffer
type RealizedOp ¶
type RealizedOp struct {
// contains filtered or unexported fields
}
type ReluFunc ¶
type ReluFunc struct{}
func (ReluFunc) Backward ¶
func (f ReluFunc) Backward(ctx *FuncContext, g *LazyBuffer) []*LazyBuffer
func (ReluFunc) Forward ¶
func (f ReluFunc) Forward(ctx *FuncContext, bs []*LazyBuffer) *LazyBuffer
type ReshapeFunc ¶
type ReshapeFunc struct {
Shape Shape
}
func (ReshapeFunc) Backward ¶
func (f ReshapeFunc) Backward(ctx *FuncContext, g *LazyBuffer) []*LazyBuffer
func (ReshapeFunc) Forward ¶
func (f ReshapeFunc) Forward(ctx *FuncContext, bs []*LazyBuffer) *LazyBuffer
type ShapeStride ¶
type ShapeStride struct {
Shape, Stride Dim
}
func ToShapeStrides ¶
func ToShapeStrides(shape Shape, strides Strides) []ShapeStride
type ShapeTracker ¶
type ShapeTracker struct {
// contains filtered or unexported fields
}
func NewShapeTracker ¶
func NewShapeTracker(shape Shape) *ShapeTracker
func (*ShapeTracker) Clone ¶
func (st *ShapeTracker) Clone() *ShapeTracker
func (*ShapeTracker) Contiguous ¶
func (st *ShapeTracker) Contiguous() bool
func (*ShapeTracker) Expand ¶
func (st *ShapeTracker) Expand(newShape Shape)
func (*ShapeTracker) Flip ¶
func (st *ShapeTracker) Flip(axes ...Dim)
func (*ShapeTracker) MovementOp ¶
func (st *ShapeTracker) MovementOp(op Op, arg any)
func (*ShapeTracker) Offset ¶
func (st *ShapeTracker) Offset() Dim
func (*ShapeTracker) Permute ¶
func (st *ShapeTracker) Permute(axis ...Dim)
func (*ShapeTracker) Reshape ¶
func (st *ShapeTracker) Reshape(newShape Shape)
func (*ShapeTracker) Shape ¶
func (st *ShapeTracker) Shape() Shape
func (*ShapeTracker) Stride ¶
func (st *ShapeTracker) Stride(mul ...Dim)
func (*ShapeTracker) Strides ¶
func (st *ShapeTracker) Strides() Strides
type SliceBound ¶
type SliceBound struct {
Start, Stop Dim
}
type SubFunc ¶
type SubFunc struct{}
func (SubFunc) Backward ¶
func (a SubFunc) Backward(ctx *FuncContext, g *LazyBuffer) []*LazyBuffer
func (SubFunc) Forward ¶
func (a SubFunc) Forward(ctx *FuncContext, bs []*LazyBuffer) *LazyBuffer
type SumFunc ¶
type SumFunc struct {
Axis []int
}
func (SumFunc) Backward ¶
func (f SumFunc) Backward(ctx *FuncContext, g *LazyBuffer) []*LazyBuffer
func (SumFunc) Forward ¶
func (f SumFunc) Forward(ctx *FuncContext, bs []*LazyBuffer) *LazyBuffer
type Tensor ¶
type Tensor struct {
// contains filtered or unexported fields
}
func BroadcastedTensor ¶
func NewTensor ¶
func NewTensor(data *LazyBuffer, requiresGrad bool) *Tensor
func (*Tensor) Data ¶
func (t *Tensor) Data() *LazyBuffer
func (*Tensor) FullSoftmax ¶
func (t *Tensor) FullSoftmax() TensorSoftmax
func (*Tensor) LogSoftmax ¶
func (*Tensor) RequiresGrad ¶
type TensorSoftmax ¶
type TensorSoftmax struct {
M, E, Ss *Tensor
}
type View ¶
type View struct {
// contains filtered or unexported fields
}
func ViewFromShape ¶
func (*View) BaseStrides ¶
func (*View) Contiguous ¶
func (View) ShapeStrides ¶
func (v View) ShapeStrides() []ShapeStride
Source Files ¶
Click to show internal directories.
Click to hide internal directories.