Class CpuBackend
java.lang.Object
io.github.kirstenali.deepj.tensor.cpu.CpuBackend
- All Implemented Interfaces:
TensorBackend
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadamWUpdate(Tensor w, Tensor g, Tensor mt, Tensor vt, float lr, float beta1, float beta2, float eps, float weightDecay, float bc1, float bc2) addBroadcastCols(Tensor a, Tensor cv) addBroadcastRows(Tensor a, Tensor rv) voidaddInPlace(Tensor a, Tensor b) addRowVector(Tensor a, Tensor rv) voidaddScalarInPlace(Tensor a, float s) batchedMatmul(Tensor left, Tensor right, int batches, boolean ta, boolean tb) causalMask(int size) causalSoftmax(Tensor input, int length, float scale) voidExplicitly assigns logical values, casting to the destination's storage dtype.crossEntropy(Tensor logits, int[] targets) crossEntropy(Tensor logits, int[] targets, boolean[] mask) crossEntropyGradient(Tensor logits, int[] targets) crossEntropyGradient(Tensor logits, int[] targets, boolean[] mask) floatcrossEntropyLoss(Tensor logits, int[] targets) floatcrossEntropyLoss(Tensor logits, int[] targets, boolean[] mask) divideBroadcastCols(Tensor a, Tensor cv) voiddivideInPlace(Tensor a, Tensor b) divideScalar(Tensor a, float s) voiddivideScalarInPlace(Tensor a, float s) voidexpInPlace(Tensor a) geluBackward(Tensor input, Tensor gradOutput) voidfloatvoidindexSelect(Tensor input, int axis, int[] indices) indexSelectGradient(Tensor gradient, int[] shape, int axis, int[] indices) layerNormBackward(Tensor dXHat, Tensor xHat, Tensor std, int dim) voidlogInPlace(Tensor a) maximumAxes(Tensor input, int[] axes, boolean keep) maximumAxesBackward(Tensor input, Tensor maximum, Tensor gradient, int[] axes, boolean keep) mergeHeads(Tensor input, int heads) multiplyBroadcastCols(Tensor a, Tensor cv) multiplyBroadcastRows(Tensor a, Tensor rv) voidmultiplyInPlace(Tensor a, Tensor b) multiplyScalar(Tensor a, float s) voidmultiplyScalarInPlace(Tensor a, float s) voidnegInPlace(Tensor a) normalizationBackward(Tensor gradient, Tensor normalized, Tensor denominator, Tensor gamma, boolean centered) ones(int rows, int cols) voidreluBackward(Tensor input, Tensor gradOutput) voidrmsNormBackward(Tensor gradient, Tensor normalized, Tensor rms, Tensor gamma) sampleRows(Tensor t, int n, Random rnd) voidscatterAddRows(Tensor target, int[] indices, Tensor grad) voidvoidvoidsliceGradient(Tensor gradient, int[] shape, int axis, int start, int step) softmaxAxis(Tensor input, int axis) softmaxBackward(Tensor gradOutput, Tensor softmaxOut) softmaxRows(Tensor logits) splitHeads(Tensor input, int heads) voidsubtractBroadcastCols(Tensor a, Tensor cv) voidsubtractInPlace(Tensor a, Tensor b) floatfloatswiGluBackward(Tensor gradient, Tensor gate, Tensor up) voidvarianceAxes(Tensor input, int[] axes, boolean keep, int correction) zeros(int rows, int cols) Backend-owned positive-zero storage; ordinary Tensor constructors stay CPU-backed.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.kirstenali.deepj.tensor.TensorBackend
causalMask, copy, expand, headPrefixMatmul, l2Norm, materializeTensor, permute, releaseResources, releaseTemporaryResources, reshape, rotary, select, slice, softmaxAxisBackward, softmaxBackward, sumToShape, unsqueeze, usesDeviceStorage, view, writeHeadCache
-
Constructor Details
-
CpuBackend
public CpuBackend()
-
-
Method Details
-
causalSoftmax
-
sliceRows
-
splitHeads
-
mergeHeads
-
batchedMatmul
-
copyInto
Description copied from interface:TensorBackendExplicitly assigns logical values, casting to the destination's storage dtype. -
zeros
-
cast
-
sumAxes
-
meanAxes
-
varianceAxes
-
maximumAxes
-
maximumAxesBackward
-
sliceGradient
-
softmaxAxis
-
indexSelect
-
indexAdd
-
indexSelectGradient
-
crossEntropy
-
crossEntropy
-
normalize
public NormalizationResult normalize(Tensor input, Tensor gamma, Tensor beta, float epsilon, boolean centered) -
normalizationBackward
-
rmsNorm
-
rmsNormBackward
-
swiGlu
-
swiGluBackward
-
crossEntropyLoss
-
crossEntropyGradient
-
crossEntropyLoss
-
crossEntropyGradient
-
adamWUpdate
-
layerNormBackward
-
get
-
set
-
getRow
-
setRow
-
sliceRows
-
scatterAddRows
-
sampleRows
-
addInPlace
-
subtractInPlace
-
multiplyInPlace
-
divideInPlace
-
multiplyScalarInPlace
-
addScalarInPlace
-
divideScalarInPlace
-
sqrtInPlace
-
negInPlace
-
expInPlace
-
logInPlace
-
reluInPlace
-
geluInPlace
-
tanhInPlace
-
sigmoidInPlace
-
print
-
sumRows
-
sumAlongRows
-
sumAlongCols
-
meanAlongRows
-
varianceAlongRows
-
maxAlongRows
-
sum
-
sumAbs
-
transpose
-
clamp
-
sqrt
-
pow
-
neg
-
exp
-
log
-
tanh
-
sigmoid
-
relu
-
gelu
-
reluBackward
-
geluBackward
-
softmaxRows
-
softmaxBackward
-
zeros
Description copied from interface:TensorBackendBackend-owned positive-zero storage; ordinary Tensor constructors stay CPU-backed.- Specified by:
zerosin interfaceTensorBackend
-
ones
-
random
-
causalMask
-
matmul
- Specified by:
matmulin interfaceTensorBackend
-
add
- Specified by:
addin interfaceTensorBackend
-
subtract
- Specified by:
subtractin interfaceTensorBackend
-
multiply
- Specified by:
multiplyin interfaceTensorBackend
-
divide
- Specified by:
dividein interfaceTensorBackend
-
addRowVector
- Specified by:
addRowVectorin interfaceTensorBackend
-
addBroadcastRows
- Specified by:
addBroadcastRowsin interfaceTensorBackend
-
multiplyBroadcastRows
- Specified by:
multiplyBroadcastRowsin interfaceTensorBackend
-
addBroadcastCols
- Specified by:
addBroadcastColsin interfaceTensorBackend
-
subtractBroadcastCols
- Specified by:
subtractBroadcastColsin interfaceTensorBackend
-
multiplyBroadcastCols
- Specified by:
multiplyBroadcastColsin interfaceTensorBackend
-
divideBroadcastCols
- Specified by:
divideBroadcastColsin interfaceTensorBackend
-
multiplyScalar
- Specified by:
multiplyScalarin interfaceTensorBackend
-
addScalar
- Specified by:
addScalarin interfaceTensorBackend
-
divideScalar
- Specified by:
divideScalarin interfaceTensorBackend
-