cpu

package
v0.0.0-...-2fe1034 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCompoundKernel

func BuildCompoundKernel(typeArgs []acc.TypeArg) (string, string)

Types

type ConvLayer

type ConvLayer struct {
	ConvLayerBase
}

func NewConvLayer

func NewConvLayer(
	lib *CpuGenerator,
	dtype base.Dtype,
	params *backends.ConvParams) *ConvLayer

func (*ConvLayer) Init

func (n *ConvLayer) Init(
	lib *CpuGenerator,
	dtype base.Dtype,
	params *backends.ConvParams)

type ConvLayerBase

type ConvLayerBase struct {
	// contains filtered or unexported fields
}

func (*ConvLayerBase) BpropConv

func (n *ConvLayerBase) BpropConv(
	i backends.Tensor,
	f backends.Tensor,
	o backends.Tensor,
	x backends.Tensor,
	bias backends.Tensor,
	bsum backends.Tensor,
	alpha float64,
	beta float64,
	relu bool,
	brelu bool,
	slope float64)

func (*ConvLayerBase) C

func (n *ConvLayerBase) C() int

func (*ConvLayerBase) CompoundOps

func (n *ConvLayerBase) CompoundOps(
	o backends.Tensor,
	x backends.Tensor,
	bias backends.Tensor,
	bsum backends.Tensor,
	relu bool,
	brelu bool,
	slope float64)

func (*ConvLayerBase) DHW

func (n *ConvLayerBase) DHW() []int

func (*ConvLayerBase) DimF

func (n *ConvLayerBase) DimF() []int

func (*ConvLayerBase) DimF2

func (n *ConvLayerBase) DimF2() []int

func (*ConvLayerBase) DimI

func (n *ConvLayerBase) DimI() []int

func (*ConvLayerBase) DimI2

func (n *ConvLayerBase) DimI2() []int

func (*ConvLayerBase) DimO

func (n *ConvLayerBase) DimO() []int

func (*ConvLayerBase) DimO2

func (n *ConvLayerBase) DimO2() []int

func (*ConvLayerBase) DimS

func (n *ConvLayerBase) DimS() []int

func (*ConvLayerBase) FpropConv

func (n *ConvLayerBase) FpropConv(
	i backends.Tensor,
	f backends.Tensor,
	o backends.Tensor,
	x backends.Tensor,
	bias backends.Tensor,
	bsum backends.Tensor,
	alpha float64,
	beta float64,
	relu bool,
	brelu bool,
	slope float64)

func (*ConvLayerBase) Init

func (n *ConvLayerBase) Init(lib *CpuGenerator, dtype base.Dtype, params *ConvParams)

func (*ConvLayerBase) K

func (n *ConvLayerBase) K() int

func (*ConvLayerBase) M

func (n *ConvLayerBase) M() int

func (*ConvLayerBase) MPQ

func (n *ConvLayerBase) MPQ() []int

func (*ConvLayerBase) N

func (n *ConvLayerBase) N() int

func (*ConvLayerBase) NCK

func (n *ConvLayerBase) NCK() []int

func (*ConvLayerBase) NOut

func (n *ConvLayerBase) NOut() int

func (*ConvLayerBase) P

func (n *ConvLayerBase) P() int

func (*ConvLayerBase) Padding

func (n *ConvLayerBase) Padding() []int

func (*ConvLayerBase) Q

func (n *ConvLayerBase) Q() int

func (*ConvLayerBase) SizeF

func (n *ConvLayerBase) SizeF() int

func (*ConvLayerBase) SizeI

func (n *ConvLayerBase) SizeI() int

func (*ConvLayerBase) SizeO

func (n *ConvLayerBase) SizeO() int

func (*ConvLayerBase) Strides

func (n *ConvLayerBase) Strides() []int

func (*ConvLayerBase) TRS

func (n *ConvLayerBase) TRS() []int

func (*ConvLayerBase) UpdateConv

func (n *ConvLayerBase) UpdateConv(
	i backends.Tensor,
	e backends.Tensor,
	u backends.Tensor,
	alpha float64,
	beta float64,
	gradBias backends.Tensor)

type ConvParams

type ConvParams struct {
	N    int
	C    int
	K    int
	D    int
	H    int
	W    int
	T    int
	R    int
	S    int
	M    int
	P    int
	Q    int
	PadD int
	PadH int
	PadW int
	StrD int
	StrH int
	StrW int
	DilD int
	DilH int
	DilW int
}

func (*ConvParams) InitConv

func (a *ConvParams) InitConv(params *backends.ConvParams)

func (*ConvParams) InitDeconv

func (a *ConvParams) InitDeconv(params *backends.DeconvParams)

type CpuDeviceAllocation

type CpuDeviceAllocation struct {
	// contains filtered or unexported fields
}

func NewCpuDeviceAllocation

func NewCpuDeviceAllocation(index int, nbytes int, offset int) *CpuDeviceAllocation

func (*CpuDeviceAllocation) Add

type CpuGenerator

type CpuGenerator struct {
	acc.AccGeneratorBase
	// contains filtered or unexported fields
}

func NewCpuGenerator

func NewCpuGenerator(
	rngSeed int,
	defaultDtype base.Dtype,
	stochasticRound int,
	bench bool,
	scratchSize int,
	histBins int,
	histOffset int,
	compatMode backends.CompatMode) *CpuGenerator

func (*CpuGenerator) Assign

func (b *CpuGenerator) Assign(out *acc.AccTensor, value backends.Value) backends.Value

func (*CpuGenerator) Binarize

func (b *CpuGenerator) Binarize(
	ary backends.Tensor, out backends.Tensor, stochastic bool) backends.Tensor

func (*CpuGenerator) BpropConv

func (b *CpuGenerator) BpropConv(
	layer backends.ConvLayerBase,
	f backends.Tensor,
	e backends.Tensor,
	gradI backends.Tensor,
	x backends.Tensor,
	bias backends.Tensor,
	bsum backends.Tensor,
	alpha float64,
	beta float64,
	relu bool,
	brelu bool,
	slope float64)

func (*CpuGenerator) BpropLrn

func (b *CpuGenerator) BpropLrn(
	layer backends.LrnLayer,
	i backends.Tensor,
	o backends.Tensor,
	e backends.Tensor,
	delta backends.Tensor,
	denom backends.Tensor,
	alpha float64,
	beta float64,
	ascale float64,
	bpower float64)

func (*CpuGenerator) BpropPool

func (b *CpuGenerator) BpropPool(
	layer backends.PoolLayer,
	i backends.Tensor,
	o backends.Tensor,
	argmax backends.Tensor,
	alpha float64,
	beta float64)

func (*CpuGenerator) BpropRelu

func (b *CpuGenerator) BpropRelu(
	layer backends.Layer,
	x backends.Tensor,
	errors backends.Tensor,
	deltas backends.Tensor,
	slope float64) backends.Value

func (*CpuGenerator) BpropSkipNode

func (b *CpuGenerator) BpropSkipNode(
	errors backends.Tensor, deltas backends.Tensor, alpha float64, beta float64)

func (*CpuGenerator) BpropTransform

func (b *CpuGenerator) BpropTransform(
	nglayer backends.Layer,
	transform backends.Transform,
	outputs backends.Tensor,
	errors backends.Tensor,
	deltas backends.Tensor,
	relu bool)

func (*CpuGenerator) BuildProlog

func (b *CpuGenerator) BuildProlog()

func (*CpuGenerator) CompoundBpropBn

func (b *CpuGenerator) CompoundBpropBn(
	deltaOut backends.Tensor,
	gradGamma backends.Tensor,
	gradBeta backends.Tensor,
	deltaIn backends.Tensor,
	x backends.Tensor,
	xsum backends.Tensor,
	xvar backends.Tensor,
	gamma backends.Tensor,
	eps float64,
	binary bool,
	later backends.BatchNormLayer)

func (*CpuGenerator) CompoundDot

func (b *CpuGenerator) CompoundDot(
	x backends.Tensor,
	y backends.Tensor,
	z backends.Tensor,
	alpha float64,
	beta float64,
	relu bool,
	bsum backends.Tensor) backends.Tensor

func (*CpuGenerator) CompoundDotCpu

func (b *CpuGenerator) CompoundDotCpu(
	x *acc.AccTensor,
	y *acc.AccTensor,
	z *acc.AccTensor,
	alpha float64,
	beta float64,
	relu bool,
	bsum *acc.AccTensor,
	repeat int,
	size []int) *acc.AccTensor

func (*CpuGenerator) CompoundFpropBn

func (b *CpuGenerator) CompoundFpropBn(
	x backends.Tensor,
	xsum backends.Tensor,
	xvar backends.Tensor,
	gmean backends.Tensor,
	gvar backends.Tensor,
	gamma backends.Tensor,
	beta backends.Tensor,
	y backends.Tensor,
	eps float64,
	rho float64,
	computeBatchSum bool,
	accumbeta float64,
	relu bool,
	binary bool,
	inference bool,
	outputs backends.Tensor,
	later backends.BatchNormLayer)

func (*CpuGenerator) CompoundKernel

func (b *CpuGenerator) CompoundKernel(args []backends.Value) backends.Value

func (*CpuGenerator) ConfigureCodeOutput

func (b *CpuGenerator) ConfigureCodeOutput(
	buildMainCpp bool,
	filePrefix string,
	hostNamespace string,
	kernelPrefix string)

func (*CpuGenerator) FormatBufferRef

func (b *CpuGenerator) FormatBufferRef(tensor backends.Tensor, paren bool) string

func (*CpuGenerator) FpropConv

func (b *CpuGenerator) FpropConv(
	layer backends.ConvLayerBase,
	i backends.Tensor,
	f backends.Tensor,
	o backends.Tensor,
	x backends.Tensor,
	bias backends.Tensor,
	bsum backends.Tensor,
	alpha float64,
	beta float64,
	relu bool,
	brelu bool,
	slope float64)

func (*CpuGenerator) FpropLrn

func (b *CpuGenerator) FpropLrn(
	layer backends.LrnLayer,
	i backends.Tensor,
	o backends.Tensor,
	denom backends.Tensor,
	alpha float64,
	beta float64,
	ascale float64,
	bpower float64)

func (*CpuGenerator) FpropPool

func (b *CpuGenerator) FpropPool(
	layer backends.PoolLayer,
	i backends.Tensor,
	o backends.Tensor,
	argmax backends.Tensor,
	alpha float64,
	beta float64)

func (*CpuGenerator) FpropRelu

func (b *CpuGenerator) FpropRelu(
	layer backends.Layer,
	x backends.Tensor,
	slope float64) backends.Value

func (*CpuGenerator) FpropSkipNode

func (b *CpuGenerator) FpropSkipNode(x backends.Tensor, y backends.Tensor, beta float64)

func (*CpuGenerator) FpropSoftmax

func (b *CpuGenerator) FpropSoftmax(x backends.Value, axis int) backends.Value

func (*CpuGenerator) FpropTransform

func (b *CpuGenerator) FpropTransform(
	nglayer backends.Layer,
	transform backends.Transform,
	inputs backends.Tensor,
	outputs backends.Tensor,
	relu bool)

func (*CpuGenerator) GetData

func (b *CpuGenerator) GetData(
	dest string, start string, stop string, x backends.Tensor) string

func (*CpuGenerator) GetFloat

func (b *CpuGenerator) GetFloat(src acc.DeviceAllocation, size int) string

func (*CpuGenerator) GetInt

func (b *CpuGenerator) GetInt(src acc.DeviceAllocation, size int) string

func (*CpuGenerator) GetMetricSum

func (b *CpuGenerator) GetMetricSum(x backends.Tensor, start string, stop string) string

func (*CpuGenerator) Init

func (b *CpuGenerator) Init(
	self generators.Generator,
	rngSeed int,
	defaultDtype base.Dtype,
	stochasticRound int,
	bench bool,
	scratchSize int,
	histBins int,
	histOffset int,
	compatMode backends.CompatMode)

func (*CpuGenerator) LookupKernel

func (b *CpuGenerator) LookupKernel(key string) *Kernel

func (*CpuGenerator) MakeBinaryMask

func (b *CpuGenerator) MakeBinaryMask(out backends.Tensor, keepThresh float64)

func (*CpuGenerator) MemAlloc

func (b *CpuGenerator) MemAlloc(nbytes int) acc.DeviceAllocation

func (*CpuGenerator) MemcpyDtodAsync

func (b *CpuGenerator) MemcpyDtodAsync(
	dest acc.DeviceAllocation, src acc.DeviceAllocation, size int)

func (*CpuGenerator) MemsetD16Async

func (b *CpuGenerator) MemsetD16Async(dest acc.DeviceAllocation, data uint16, count int)

func (*CpuGenerator) MemsetD32Async

func (b *CpuGenerator) MemsetD32Async(dest acc.DeviceAllocation, data uint32, count int)

func (*CpuGenerator) MemsetD8Async

func (b *CpuGenerator) MemsetD8Async(dest acc.DeviceAllocation, data uint8, count int)

func (*CpuGenerator) NewBatchNormLayer

func (b *CpuGenerator) NewBatchNormLayer(inShape []int) backends.BatchNormLayer

func (*CpuGenerator) NewConvLayer

func (b *CpuGenerator) NewConvLayer(
	dtype base.Dtype, params *backends.ConvParams) backends.ConvLayer

func (*CpuGenerator) NewDeconvLayer

func (b *CpuGenerator) NewDeconvLayer(
	dtype base.Dtype, params *backends.DeconvParams) backends.DeconvLayer

func (*CpuGenerator) NewLrnLayer

func (b *CpuGenerator) NewLrnLayer(
	dtype base.Dtype, params *backends.LrnParams) backends.LrnLayer

func (*CpuGenerator) NewPoolLayer

func (b *CpuGenerator) NewPoolLayer(
	dtype base.Dtype, params *backends.PoolParams) backends.PoolLayer

func (*CpuGenerator) NewReluLayer

func (b *CpuGenerator) NewReluLayer() backends.Layer

func (*CpuGenerator) OutputCode

func (b *CpuGenerator) OutputCode(outDir string) error

func (*CpuGenerator) RegisterKernel

func (b *CpuGenerator) RegisterKernel(key string, kernel *Kernel)

func (*CpuGenerator) RngNormal

func (b *CpuGenerator) RngNormal(out backends.Tensor, loc float64, scale float64, size []int)

func (*CpuGenerator) RngUniform

func (b *CpuGenerator) RngUniform(out backends.Tensor, low float64, high float64, size []int)

func (*CpuGenerator) ScratchBufferInit

func (b *CpuGenerator) ScratchBufferInit()

func (*CpuGenerator) ScratchBufferOffset

func (b *CpuGenerator) ScratchBufferOffset(size int) acc.DeviceAllocation

func (*CpuGenerator) SetScratchSize

func (b *CpuGenerator) SetScratchSize(args ...int)

func (*CpuGenerator) UpdateConv

func (b *CpuGenerator) UpdateConv(
	layer backends.ConvLayerBase,
	i backends.Tensor,
	e backends.Tensor,
	gradF backends.Tensor,
	alpha float64,
	beta float64,
	gradBias backends.Tensor)

type DeconvLayer

type DeconvLayer struct {
	ConvLayerBase
}

func NewDeconvLayer

func NewDeconvLayer(
	lib *CpuGenerator,
	dtype base.Dtype,
	params *backends.DeconvParams) *DeconvLayer

func (*DeconvLayer) Init

func (n *DeconvLayer) Init(
	lib *CpuGenerator,
	dtype base.Dtype,
	params *backends.DeconvParams)

type Kernel

type Kernel struct {
	// contains filtered or unexported fields
}

func NewKernel

func NewKernel(lib *CpuGenerator, name string, code string) *Kernel

type LrnLayer

type LrnLayer struct {
	PoolLayer
}

func NewLrnLayer

func NewLrnLayer(
	lib *CpuGenerator,
	dtype base.Dtype,
	params *backends.LrnParams) *LrnLayer

func (*LrnLayer) BpropLrn

func (n *LrnLayer) BpropLrn(
	i backends.Tensor,
	o backends.Tensor,
	e backends.Tensor,
	delta backends.Tensor,
	denom backends.Tensor,
	ascale float64,
	bpower float64)

func (*LrnLayer) FpropLrn

func (n *LrnLayer) FpropLrn(
	i backends.Tensor,
	o backends.Tensor,
	denom backends.Tensor,
	ascale float64,
	bpower float64)

func (*LrnLayer) Init

func (n *LrnLayer) Init(
	lib *CpuGenerator,
	dtype base.Dtype,
	params *backends.LrnParams)

type PoolLayer

type PoolLayer struct {
	// contains filtered or unexported fields
}

func NewPoolLayer

func NewPoolLayer(lib *CpuGenerator, dtype base.Dtype, params *backends.PoolParams) *PoolLayer

func (*PoolLayer) BpropPool

func (n *PoolLayer) BpropPool(
	i backends.Tensor,
	o backends.Tensor,
	argmax backends.Tensor,
	alpha float64,
	beta float64)

func (*PoolLayer) C

func (n *PoolLayer) C() int

func (*PoolLayer) DHW

func (n *PoolLayer) DHW() []int

func (*PoolLayer) DimF2

func (n *PoolLayer) DimF2() []int

func (*PoolLayer) DimI

func (n *PoolLayer) DimI() []int

func (*PoolLayer) DimI2

func (n *PoolLayer) DimI2() []int

func (*PoolLayer) DimO

func (n *PoolLayer) DimO() []int

func (*PoolLayer) DimO2

func (n *PoolLayer) DimO2() []int

func (*PoolLayer) FpropPool

func (n *PoolLayer) FpropPool(
	i backends.Tensor,
	o backends.Tensor,
	argmax backends.Tensor,
	beta float64)

func (*PoolLayer) Init

func (n *PoolLayer) Init(lib *CpuGenerator, dtype base.Dtype, params *backends.PoolParams)

func (*PoolLayer) JTRS

func (n *PoolLayer) JTRS() []int

func (*PoolLayer) K

func (n *PoolLayer) K() int

func (*PoolLayer) M

func (n *PoolLayer) M() int

func (*PoolLayer) MPQ

func (n *PoolLayer) MPQ() []int

func (*PoolLayer) N

func (n *PoolLayer) N() int

func (*PoolLayer) NOut

func (n *PoolLayer) NOut() int

func (*PoolLayer) Op

func (n *PoolLayer) Op() backends.PoolOp

func (*PoolLayer) P

func (n *PoolLayer) P() int

func (*PoolLayer) Padding

func (n *PoolLayer) Padding() []int

func (*PoolLayer) Q

func (n *PoolLayer) Q() int

func (*PoolLayer) SizeF

func (n *PoolLayer) SizeF() int

func (*PoolLayer) SizeI

func (n *PoolLayer) SizeI() int

func (*PoolLayer) SizeO

func (n *PoolLayer) SizeO() int

func (*PoolLayer) Strides

func (n *PoolLayer) Strides() []int

Jump to

Keyboard shortcuts

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