Interface TensorBackend
- All Known Implementing Classes:
CpuBackend,MetalBackend
public interface TensorBackend
-
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) In-place AdamW update.addBroadcastCols(Tensor a, Tensor colVector) addBroadcastRows(Tensor a, Tensor rowVector) voidaddInPlace(Tensor a, Tensor b) addRowVector(Tensor a, Tensor rowVector) voidaddScalarInPlace(Tensor a, float s) crossEntropyGradient(Tensor logits, int[] targets) floatcrossEntropyLoss(Tensor logits, int[] targets) divideBroadcastCols(Tensor a, Tensor colVector) voiddivideInPlace(Tensor a, Tensor b) divideScalar(Tensor a, float scalar) voiddivideScalarInPlace(Tensor a, float s) voidexpInPlace(Tensor a) geluBackward(Tensor input, Tensor gradOutput) voidlayerNormBackward(Tensor dXHat, Tensor xHat, Tensor std, int dim) LayerNorm backward through normalization (given dXHat, xHat, std).voidlogInPlace(Tensor a) default voidMaterialize a tensor: flush any pending GPU computation and download the result to the tensor's CPU data[].multiplyBroadcastCols(Tensor a, Tensor colVector) multiplyBroadcastRows(Tensor a, Tensor rowVector) voidmultiplyInPlace(Tensor a, Tensor b) multiplyScalar(Tensor a, float scalar) voidmultiplyScalarInPlace(Tensor a, float s) voidnegInPlace(Tensor a) default voidRelease backend-owned resources (GPU buffers, native handles, etc.).reluBackward(Tensor input, Tensor gradOutput) voidvoidscatterAddRows(Tensor target, int[] indices, Tensor grad) voidsoftmaxBackward(Tensor gradOutput, Tensor softmaxOut) softmaxRows(Tensor logits) voidsubtractBroadcastCols(Tensor a, Tensor colVector) voidsubtractInPlace(Tensor a, Tensor b) floatfloatvoid
-
Method Details
-
matmul
-
add
-
subtract
-
multiply
-
divide
-
addRowVector
-
addBroadcastCols
-
divideBroadcastCols
-
subtractBroadcastCols
-
multiplyBroadcastCols
-
addBroadcastRows
-
multiplyBroadcastRows
-
multiplyScalar
-
addScalar
-
divideScalar
-
sumRows
-
sumAlongRows
-
sumAlongCols
-
meanAlongRows
-
varianceAlongRows
-
maxAlongRows
-
sum
-
sumAbs
-
transpose
-
clamp
-
sqrt
-
pow
-
neg
-
exp
-
log
-
tanh
-
sigmoid
-
relu
-
reluBackward
-
gelu
-
geluBackward
-
softmaxRows
-
softmaxBackward
-
crossEntropyLoss
-
crossEntropyGradient
-
adamWUpdate
void adamWUpdate(Tensor w, Tensor g, Tensor mt, Tensor vt, float lr, float beta1, float beta2, float eps, float weightDecay, float bc1, float bc2) In-place AdamW update. Mutates w, mt, vt. -
layerNormBackward
LayerNorm backward through normalization (given dXHat, xHat, std). -
scatterAddRows
-
addInPlace
-
subtractInPlace
-
multiplyInPlace
-
divideInPlace
-
multiplyScalarInPlace
-
addScalarInPlace
-
divideScalarInPlace
-
sqrtInPlace
-
negInPlace
-
expInPlace
-
logInPlace
-
reluInPlace
-
geluInPlace
-
tanhInPlace
-
sigmoidInPlace
-
materializeTensor
Materialize a tensor: flush any pending GPU computation and download the result to the tensor's CPU data[]. Default is a no-op (for CpuBackend). -
releaseResources
default void releaseResources()Release backend-owned resources (GPU buffers, native handles, etc.). Default is a no-op for backends without external resources.
-