oa::FnMatrix

FnMatrix namespace in the OA Core public surface.

NsC++ public headers

Public Functions

oa::Matrix oa::FnMatrix::abs(const oa::Matrix & inA)
oa::Matrix oa::FnMatrix::add(const oa::Matrix & inA, const oa::Matrix & inB)
void oa::FnMatrix::addInPlace(Matrix & inSelf, const Matrix & inOther)
oa::Matrix oa::FnMatrix::addScalar(const oa::Matrix & inA, oa::F32 inScalar)
void oa::FnMatrix::addScalarInPlace(Matrix & inSelf, oa::F32 inScalar)
oa::I64 oa::FnMatrix::argmax(const oa::Matrix & inA, oa::I32 inDim = -1)
Matrix oa::FnMatrix::avgPool2d(const Matrix & inX, oa::I32 inKernelSize, oa::I32 inStride, oa::I32 inPadding)
Matrix oa::FnMatrix::avgPool2dBwd(const Matrix & inX, const Matrix & inGradOutput, oa::I32 inKernelSize, oa::I32 inStride, oa::I32 inPadding)
BatchNorm2dBwdResult oa::FnMatrix::batchNorm2dBwd(const Matrix & inX, const Matrix & inGamma, const Matrix & inBeta, const Matrix & inMean, const Matrix & inVar, const Matrix & inOut, const Matrix & inDOut, oa::F32 inEps, bool inIsTraining)
oa::Matrix oa::FnMatrix::biasAdd(const oa::Matrix & inA, const oa::Matrix & inB)
Matrix oa::FnMatrix::bmm(const Matrix & inA, const Matrix & inB)
Matrix oa::FnMatrix::bmmNt(const Matrix & inA, const Matrix & inB)
Matrix oa::FnMatrix::cast(const Matrix & inSrc, oa::ScalarType inDtype)
void oa::FnMatrix::castInto(const Matrix & inSrc, Matrix & outDst)
Matrix oa::FnMatrix::categoricalAccuracyCount(const Matrix & inLogits, const Matrix & inLabels)
Matrix oa::FnMatrix::causalMask(oa::I64 inSeqLen)
Matrix oa::FnMatrix::causalMaskBwd(const Matrix & inGradOut)
Matrix oa::FnMatrix::channelNorm(const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, oa::I32 inBatch, oa::I32 inChannels, oa::I32 inSeqLen, oa::F32 inEps)
ChannelNormBwdResult oa::FnMatrix::channelNormBwd(const Matrix & inX, const Matrix & inWeight, const Matrix & inGradOutput, oa::I32 inBatch, oa::I32 inChannels, oa::I32 inSeqLen, oa::F32 inEps)
Matrix oa::FnMatrix::channelNormRelu(const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, oa::I32 inBatch, oa::I32 inChannels, oa::I32 inSeqLen, oa::F32 inEps)
ChannelNormBwdResult oa::FnMatrix::channelNormReluBwd(const Matrix & inX, const Matrix & inWeight, const Matrix & inFwdOut, const Matrix & inGradOutput, oa::I32 inBatch, oa::I32 inChannels, oa::I32 inSeqLen, oa::F32 inEps)
oa::Matrix oa::FnMatrix::clampMax(const oa::Matrix & inA, oa::F32 inMax)
oa::Matrix oa::FnMatrix::clampMin(const oa::Matrix & inA, oa::F32 inMin)
Matrix oa::FnMatrix::col2Im1d(const Matrix & inDCols, oa::I32 inN, oa::I32 inC, oa::I32 inL, oa::I32 inK, oa::I32 inStride, oa::I32 inPadding, oa::I32 inDilation, oa::I32 inOutL)
CompactRowsResult oa::FnMatrix::compactRows(const Matrix & inSelf, const Matrix & inMask)
Matrix oa::FnMatrix::compactRowsBwd(const Matrix & inGradOut, const Matrix & inRowMap, const Matrix & inCount, MatrixShape inInputShape)
Matrix oa::FnMatrix::concat(oa::Span<Matrix> inInputs, oa::I32 inDim = 0)
Matrix oa::FnMatrix::conv1dBwdData(const Matrix & inDOut, const Matrix & inWeight, oa::U32 inStride, oa::U32 inPadding, oa::U32 inDilation, const MatrixShape & inInputShape)
Conv1dBwdWeightResult oa::FnMatrix::conv1dBwdWeight(const Matrix & inInput, const Matrix & inDOut, const Matrix & inWeight, oa::U32 inStride, oa::U32 inPadding, oa::U32 inDilation)
Matrix oa::FnMatrix::conv1dGemm(const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, oa::I32 inStride = 1, oa::I32 inPadding = 0, oa::I32 inDilation = 1)
Matrix oa::FnMatrix::conv1dReluGemm(const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, oa::I32 inStride = 1, oa::I32 inPadding = 0, oa::I32 inDilation = 1)
Matrix oa::FnMatrix::conv2d(const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, oa::U32 inStride, oa::U32 inPadding, oa::U32 inGroups = 1)
Matrix oa::FnMatrix::conv2dBwdData(const Matrix & inDOut, const Matrix & inWeight, oa::U32 inStride, oa::U32 inPadding, const MatrixShape & inInputShape, oa::U32 inGroups = 1)
Conv2dBwdWeightResult oa::FnMatrix::conv2dBwdWeight(const Matrix & inInput, const Matrix & inDOut, const Matrix & inWeight, oa::U32 inStride, oa::U32 inPadding, oa::U32 inGroups = 1)
Matrix oa::FnMatrix::convTranspose2d(const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, oa::U32 inStride, oa::U32 inPadding)
Matrix oa::FnMatrix::convTranspose2dBwdData(const Matrix & inDOut, const Matrix & inWeight, oa::U32 inStride, oa::U32 inPadding, const MatrixShape & inInputShape)
ConvTranspose2dBwdWeightResult oa::FnMatrix::convTranspose2dBwdWeight(const Matrix & inInput, const Matrix & inDOut, const Matrix & inWeight, oa::U32 inStride, oa::U32 inPadding)
oa::Matrix oa::FnMatrix::copy(const oa::Matrix & inA)
oa::Status oa::FnMatrix::copyToHost(const Matrix & inSrc, void * outHost, oa::U64 inBytes)
oa::Matrix oa::FnMatrix::cos(const oa::Matrix & inA)
oa::Matrix oa::FnMatrix::dequantize(const oa::QuantMatrix & inInput)
Matrix oa::FnMatrix::detach(const Matrix & inSelf)
oa::Matrix oa::FnMatrix::div(const oa::Matrix & inA, const oa::Matrix & inB)
void oa::FnMatrix::divInPlace(Matrix & inSelf, const Matrix & inOther)
oa::Matrix oa::FnMatrix::divScalar(const oa::Matrix & inA, oa::F32 inScalar)
void oa::FnMatrix::divScalarInPlace(Matrix & inSelf, oa::F32 inScalar)
Matrix oa::FnMatrix::dropout(const Matrix & inA, oa::F32 inP, oa::U64 inSeed = 0)
oa::Matrix oa::FnMatrix::elu(const oa::Matrix & inA, oa::F32 inAlpha)
Matrix oa::FnMatrix::eluBwd(const Matrix & inForwardOutput, const Matrix & inGradOutput, oa::F32 inAlpha = 1.0f)
Matrix oa::FnMatrix::empty(MatrixShape inShape, oa::ScalarType inDtype = weightDtype(), oa::MemoryPlacement inPlacement = oa::MemoryPlacement::Auto)
Matrix oa::FnMatrix::empyrealmAdt(const Matrix & inDdA, const Matrix & inDt, oa::F32 inAFloor)
EmpyrealmAdtBwdResult oa::FnMatrix::empyrealmAdtBwd(const Matrix & inDOut, const Matrix & inDdA, const Matrix & inDt, oa::F32 inAFloor)
Matrix oa::FnMatrix::empyrealmDt(const Matrix & inX, oa::F32 inDtMin, oa::F32 inDtMax)
EmpyrealmDtAdtResult oa::FnMatrix::empyrealmDtAdt(const Matrix & inDtRaw, const Matrix & inDdA, oa::F32 inDtMin, oa::F32 inDtMax, oa::F32 inAFloor)
Matrix oa::FnMatrix::empyrealmDtBwd(const Matrix & inDOut, const Matrix & inX, oa::F32 inDtMin, oa::F32 inDtMax)
Mamba3PreprocessResult oa::FnMatrix::empyrealmPreprocess(const Matrix & inProjected, const Matrix & inDtBias, const Mamba3PreprocessConfig & inConfig)
Mamba3PreprocessBwdResult oa::FnMatrix::empyrealmPreprocessBwd(const Matrix & inProjected, const Matrix & inDtBias, const Matrix & inDZ, const Matrix & inDX, const Matrix & inDBh, const Matrix & inDCh, const Matrix & inDDT, const Matrix & inDADT, const Matrix & inDTrap, const Matrix & inDAngle, const Mamba3PreprocessConfig & inConfig)
Matrix oa::FnMatrix::empyrealmSiso(const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const SsmConfig & inConfig)
SsmBwdResult oa::FnMatrix::empyrealmSisoBwd(const Matrix & inDOut, const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const SsmConfig & inConfig)
Matrix oa::FnMatrix::empyrealmSisoStep(const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const Matrix & inSsmState, const Matrix & inAngleState, const Matrix & inKState, const Matrix & inVState, const SsmConfig & inConfig)
Matrix oa::FnMatrix::equal(const Matrix & inA, oa::F32 inValue)
oa::Matrix oa::FnMatrix::exp(const oa::Matrix & inA)
oa::Matrix oa::FnMatrix::fill(const oa::MatrixShape & inShape, oa::F32 inValue)
void oa::FnMatrix::fillInPlace(oa::Matrix & inSelf, oa::F32 inValue)
Matrix oa::FnMatrix::flashAttentionCausal(const Matrix & inQ, const Matrix & inK, const Matrix & inV, oa::F32 inScale)
FlashAttentionBwdResult oa::FnMatrix::flashAttentionCausalBwd(const Matrix & inQ, const Matrix & inK, const Matrix & inV, const Matrix & inOutput, const Matrix & inLogSumExp, const Matrix & inGradOutput, oa::F32 inScale)
Matrix oa::FnMatrix::fromBytes(oa::Span<const oa::U8> inData, MatrixShape inShape, oa::ScalarType inDtype = weightDtype())
Matrix oa::FnMatrix::fromInt32(oa::Span<const oa::I32> inData, MatrixShape inShape, oa::ScalarType inDtype = oa::ScalarType::Int32)
Matrix oa::FnMatrix::full(MatrixShape inShape, oa::F64 inValue, oa::ScalarType inDtype = weightDtype())
Matrix oa::FnMatrix::gather(const Matrix & inSelf, const Matrix & inIndices)
Matrix oa::FnMatrix::gatherBwd(const Matrix & inIndices, const Matrix & inGradOutput, oa::I32 inVocabSize, oa::I32 inEmbedDim)
Matrix oa::FnMatrix::gatherLastDim(const Matrix & inSelf, const Matrix & inIndices)
Matrix oa::FnMatrix::gatherLastDimBwd(const Matrix & inGradOut, const Matrix & inIndices, oa::I32 inInputWidth)
oa::Matrix oa::FnMatrix::geglu(const oa::Matrix & inA, oa::U32 inIntermediateSize)
Matrix oa::FnMatrix::gegluBwd(const Matrix & inInput, const Matrix & inGradOutput)
oa::Matrix oa::FnMatrix::gelu(const oa::Matrix & inA)
Matrix oa::FnMatrix::geluBwd(const Matrix & inInput, const Matrix & inGradOutput)
Matrix oa::FnMatrix::greaterEqual(const Matrix & inA, oa::F32 inValue)
Matrix oa::FnMatrix::groupedGemmM(const Matrix & inX, const Matrix & inWeight, const Matrix & inOffsets)
GroupedGemmMBwdResult oa::FnMatrix::groupedGemmMBwd(const Matrix & inDOut, const Matrix & inX, const Matrix & inWeight, const Matrix & inOffsets)
Matrix oa::FnMatrix::groupedLinearM(const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, const Matrix & inOffsets)
Matrix oa::FnMatrix::groupedLinearMBiasBwd(const Matrix & inDOut, const Matrix & inOffsets, oa::I32 inNumExperts)
GroupedLinearMBwdResult oa::FnMatrix::groupedLinearMBwd(const Matrix & inDOut, const Matrix & inX, const Matrix & inWeight, const Matrix & inOffsets)
Matrix oa::FnMatrix::gruCellLinear(const Matrix & inGatesI, const Matrix & inHidden, const Matrix & inWeightHh, oa::I32 inHiddenSize, oa::U32 inTimeOffset, oa::U32 inBatchStride, const Matrix & inBiasHh = Matrix{})
Matrix oa::FnMatrix::gruCellPointwise(const Matrix & inGatesI, const Matrix & inGatesH, const Matrix & inHidden, oa::I32 inHiddenSize, oa::U32 inTimeOffset = 0, oa::U32 inBatchStride = 1)
GruCellPointwiseBwdResult oa::FnMatrix::gruCellPointwiseBwd(const Matrix & inGatesI, const Matrix & inGatesH, const Matrix & inHidden, const Matrix & inGradOutput, oa::I32 inHiddenSize, oa::U32 inTimeOffset = 0, oa::U32 inBatchStride = 1)
GruScanResult oa::FnMatrix::gruScan(const Matrix & inGatesI, const Matrix & inWeightHh, oa::I32 inHiddenSize, oa::I32 inSeqLen, oa::I32 inBatch, const Matrix & inBiasHh = Matrix{})
GruScanBwdResult oa::FnMatrix::gruScanBwd(const Matrix & inDOut, const Matrix & inGatesI, const Matrix & inHPrev, const Matrix & inWeightHh, oa::I32 inHiddenSize, oa::I32 inSeqLen, oa::I32 inBatch, const Matrix & inBiasHh = Matrix{})
Matrix oa::FnMatrix::heavyTailActivation(const Matrix & inSelf)
Matrix oa::FnMatrix::im2Col1d(const Matrix & inX, oa::I32 inK, oa::I32 inStride, oa::I32 inPadding, oa::I32 inDilation = 1)
oa::Matrix oa::FnMatrix::layerNorm(const oa::Matrix & inSelf, const oa::Matrix & inWeight, const oa::Matrix & inBias, oa::F32 inEps)
LayerNormBwdResult oa::FnMatrix::layerNormBwd(const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, const Matrix & inOut, const Matrix & inMean, const Matrix & inRstd, const Matrix & inGradOutput, oa::F32 inEps = 1e-5F)
oa::Matrix oa::FnMatrix::leakyRelu(const oa::Matrix & inA, oa::F32 inAlpha)
Matrix oa::FnMatrix::leakyReluBwd(const Matrix & inForwardOutput, const Matrix & inGradOutput, oa::F32 inAlpha = 0.01f)
Matrix oa::FnMatrix::linear(const Matrix & inX, const Matrix & inWeight, const Matrix & inBias = Matrix{})
Matrix oa::FnMatrix::linearDataBwd(const Matrix & inGradOutput, const Matrix & inWeight)
Matrix oa::FnMatrix::linearDataReluBwd(const Matrix & inGradOutput, const Matrix & inWeight, const Matrix & inActivation)
Matrix oa::FnMatrix::linearGelu(const Matrix & inX, const Matrix & inWeight, const Matrix & inBias)
Matrix oa::FnMatrix::linearRelu(const Matrix & inX, const Matrix & inWeight, const Matrix & inBias)
Matrix oa::FnMatrix::linearReluBwdData(const Matrix & inGradOutput, const Matrix & inWeight, const Matrix & inActivation)
Matrix oa::FnMatrix::linearSilu(const Matrix & inX, const Matrix & inWeight, const Matrix & inBias)
LinearWeightBiasBwdResult oa::FnMatrix::linearWeightBiasBwd(const Matrix & inInput, const Matrix & inGradOutput)
Matrix oa::FnMatrix::linearWeightBwd(const Matrix & inInput, const Matrix & inGradOutput)
oa::Matrix oa::FnMatrix::log(const oa::Matrix & inA)
oa::Matrix oa::FnMatrix::logSoftmax(const oa::Matrix & inA, oa::I32 inDim = -1)
Matrix oa::FnMatrix::logSoftmaxBwd(const Matrix & inForwardOutput, const Matrix & inGradOutput, oa::I32 inDim = -1)
Matrix oa::FnMatrix::mamba3Mimo(const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const Matrix & inMimoX, const Matrix & inMimoZ, const Matrix & inMimoO, const Matrix & inNormWeight, const SsmConfig & inConfig)
Mamba3MimoBwdResult oa::FnMatrix::mamba3MimoBwd(const Matrix & inDOut, const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const Matrix & inMimoX, const Matrix & inMimoZ, const Matrix & inMimoO, const Matrix & inNormWeight, const SsmConfig & inConfig)
Matrix oa::FnMatrix::mamba3MimoStep(const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const Matrix & inMimoX, const Matrix & inMimoZ, const Matrix & inMimoO, const Matrix & inNormWeight, const Matrix & inSsmState, const Matrix & inAngleState, const Matrix & inKState, const Matrix & inVState, const SsmConfig & inConfig)
Mamba3PreprocessResult oa::FnMatrix::mamba3Preprocess(const Matrix & inProjected, const Matrix & inDtBias, const Mamba3PreprocessConfig & inConfig)
Mamba3PreprocessBwdResult oa::FnMatrix::mamba3PreprocessBwd(const Matrix & inProjected, const Matrix & inDtBias, const Matrix & inDZ, const Matrix & inDX, const Matrix & inDBh, const Matrix & inDCh, const Matrix & inDDT, const Matrix & inDADT, const Matrix & inDTrap, const Matrix & inDAngle, const Mamba3PreprocessConfig & inConfig)
Matrix oa::FnMatrix::mamba3Siso(const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const SsmConfig & inConfig)
SsmBwdResult oa::FnMatrix::mamba3SisoBwd(const Matrix & inDOut, const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const SsmConfig & inConfig)
Matrix oa::FnMatrix::mamba3SisoStep(const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const Matrix & inSsmState, const Matrix & inAngleState, const Matrix & inKState, const Matrix & inVState, const SsmConfig & inConfig)
Matrix oa::FnMatrix::maskedCategoricalAccuracyCount(const Matrix & inLogits, const Matrix & inLabels, const Matrix & inMask)
oa::Matrix oa::FnMatrix::matMulNt(const oa::Matrix & inA, const oa::Matrix & inB, oa::MatMulPrecision inPrecision = oa::MatMulPrecision::Auto)
oa::Matrix oa::FnMatrix::max(const oa::Matrix & inA, oa::I32 inDim = -1)
Matrix oa::FnMatrix::maxBwd(const Matrix & inInput, const Matrix & inMaxValue, const Matrix & inGradOutput)
MaxPool2dResult oa::FnMatrix::maxPool2d(const Matrix & inX, oa::I32 inKernelSize, oa::I32 inStride, oa::I32 inPadding)
Matrix oa::FnMatrix::maxPool2dBwd(const Matrix & inX, const Matrix & inIndices, const Matrix & inGradOutput, oa::I32 inKernelSize, oa::I32 inStride, oa::I32 inPadding)
oa::Matrix oa::FnMatrix::mean(const oa::Matrix & inA, oa::I32 inDim = -1)
Matrix oa::FnMatrix::mergeHeads(const Matrix & inX, oa::I32 inBatch, oa::I32 inSeqLen, oa::I32 inNumHeads)
oa::Matrix oa::FnMatrix::mish(const oa::Matrix & inA)
Matrix oa::FnMatrix::mishBwd(const Matrix & inInput, const Matrix & inGradOutput)
Matrix oa::FnMatrix::moeCombine(const Matrix & inPacked, const Matrix & inRouteGate, const Matrix & inInverse, const Matrix & inPackedSlot)
MoeCombineBwdResult oa::FnMatrix::moeCombineBwd(const Matrix & inDOut, const Matrix & inPacked, const Matrix & inRouteGate, const Matrix & inInverse, const Matrix & inPackedSlot)
MoeExpertPlan oa::FnMatrix::moeExpertPlan(const Matrix & inExpertIndices, oa::I32 inNumExperts)
Matrix oa::FnMatrix::moeGather(const Matrix & inSelf, const Matrix & inIndices, const Matrix & inInverse)
Matrix oa::FnMatrix::moeGatherBwd(const Matrix & inSource, const Matrix & inInverse, oa::I32 inOutRows)
Matrix oa::FnMatrix::moeRouteWeights(const Matrix & inProbs, const Matrix & inExpertIndices)
Matrix oa::FnMatrix::moeRouteWeightsBwd(const Matrix & inDOut, const Matrix & inProbs, const Matrix & inExpertIndices, const Matrix & inRouteWeights)
void oa::FnMatrix::moeRoutingBiasUpdate(const Matrix & inSelectionMask, Matrix & inOutBias, oa::I32 inExpertsPerToken, oa::F32 inGamma)
oa::Matrix oa::FnMatrix::mul(const oa::Matrix & inA, const oa::Matrix & inB)
void oa::FnMatrix::mulInPlace(Matrix & inSelf, const Matrix & inOther)
oa::Matrix oa::FnMatrix::neg(const oa::Matrix & inA)
Matrix oa::FnMatrix::ones(MatrixShape inShape, oa::ScalarType inDtype = weightDtype())
oa::Matrix oa::FnMatrix::philoxNormal(const oa::Matrix & inA, oa::F32 inMean = 0.0F, oa::F32 inStddev = 1.0F, oa::U64 inSeed = 0)
oa::Matrix oa::FnMatrix::philoxUniform(const oa::Matrix & inA, oa::F32 inLow = 0.0F, oa::F32 inHigh = 1.0F, oa::U64 inSeed = 0)
oa::Matrix oa::FnMatrix::pow(const oa::Matrix & inA, oa::F32 inExponent)
oa::QuantMatrix oa::FnMatrix::quantize(const oa::Matrix & inInput, oa::Quantization inQuantization)
Matrix oa::FnMatrix::rand(MatrixShape inShape, oa::ScalarType inDtype = weightDtype())
Matrix oa::FnMatrix::randGlorotUniform(MatrixShape inShape, oa::ScalarType inDtype = weightDtype())
Matrix oa::FnMatrix::randKaimingUniform(MatrixShape inShape, oa::ScalarType inDtype = weightDtype())
Matrix oa::FnMatrix::randN(MatrixShape inShape, oa::ScalarType inDtype = weightDtype())
Matrix oa::FnMatrix::randXavier(MatrixShape inShape, oa::ScalarType inDtype = weightDtype())
oa::Matrix oa::FnMatrix::reciprocal(const oa::Matrix & inA)
oa::Matrix oa::FnMatrix::relu(const oa::Matrix & inA)
Matrix oa::FnMatrix::reluBwd(const Matrix & inForwardOutput, const Matrix & inGradOutput)
Matrix oa::FnMatrix::repeatInterleave(const Matrix & inA, oa::I32 inRepeats, oa::I32 inDim)
Matrix oa::FnMatrix::repeatInterleaveBwd(const Matrix & inGradOut, MatrixShape inInputShape, oa::I32 inRepeats, oa::I32 inDim)
oa::Matrix oa::FnMatrix::reshape(const oa::Matrix & inA, oa::MatrixShape inShape)
ResidualRmsNormResult oa::FnMatrix::residualRmsNorm(const Matrix & inA, const Matrix & inB, const Matrix & inWeight, oa::F32 inEps)
oa::Matrix oa::FnMatrix::rmsNorm(const oa::Matrix & inSelf, const oa::Matrix & inWeight, oa::F32 inEps)
RmsNormBwdResult oa::FnMatrix::rmsNormBwd(const Matrix & inX, const Matrix & inWeight, const Matrix & inGradOutput, oa::F32 inEps = 1e-5F)
Matrix oa::FnMatrix::rmsNormGated(const Matrix & inSelf, const Matrix & inWeight, const Matrix & inBias, const Matrix & inZ, oa::F32 inEps, bool inNormBeforeGate = true)
RmsNormGatedBwdResult oa::FnMatrix::rmsNormGatedBwd(const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, const Matrix & inZ, const Matrix & inGradOutput, oa::F32 inEps)
Matrix oa::FnMatrix::rnnCellLinear(const Matrix & inGatesI, const Matrix & inHidden, const Matrix & inWeightHh, oa::U32 inTimeOffset = 0, oa::U32 inBatchStride = 1, const Matrix & inBiasHh = Matrix{})
Matrix oa::FnMatrix::rnnCellPointwise(const Matrix & inGatesI, const Matrix & inGatesH)
RnnCellPointwiseBwdResult oa::FnMatrix::rnnCellPointwiseBwd(const Matrix & inGatesI, const Matrix & inGatesH, const Matrix & inGradOutput, oa::I32 inHiddenSize, oa::U32 inTimeOffset = 0, oa::U32 inBatchStride = 1)
RnnScanResult oa::FnMatrix::rnnScan(const Matrix & inGatesI, const Matrix & inWeightHh, oa::I32 inHiddenSize, oa::I32 inSeqLen, oa::I32 inBatch, const Matrix & inBiasHh = Matrix{})
RnnScanBwdResult oa::FnMatrix::rnnScanBwd(const Matrix & inDOut, const Matrix & inGatesI, const Matrix & inHPrev, const Matrix & inWeightHh, oa::I32 inHiddenSize, oa::I32 inSeqLen, oa::I32 inBatch, const Matrix & inBiasHh = Matrix{})
Matrix oa::FnMatrix::sampleLogits(const Matrix & inLogits, oa::F32 inTemperature = 1.0F, oa::I32 inTopK = 0, oa::F32 inTopP = 1.0F, oa::U64 inSeed = 0)
oa::F32 oa::FnMatrix::scalar(const Matrix & inSrc)
oa::Matrix oa::FnMatrix::scale(const oa::Matrix & inA, oa::F32 inScalar)
void oa::FnMatrix::scaleInPlace(Matrix & inSelf, oa::F32 inScalar)
Matrix oa::FnMatrix::scatterAddRows(const Matrix & inSource, const Matrix & inIndices, oa::I32 inOutRows)
Matrix oa::FnMatrix::scatterRows(const Matrix & inSelf, const Matrix & inSource, const Matrix & inRowMap, const Matrix & inCount)
Matrix oa::FnMatrix::scatterRowsBwdSource(const Matrix & inGradOut, const Matrix & inRowMap, const Matrix & inCount)
void oa::FnMatrix::setRngSeed(oa::U64 inSeed)
oa::Matrix oa::FnMatrix::sigmoid(const oa::Matrix & inA)
Matrix oa::FnMatrix::sigmoidBwd(const Matrix & inForwardOutput, const Matrix & inGradOutput)
oa::Matrix oa::FnMatrix::silu(const oa::Matrix & inA)
Matrix oa::FnMatrix::siluBwd(const Matrix & inInput, const Matrix & inGradOutput)
oa::Matrix oa::FnMatrix::siluMul(const oa::Matrix & inA, oa::U32 inIntermediateSize)
Matrix oa::FnMatrix::siluMulBwd(const Matrix & inInput, const Matrix & inGradOutput)
oa::Matrix oa::FnMatrix::sin(const oa::Matrix & inA)
oa::Matrix oa::FnMatrix::slice(const oa::Matrix & inSelf, oa::I32 inDim, oa::I64 inStart, oa::I64 inEnd)
Matrix oa::FnMatrix::sliceBwd(MatrixShape inInputShape, oa::I32 inDim, oa::I64 inStart, oa::I64 inEnd, const Matrix & inDOut)
oa::Matrix oa::FnMatrix::softmax(const oa::Matrix & inA, oa::I32 inDim = -1)
Matrix oa::FnMatrix::softmaxBwd(const Matrix & inForwardOutput, const Matrix & inGradOutput, oa::I32 inDim = -1)
Matrix oa::FnMatrix::softmaxScaledMasked(const Matrix & inScores, const Matrix & inMask, oa::F32 inScale)
Matrix oa::FnMatrix::softmaxScaledMaskedBwd(const Matrix & inForwardOutput, const Matrix & inGradOutput, oa::F32 inScale)
oa::Matrix oa::FnMatrix::softplus(const oa::Matrix & inA)
Matrix oa::FnMatrix::softplusBwd(const Matrix & inForwardOutput, const Matrix & inGradOutput)
oa::Vector<Matrix> oa::FnMatrix::split(const Matrix & inSelf, oa::Span<oa::I64> inSizes, oa::I32 inDim = 0)
Matrix oa::FnMatrix::splitHeads(const Matrix & inX, oa::I32 inBatch, oa::I32 inSeqLen, oa::I32 inNumHeads)
oa::Matrix oa::FnMatrix::sqrt(const oa::Matrix & inA)
oa::Matrix oa::FnMatrix::sub(const oa::Matrix & inA, const oa::Matrix & inB)
void oa::FnMatrix::subInPlace(Matrix & inSelf, const Matrix & inOther)
oa::Matrix oa::FnMatrix::subScalar(const oa::Matrix & inA, oa::F32 inScalar)
void oa::FnMatrix::subScalarInPlace(Matrix & inSelf, oa::F32 inScalar)
oa::Matrix oa::FnMatrix::sum(const oa::Matrix & inA, oa::I32 inDim = -1)
oa::Matrix oa::FnMatrix::swiglu(const oa::Matrix & inA, const oa::Matrix & inB)
SwigluBwdResult oa::FnMatrix::swigluBwd(const Matrix & inGate, const Matrix & inUp, const Matrix & inOut, const Matrix & inGradOutput)
oa::Matrix oa::FnMatrix::tanh(const oa::Matrix & inA)
Matrix oa::FnMatrix::tanhBwd(const Matrix & inForwardOutput, const Matrix & inGradOutput)
TopKResult oa::FnMatrix::topK(const Matrix & inA, oa::I32 inK, oa::I32 inDim = -1)
Matrix oa::FnMatrix::topKMask(const Matrix & inIndices, oa::I32 inNumExperts)
oa::Matrix oa::FnMatrix::transpose(const oa::Matrix & inA, oa::I32 inDim0 = -2, oa::I32 inDim1 = -1)
Matrix oa::FnMatrix::upsampleBwd(const Matrix & inInput, const Matrix & inDOut, oa::I32 inScaleFactor, bool inIsBilinear)
VqAssignResult oa::FnMatrix::vqAssign(const Matrix & inZe, const Matrix & inCodebook)
void oa::FnMatrix::vqEmaUpdate(const Matrix & inZe, const Matrix & inIdx, Matrix & ioEmbedSum, Matrix & ioClusterSize, Matrix & outCodebook, oa::F32 inDecay, oa::F32 inEps, oa::F32 inDeadThreshold, oa::U32 inSeed, bool inNormalize)
oa::ScalarType oa::FnMatrix::weightDtype()
Matrix oa::FnMatrix::zeros(MatrixShape inShape, oa::ScalarType inDtype = weightDtype())

Function Documentation

oa::Matrix oa::FnMatrix::abs( const oa::Matrix & inA )
abs: Element-wise absolute value: out = |A|.

Parameters

inA
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

oa::Matrix oa::FnMatrix::add( const oa::Matrix & inA, const oa::Matrix & inB )
add: Element-wise addition: out = A + B.

Parameters

inA
const oa::Matrix &

inB
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

void oa::FnMatrix::addInPlace( Matrix & inSelf, const Matrix & inOther )
in-place operations

Parameters

inSelf
Matrix &

inOther
const Matrix &

Returns

void

The declared return value.

oa::Matrix oa::FnMatrix::addScalar( const oa::Matrix & inA, oa::F32 inScalar )
addScalar: Scalar addition: out = A + Scalar.

Parameters

inA
const oa::Matrix &

inScalar
oa::F32

Returns

oa::Matrix

The declared return value.

void oa::FnMatrix::addScalarInPlace( Matrix & inSelf, oa::F32 inScalar )
No public source comment is attached to this declaration.

Parameters

inSelf
Matrix &

inScalar
oa::F32

Returns

void

The declared return value.

oa::I64 oa::FnMatrix::argmax( const oa::Matrix & inA, oa::I32 inDim = -1 )
argmax: Find index of maximum value: out = argmax(A).

Parameters

inA
const oa::Matrix &

inDim
oa::I32

Default: -1

Returns

oa::I64

The declared return value.

Matrix oa::FnMatrix::avgPool2d( const Matrix & inX, oa::I32 inKernelSize, oa::I32 inStride, oa::I32 inPadding )
--- Pooling ---

Parameters

inX
const Matrix &

inKernelSize
oa::I32

inStride
oa::I32

inPadding
oa::I32

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::avgPool2dBwd( const Matrix & inX, const Matrix & inGradOutput, oa::I32 inKernelSize, oa::I32 inStride, oa::I32 inPadding )
avgPool2dBwd: backward for 2D average pooling.

Parameters

inX
const Matrix &

inGradOutput
const Matrix &

inKernelSize
oa::I32

inStride
oa::I32

inPadding
oa::I32

Returns

Matrix

The declared return value.

BatchNorm2dBwdResult oa::FnMatrix::batchNorm2dBwd( const Matrix & inX, const Matrix & inGamma, const Matrix & inBeta, const Matrix & inMean, const Matrix & inVar, const Matrix & inOut, const Matrix & inDOut, oa::F32 inEps, bool inIsTraining )
batchNorm2dBwd: backward pass for BatchNorm2d.

Parameters

inX
const Matrix &

inGamma
const Matrix &

inBeta
const Matrix &

inMean
const Matrix &

inVar
const Matrix &

inOut
const Matrix &

inDOut
const Matrix &

inEps
oa::F32

inIsTraining
bool

Returns

BatchNorm2dBwdResult

The declared return value.

oa::Matrix oa::FnMatrix::biasAdd( const oa::Matrix & inA, const oa::Matrix & inB )
biasAdd: Add bias vector: out = A + Bias (broadcasted).

Parameters

inA
const oa::Matrix &

inB
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::bmm( const Matrix & inA, const Matrix & inB )
bmm: per-batch matrix multiply, A[N,M,K] @ B[N,K,P] = out[N,M,P].

Parameters

inA
const Matrix &

inB
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::bmmNt( const Matrix & inA, const Matrix & inB )
bmmNt: per-batch matrix multiply with transposed right operand storage, A[N,M,K] @ B[N,P,K]^T = out[N,M,P].

Parameters

inA
const Matrix &

inB
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::cast( const Matrix & inSrc, oa::ScalarType inDtype )
--- dtype cast --- cast: allocate a new matrix of inDtype and convert inSrc into it. castInto: convert inSrc into the pre-allocated outDst in place.

Parameters

inSrc
const Matrix &

inDtype
oa::ScalarType

Returns

Matrix

The declared return value.

void oa::FnMatrix::castInto( const Matrix & inSrc, Matrix & outDst )
No public source comment is attached to this declaration.

Parameters

inSrc
const Matrix &

outDst
Matrix &

Returns

void

The declared return value.

Matrix oa::FnMatrix::categoricalAccuracyCount( const Matrix & inLogits, const Matrix & inLabels )
No public source comment is attached to this declaration.

Parameters

inLogits
const Matrix &

inLabels
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::causalMask( oa::I64 inSeqLen ) Matrix oa::FnMatrix::causalMask( const Matrix & inScores )
No public source comment is attached to this declaration.

Parameters

inSeqLen
oa::I64

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::causalMaskBwd( const Matrix & inGradOut )
No public source comment is attached to this declaration.

Parameters

inGradOut
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::channelNorm( const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, oa::I32 inBatch, oa::I32 inChannels, oa::I32 inSeqLen, oa::F32 inEps )
channelNorm: fused LayerNorm over the channel axis of [B,C,T] without transposing. Replaces Transpose+LayerNorm+transpose (3 dispatches) with 1.

Parameters

inX
const Matrix &

inWeight
const Matrix &

inBias
const Matrix &

inBatch
oa::I32

inChannels
oa::I32

inSeqLen
oa::I32

inEps
oa::F32

Returns

Matrix

The declared return value.

ChannelNormBwdResult oa::FnMatrix::channelNormBwd( const Matrix & inX, const Matrix & inWeight, const Matrix & inGradOutput, oa::I32 inBatch, oa::I32 inChannels, oa::I32 inSeqLen, oa::F32 inEps )
No public source comment is attached to this declaration.

Parameters

inX
const Matrix &

inWeight
const Matrix &

inGradOutput
const Matrix &

inBatch
oa::I32

inChannels
oa::I32

inSeqLen
oa::I32

inEps
oa::F32

Returns

ChannelNormBwdResult

The declared return value.

Matrix oa::FnMatrix::channelNormRelu( const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, oa::I32 inBatch, oa::I32 inChannels, oa::I32 inSeqLen, oa::F32 inEps )
channelNormRelu: fused channelNorm + ReLU on [B,C,T].

Parameters

inX
const Matrix &

inWeight
const Matrix &

inBias
const Matrix &

inBatch
oa::I32

inChannels
oa::I32

inSeqLen
oa::I32

inEps
oa::F32

Returns

Matrix

The declared return value.

ChannelNormBwdResult oa::FnMatrix::channelNormReluBwd( const Matrix & inX, const Matrix & inWeight, const Matrix & inFwdOut, const Matrix & inGradOutput, oa::I32 inBatch, oa::I32 inChannels, oa::I32 inSeqLen, oa::F32 inEps )
No public source comment is attached to this declaration.

Parameters

inX
const Matrix &

inWeight
const Matrix &

inFwdOut
const Matrix &

inGradOutput
const Matrix &

inBatch
oa::I32

inChannels
oa::I32

inSeqLen
oa::I32

inEps
oa::F32

Returns

ChannelNormBwdResult

The declared return value.

oa::Matrix oa::FnMatrix::clampMax( const oa::Matrix & inA, oa::F32 inMax )
clampMax: Element-wise clamp max: out = min(A, Max).

Parameters

inA
const oa::Matrix &

inMax
oa::F32

Returns

oa::Matrix

The declared return value.

oa::Matrix oa::FnMatrix::clampMin( const oa::Matrix & inA, oa::F32 inMin )
clampMin: Element-wise clamp min: out = max(A, Min).

Parameters

inA
const oa::Matrix &

inMin
oa::F32

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::col2Im1d( const Matrix & inDCols, oa::I32 inN, oa::I32 inC, oa::I32 inL, oa::I32 inK, oa::I32 inStride, oa::I32 inPadding, oa::I32 inDilation, oa::I32 inOutL )
col2Im1d: backward of im2Col1d — fold a column-matrix gradient [N*outL, inC*K] back into input shape [N, inC, L], accumulating over overlapping windows.

Parameters

inDCols
const Matrix &

inN
oa::I32

inC
oa::I32

inL
oa::I32

inK
oa::I32

inStride
oa::I32

inPadding
oa::I32

inDilation
oa::I32

inOutL
oa::I32

Returns

Matrix

The declared return value.

CompactRowsResult oa::FnMatrix::compactRows( const Matrix & inSelf, const Matrix & inMask )
No public source comment is attached to this declaration.

Parameters

inSelf
const Matrix &

inMask
const Matrix &

Returns

CompactRowsResult

The declared return value.

Matrix oa::FnMatrix::compactRowsBwd( const Matrix & inGradOut, const Matrix & inRowMap, const Matrix & inCount, MatrixShape inInputShape ) Matrix oa::FnMatrix::compactRowsBwd( const Matrix & inGradOut, const Matrix & inRowMap, const Matrix & inCount, const Matrix & inDispatchArgs, MatrixShape inInputShape )
No public source comment is attached to this declaration.

Parameters

inGradOut
const Matrix &

inRowMap
const Matrix &

inCount
const Matrix &

inInputShape
MatrixShape

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::concat( oa::Span<Matrix> inInputs, oa::I32 inDim = 0 )
No public source comment is attached to this declaration.

Parameters

inInputs
oa::Span<Matrix>

inDim
oa::I32

Default: 0

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::conv1dBwdData( const Matrix & inDOut, const Matrix & inWeight, oa::U32 inStride, oa::U32 inPadding, oa::U32 inDilation, const MatrixShape & inInputShape )
conv1dBwdData: backward for 1D convolution (input gradient).

Parameters

inDOut
const Matrix &

inWeight
const Matrix &

inStride
oa::U32

inPadding
oa::U32

inDilation
oa::U32

inInputShape
const MatrixShape &

Returns

Matrix

The declared return value.

Conv1dBwdWeightResult oa::FnMatrix::conv1dBwdWeight( const Matrix & inInput, const Matrix & inDOut, const Matrix & inWeight, oa::U32 inStride, oa::U32 inPadding, oa::U32 inDilation )
conv1dBwdWeight: fused weight and bias gradient for 1D convolution.

Parameters

inInput
const Matrix &

inDOut
const Matrix &

inWeight
const Matrix &

inStride
oa::U32

inPadding
oa::U32

inDilation
oa::U32

Returns

Conv1dBwdWeightResult

The declared return value.

Matrix oa::FnMatrix::conv1dGemm( const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, oa::I32 inStride = 1, oa::I32 inPadding = 0, oa::I32 inDilation = 1 )
conv1dGemm: 1-D convolution executed as im2col + a single matmul. inX [N, inC, L], inWeight [outC, inC, K], inBias [outC] -> [N, outC, outL]

Parameters

inX
const Matrix &

inWeight
const Matrix &

inBias
const Matrix &

inStride
oa::I32

Default: 1

inPadding
oa::I32

Default: 0

inDilation
oa::I32

Default: 1

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::conv1dReluGemm( const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, oa::I32 inStride = 1, oa::I32 inPadding = 0, oa::I32 inDilation = 1 )
conv1dReluGemm: conv1dGemm with the ReLU folded into the GEMM bias epilogue.

Parameters

inX
const Matrix &

inWeight
const Matrix &

inBias
const Matrix &

inStride
oa::I32

Default: 1

inPadding
oa::I32

Default: 0

inDilation
oa::I32

Default: 1

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::conv2d( const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, oa::U32 inStride, oa::U32 inPadding, oa::U32 inGroups = 1 )
--- Conv2d ---

Parameters

inX
const Matrix &

inWeight
const Matrix &

inBias
const Matrix &

inStride
oa::U32

inPadding
oa::U32

inGroups
oa::U32

Default: 1

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::conv2dBwdData( const Matrix & inDOut, const Matrix & inWeight, oa::U32 inStride, oa::U32 inPadding, const MatrixShape & inInputShape, oa::U32 inGroups = 1 )
conv2dBwdData: backward for 2D convolution (input gradient).

Parameters

inDOut
const Matrix &

inWeight
const Matrix &

inStride
oa::U32

inPadding
oa::U32

inInputShape
const MatrixShape &

inGroups
oa::U32

Default: 1

Returns

Matrix

The declared return value.

Conv2dBwdWeightResult oa::FnMatrix::conv2dBwdWeight( const Matrix & inInput, const Matrix & inDOut, const Matrix & inWeight, oa::U32 inStride, oa::U32 inPadding, oa::U32 inGroups = 1 )
conv2dBwdWeight: fused weight and bias gradient for 2D convolution.

Parameters

inInput
const Matrix &

inDOut
const Matrix &

inWeight
const Matrix &

inStride
oa::U32

inPadding
oa::U32

inGroups
oa::U32

Default: 1

Returns

Conv2dBwdWeightResult

The declared return value.

Matrix oa::FnMatrix::convTranspose2d( const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, oa::U32 inStride, oa::U32 inPadding )
convTranspose2d: 2D transposed convolution (learnable upsampling). input: [N, inC, H, W], weight: [inC, outC, K, K], Bias: [outC] output: [N, outC, H_out, W_out] where H_out = (H - 1) * S - 2P + K.

Parameters

inX
const Matrix &

inWeight
const Matrix &

inBias
const Matrix &

inStride
oa::U32

inPadding
oa::U32

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::convTranspose2dBwdData( const Matrix & inDOut, const Matrix & inWeight, oa::U32 inStride, oa::U32 inPadding, const MatrixShape & inInputShape )
convTranspose2dBwdData: backward for 2D transposed convolution (input gradient).

Parameters

inDOut
const Matrix &

inWeight
const Matrix &

inStride
oa::U32

inPadding
oa::U32

inInputShape
const MatrixShape &

Returns

Matrix

The declared return value.

ConvTranspose2dBwdWeightResult oa::FnMatrix::convTranspose2dBwdWeight( const Matrix & inInput, const Matrix & inDOut, const Matrix & inWeight, oa::U32 inStride, oa::U32 inPadding )
convTranspose2dBwdWeight: fused weight and bias gradient for 2D transposed convolution.

Parameters

inInput
const Matrix &

inDOut
const Matrix &

inWeight
const Matrix &

inStride
oa::U32

inPadding
oa::U32

Returns

ConvTranspose2dBwdWeightResult

The declared return value.

oa::Matrix oa::FnMatrix::copy( const oa::Matrix & inA )
copy: Copy tensor data: out = A.

Parameters

inA
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

oa::Status oa::FnMatrix::copyToHost( const Matrix & inSrc, void * outHost, oa::U64 inBytes )
--- Transfer --- Copy device matrix data to host memory. inBytes must be >= inSrc.byteSize().

Parameters

inSrc
const Matrix &

outHost
void *

inBytes
oa::U64

Returns

oa::Status

The declared return value.

oa::Matrix oa::FnMatrix::cos( const oa::Matrix & inA )
cos: Element-wise cosine: out = cos(A).

Parameters

inA
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

oa::Matrix oa::FnMatrix::dequantize( const oa::QuantMatrix & inInput )
Materialize a Float32 matrix with the logical shape retained by inInput.

Parameters

inInput
const oa::QuantMatrix &

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::detach( const Matrix & inSelf )
detach: stop-gradient. Returns a view that SHARES inSelf's device buffer but carries no autograd linkage (leaf, requiresGrad=false), so backward terminates here. Metadata-only: no kernel, no copy. This is the primitive the straight- through estimator needs.

Parameters

inSelf
const Matrix &

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::div( const oa::Matrix & inA, const oa::Matrix & inB )
div: Element-wise division: out = A / B.

Parameters

inA
const oa::Matrix &

inB
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

void oa::FnMatrix::divInPlace( Matrix & inSelf, const Matrix & inOther )
No public source comment is attached to this declaration.

Parameters

inSelf
Matrix &

inOther
const Matrix &

Returns

void

The declared return value.

oa::Matrix oa::FnMatrix::divScalar( const oa::Matrix & inA, oa::F32 inScalar )
divScalar: Scalar division: out = A / Scalar.

Parameters

inA
const oa::Matrix &

inScalar
oa::F32

Returns

oa::Matrix

The declared return value.

void oa::FnMatrix::divScalarInPlace( Matrix & inSelf, oa::F32 inScalar )
No public source comment is attached to this declaration.

Parameters

inSelf
Matrix &

inScalar
oa::F32

Returns

void

The declared return value.

Matrix oa::FnMatrix::dropout( const Matrix & inA, oa::F32 inP, oa::U64 inSeed = 0 )
Inverted dropout. inP must be [0,1).

Parameters

inA
const Matrix &

inP
oa::F32

inSeed
oa::U64

Default: 0

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::elu( const oa::Matrix & inA, oa::F32 inAlpha )
elu: ELU activation: out = A if A > 0 else Alpha * (exp(A) - 1).

Parameters

inA
const oa::Matrix &

inAlpha
oa::F32

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::eluBwd( const Matrix & inForwardOutput, const Matrix & inGradOutput, oa::F32 inAlpha = 1.0f )
eluBwd: backward pass for ELU activation. Computes: dInput = dOutput * (x > 0 ? 1 : alpha * exp(x))

Parameters

inForwardOutput
const Matrix &

inGradOutput
const Matrix &

inAlpha
oa::F32

Default: 1.0f

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::empty( MatrixShape inShape, oa::ScalarType inDtype = weightDtype(), oa::MemoryPlacement inPlacement = oa::MemoryPlacement::Auto )
--- Factory functions ---

Parameters

inShape
MatrixShape

inDtype
oa::ScalarType

Default: weightDtype()

inPlacement
oa::MemoryPlacement

Default: oa::MemoryPlacement::Auto

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::empyrealmAdt( const Matrix & inDdA, const Matrix & inDt, oa::F32 inAFloor )
--- empyrealm operations ---

Parameters

inDdA
const Matrix &

inDt
const Matrix &

inAFloor
oa::F32

Returns

Matrix

The declared return value.

EmpyrealmAdtBwdResult oa::FnMatrix::empyrealmAdtBwd( const Matrix & inDOut, const Matrix & inDdA, const Matrix & inDt, oa::F32 inAFloor )
No public source comment is attached to this declaration.

Parameters

inDOut
const Matrix &

inDdA
const Matrix &

inDt
const Matrix &

inAFloor
oa::F32

Returns

EmpyrealmAdtBwdResult

The declared return value.

Matrix oa::FnMatrix::empyrealmDt( const Matrix & inX, oa::F32 inDtMin, oa::F32 inDtMax )
No public source comment is attached to this declaration.

Parameters

inX
const Matrix &

inDtMin
oa::F32

inDtMax
oa::F32

Returns

Matrix

The declared return value.

EmpyrealmDtAdtResult oa::FnMatrix::empyrealmDtAdt( const Matrix & inDtRaw, const Matrix & inDdA, oa::F32 inDtMin, oa::F32 inDtMax, oa::F32 inAFloor )
No public source comment is attached to this declaration.

Parameters

inDtRaw
const Matrix &

inDdA
const Matrix &

inDtMin
oa::F32

inDtMax
oa::F32

inAFloor
oa::F32

Returns

EmpyrealmDtAdtResult

The declared return value.

Matrix oa::FnMatrix::empyrealmDtBwd( const Matrix & inDOut, const Matrix & inX, oa::F32 inDtMin, oa::F32 inDtMax )
No public source comment is attached to this declaration.

Parameters

inDOut
const Matrix &

inX
const Matrix &

inDtMin
oa::F32

inDtMax
oa::F32

Returns

Matrix

The declared return value.

Mamba3PreprocessResult oa::FnMatrix::empyrealmPreprocess( const Matrix & inProjected, const Matrix & inDtBias, const Mamba3PreprocessConfig & inConfig )
No public source comment is attached to this declaration.

Parameters

inProjected
const Matrix &

inDtBias
const Matrix &

inConfig
const Mamba3PreprocessConfig &

Returns

Mamba3PreprocessResult

The declared return value.

Mamba3PreprocessBwdResult oa::FnMatrix::empyrealmPreprocessBwd( const Matrix & inProjected, const Matrix & inDtBias, const Matrix & inDZ, const Matrix & inDX, const Matrix & inDBh, const Matrix & inDCh, const Matrix & inDDT, const Matrix & inDADT, const Matrix & inDTrap, const Matrix & inDAngle, const Mamba3PreprocessConfig & inConfig )
No public source comment is attached to this declaration.

Parameters

inProjected
const Matrix &

inDtBias
const Matrix &

inDZ
const Matrix &

inDX
const Matrix &

inDBh
const Matrix &

inDCh
const Matrix &

inDDT
const Matrix &

inDADT
const Matrix &

inDTrap
const Matrix &

inDAngle
const Matrix &

inConfig
const Mamba3PreprocessConfig &

Returns

Mamba3PreprocessBwdResult

The declared return value.

Matrix oa::FnMatrix::empyrealmSiso( const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const SsmConfig & inConfig )
No public source comment is attached to this declaration.

Parameters

inC
const Matrix &

inB
const Matrix &

inX
const Matrix &

inZ
const Matrix &

inAdt
const Matrix &

inDt
const Matrix &

inTrap
const Matrix &

inAngle
const Matrix &

inCBias
const Matrix &

inBBias
const Matrix &

inD
const Matrix &

inConfig
const SsmConfig &

Returns

Matrix

The declared return value.

SsmBwdResult oa::FnMatrix::empyrealmSisoBwd( const Matrix & inDOut, const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const SsmConfig & inConfig )
No public source comment is attached to this declaration.

Parameters

inDOut
const Matrix &

inC
const Matrix &

inB
const Matrix &

inX
const Matrix &

inZ
const Matrix &

inAdt
const Matrix &

inDt
const Matrix &

inTrap
const Matrix &

inAngle
const Matrix &

inCBias
const Matrix &

inBBias
const Matrix &

inD
const Matrix &

inConfig
const SsmConfig &

Returns

SsmBwdResult

The declared return value.

Matrix oa::FnMatrix::empyrealmSisoStep( const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const Matrix & inSsmState, const Matrix & inAngleState, const Matrix & inKState, const Matrix & inVState, const SsmConfig & inConfig )
No public source comment is attached to this declaration.

Parameters

inC
const Matrix &

inB
const Matrix &

inX
const Matrix &

inZ
const Matrix &

inAdt
const Matrix &

inDt
const Matrix &

inTrap
const Matrix &

inAngle
const Matrix &

inCBias
const Matrix &

inBBias
const Matrix &

inD
const Matrix &

inSsmState
const Matrix &

inAngleState
const Matrix &

inKState
const Matrix &

inVState
const Matrix &

inConfig
const SsmConfig &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::equal( const Matrix & inA, oa::F32 inValue )
No public source comment is attached to this declaration.

Parameters

inA
const Matrix &

inValue
oa::F32

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::exp( const oa::Matrix & inA )
exp: Element-wise exponential: out = exp(A).

Parameters

inA
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

oa::Matrix oa::FnMatrix::fill( const oa::MatrixShape & inShape, oa::F32 inValue )
fill: Create a Float32 matrix filled with a constant value.

Parameters

inShape
const oa::MatrixShape &

inValue
oa::F32

Returns

oa::Matrix

The declared return value.

void oa::FnMatrix::fillInPlace( oa::Matrix & inSelf, oa::F32 inValue )
fillInPlace: Replace every value in an existing matrix.

Parameters

inSelf
oa::Matrix &

inValue
oa::F32

Returns

void

The declared return value.

Matrix oa::FnMatrix::flashAttentionCausal( const Matrix & inQ, const Matrix & inK, const Matrix & inV, oa::F32 inScale )
flashAttentionCausal: IO-aware causal scaled dot-product attention. Q/K/V and output use contiguous [batchHeads, sequence, headDim] storage.

Parameters

inQ
const Matrix &

inK
const Matrix &

inV
const Matrix &

inScale
oa::F32

Returns

Matrix

The declared return value.

FlashAttentionBwdResult oa::FnMatrix::flashAttentionCausalBwd( const Matrix & inQ, const Matrix & inK, const Matrix & inV, const Matrix & inOutput, const Matrix & inLogSumExp, const Matrix & inGradOutput, oa::F32 inScale )
flashAttentionCausalBwd: explicit adjoint for the FlashAttention autograd node.

Parameters

inQ
const Matrix &

inK
const Matrix &

inV
const Matrix &

inOutput
const Matrix &

inLogSumExp
const Matrix &

inGradOutput
const Matrix &

inScale
oa::F32

Returns

FlashAttentionBwdResult

The declared return value.

Matrix oa::FnMatrix::fromBytes( oa::Span<const oa::U8> inData, MatrixShape inShape, oa::ScalarType inDtype = weightDtype() )
No public source comment is attached to this declaration.

Parameters

inData
oa::Span<const oa::U8>

inShape
MatrixShape

inDtype
oa::ScalarType

Default: weightDtype()

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::fromInt32( oa::Span<const oa::I32> inData, MatrixShape inShape, oa::ScalarType inDtype = oa::ScalarType::Int32 )
No public source comment is attached to this declaration.

Parameters

inData
oa::Span<const oa::I32>

inShape
MatrixShape

inDtype
oa::ScalarType

Default: oa::ScalarType::Int32

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::full( MatrixShape inShape, oa::F64 inValue, oa::ScalarType inDtype = weightDtype() )
No public source comment is attached to this declaration.

Parameters

inShape
MatrixShape

inValue
oa::F64

inDtype
oa::ScalarType

Default: weightDtype()

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::gather( const Matrix & inSelf, const Matrix & inIndices )
Indexing

Parameters

inSelf
const Matrix &

inIndices
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::gatherBwd( const Matrix & inIndices, const Matrix & inGradOutput, oa::I32 inVocabSize, oa::I32 inEmbedDim )
No public source comment is attached to this declaration.

Parameters

inIndices
const Matrix &

inGradOutput
const Matrix &

inVocabSize
oa::I32

inEmbedDim
oa::I32

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::gatherLastDim( const Matrix & inSelf, const Matrix & inIndices )
No public source comment is attached to this declaration.

Parameters

inSelf
const Matrix &

inIndices
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::gatherLastDimBwd( const Matrix & inGradOut, const Matrix & inIndices, oa::I32 inInputWidth )
No public source comment is attached to this declaration.

Parameters

inGradOut
const Matrix &

inIndices
const Matrix &

inInputWidth
oa::I32

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::geglu( const oa::Matrix & inA, oa::U32 inIntermediateSize )
geglu: GEGLU activation: out = A[:N] * GELU(A[N:]).

Parameters

inA
const oa::Matrix &

inIntermediateSize
oa::U32

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::gegluBwd( const Matrix & inInput, const Matrix & inGradOutput )
gegluBwd: backward pass for GEGLU activation.

Parameters

inInput
const Matrix &

forward INPUT (up||gate); up*GELU(gate) is not invertible

inGradOutput
const Matrix &

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::gelu( const oa::Matrix & inA )
gelu: GELU activation: out = GELU(A).

Parameters

inA
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::geluBwd( const Matrix & inInput, const Matrix & inGradOutput )
geluBwd: backward pass for GELU activation. Computes: dInput = dOutput * gelu'(x)

Parameters

inInput
const Matrix &

forward INPUT x (gelu'(x) is a function of input, not output)

inGradOutput
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::greaterEqual( const Matrix & inA, oa::F32 inValue )
No public source comment is attached to this declaration.

Parameters

inA
const Matrix &

inValue
oa::F32

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::groupedGemmM( const Matrix & inX, const Matrix & inWeight, const Matrix & inOffsets )
No public source comment is attached to this declaration.

Parameters

inX
const Matrix &

inWeight
const Matrix &

inOffsets
const Matrix &

Returns

Matrix

The declared return value.

GroupedGemmMBwdResult oa::FnMatrix::groupedGemmMBwd( const Matrix & inDOut, const Matrix & inX, const Matrix & inWeight, const Matrix & inOffsets )
No public source comment is attached to this declaration.

Parameters

inDOut
const Matrix &

inX
const Matrix &

inWeight
const Matrix &

inOffsets
const Matrix &

Returns

GroupedGemmMBwdResult

The declared return value.

Matrix oa::FnMatrix::groupedLinearM( const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, const Matrix & inOffsets )
No public source comment is attached to this declaration.

Parameters

inX
const Matrix &

inWeight
const Matrix &

inBias
const Matrix &

inOffsets
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::groupedLinearMBiasBwd( const Matrix & inDOut, const Matrix & inOffsets, oa::I32 inNumExperts )
No public source comment is attached to this declaration.

Parameters

inDOut
const Matrix &

inOffsets
const Matrix &

inNumExperts
oa::I32

Returns

Matrix

The declared return value.

GroupedLinearMBwdResult oa::FnMatrix::groupedLinearMBwd( const Matrix & inDOut, const Matrix & inX, const Matrix & inWeight, const Matrix & inOffsets )
No public source comment is attached to this declaration.

Parameters

inDOut
const Matrix &

inX
const Matrix &

inWeight
const Matrix &

inOffsets
const Matrix &

Returns

GroupedLinearMBwdResult

The declared return value.

Matrix oa::FnMatrix::gruCellLinear( const Matrix & inGatesI, const Matrix & inHidden, const Matrix & inWeightHh, oa::I32 inHiddenSize, oa::U32 inTimeOffset, oa::U32 inBatchStride, const Matrix & inBiasHh = Matrix{} )
gruCellLinear: fused GRU recurrent step — Linear(h, W_hh) + gruCellPointwise. Replaces the per-timestep pair of dispatches with one kernel. The hidden projection required by reverse mode is retained internally rather than exposed as an output parameter.

Parameters

inGatesI
const Matrix &

inHidden
const Matrix &

inWeightHh
const Matrix &

inHiddenSize
oa::I32

inTimeOffset
oa::U32

inBatchStride
oa::U32

inBiasHh
const Matrix &

Default: Matrix{}

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::gruCellPointwise( const Matrix & inGatesI, const Matrix & inGatesH, const Matrix & inHidden, oa::I32 inHiddenSize, oa::U32 inTimeOffset = 0, oa::U32 inBatchStride = 1 )
gruCellPointwise: fused GRU pointwise forward. r = sigmoid(gatesI[r] + gatesH[r]) z = sigmoid(gatesI[z] + gatesH[z]) n = tanh(gatesI[n] + r * gatesH[n]) h_new = (1 - z) * n + z * hPrev

Parameters

inGatesI
const Matrix &

[B, 3H] input projection (reset|update|candidate along dim 1) or [B*T, 3H] with inTimeOffset = t*B to index row t without Slice

inGatesH
const Matrix &

[B, 3H] hidden projection

inHidden
const Matrix &

[B, H] previous hidden state

inHiddenSize
oa::I32

H

inTimeOffset
oa::U32

row offset into inGatesI (in units of 3H), default 0

inBatchStride
oa::U32

Default: 1

Returns

Matrix

The declared return value.

GruCellPointwiseBwdResult oa::FnMatrix::gruCellPointwiseBwd( const Matrix & inGatesI, const Matrix & inGatesH, const Matrix & inHidden, const Matrix & inGradOutput, oa::I32 inHiddenSize, oa::U32 inTimeOffset = 0, oa::U32 inBatchStride = 1 )
gruCellPointwiseBwd: fused GRU pointwise backward. Returns gradients w.r.t. gatesI, gatesH and the previous hidden state.

Parameters

inGatesI
const Matrix &

inGatesH
const Matrix &

inHidden
const Matrix &

inGradOutput
const Matrix &

inHiddenSize
oa::I32

inTimeOffset
oa::U32

row offset into inGatesI / dGatesI (in rows of 3H), default 0

inBatchStride
oa::U32

row stride between batches in inGatesI (T for batch-major, 1 for contiguous), default 1

Returns

GruCellPointwiseBwdResult

The declared return value.

GruScanResult oa::FnMatrix::gruScan( const Matrix & inGatesI, const Matrix & inWeightHh, oa::I32 inHiddenSize, oa::I32 inSeqLen, oa::I32 inBatch, const Matrix & inBiasHh = Matrix{} )
gruScan: whole-sequence GRU recurrent scan in ONE dispatch (one workgroup per batch, looping all timesteps). Mathematically identical to running gruCellLinear for each timestep, but collapses S dispatches into 1. The recurrent weight/bias gradient is computed separately via linearWeightBiasBwd on the saved hPrev.

Parameters

inGatesI
const Matrix &

[B*S, 3H] precomputed input projection (row b*S+t = timestep t)

inWeightHh
const Matrix &

inHiddenSize
oa::I32

inSeqLen
oa::I32

S

inBatch
oa::I32

inBiasHh
const Matrix &

Default: Matrix{}

Returns

GruScanResult

The declared return value.

GruScanBwdResult oa::FnMatrix::gruScanBwd( const Matrix & inDOut, const Matrix & inGatesI, const Matrix & inHPrev, const Matrix & inWeightHh, oa::I32 inHiddenSize, oa::I32 inSeqLen, oa::I32 inBatch, const Matrix & inBiasHh = Matrix{} )
gruScanBwd: BPTT recurrence scan (backward of gruScan) in ONE dispatch. Produces gradients w.r.t. the input projection gatesI and the hidden projection gatesH (the latter drives the separate linearWeightBiasBwd weight-grad call).

Parameters

inDOut
const Matrix &

inGatesI
const Matrix &

inHPrev
const Matrix &

inWeightHh
const Matrix &

inHiddenSize
oa::I32

inSeqLen
oa::I32

inBatch
oa::I32

inBiasHh
const Matrix &

Default: Matrix{}

Returns

GruScanBwdResult

The declared return value.

Matrix oa::FnMatrix::heavyTailActivation( const Matrix & inSelf )
No public source comment is attached to this declaration.

Parameters

inSelf
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::im2Col1d( const Matrix & inX, oa::I32 inK, oa::I32 inStride, oa::I32 inPadding, oa::I32 inDilation = 1 )
im2Col1d: unfold a 1-D conv input [N, inC, L] into the GEMM-ready column matrix [N*outL, inC*K]. The building block of conv1dGemm.

Parameters

inX
const Matrix &

inK
oa::I32

inStride
oa::I32

inPadding
oa::I32

inDilation
oa::I32

Default: 1

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::layerNorm( const oa::Matrix & inSelf, const oa::Matrix & inWeight, const oa::Matrix & inBias, oa::F32 inEps )
layerNorm: Affine layer normalization over the last dimension: out = ((A - mean(A)) / sqrt(var(A) + Eps)) * Weight + Bias.

Parameters

inSelf
const oa::Matrix &

inWeight
const oa::Matrix &

inBias
const oa::Matrix &

inEps
oa::F32

Returns

oa::Matrix

The declared return value.

LayerNormBwdResult oa::FnMatrix::layerNormBwd( const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, const Matrix & inOut, const Matrix & inMean, const Matrix & inRstd, const Matrix & inGradOutput, oa::F32 inEps = 1e-5F )
layerNormBwd: backward pass for LayerNorm.

Parameters

inX
const Matrix &

inWeight
const Matrix &

inBias
const Matrix &

inOut
const Matrix &

inMean
const Matrix &

inRstd
const Matrix &

inGradOutput
const Matrix &

inEps
oa::F32

Default: 1e-5F

Returns

LayerNormBwdResult

The declared return value.

oa::Matrix oa::FnMatrix::leakyRelu( const oa::Matrix & inA, oa::F32 inAlpha )
leakyRelu: Leaky ReLU activation: out = max(Alpha * A, A).

Parameters

inA
const oa::Matrix &

inAlpha
oa::F32

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::leakyReluBwd( const Matrix & inForwardOutput, const Matrix & inGradOutput, oa::F32 inAlpha = 0.01f )
leakyReluBwd: backward pass for LeakyReLU activation. Computes: dInput = dOutput * (x > 0 ? 1 : alpha)

Parameters

inForwardOutput
const Matrix &

inGradOutput
const Matrix &

inAlpha
oa::F32

Default: 0.01f

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::linear( const Matrix & inX, const Matrix & inWeight, const Matrix & inBias = Matrix{} )
linear: linear layer (fully connected). output = input @ weight^T + bias

Parameters

inX
const Matrix &

[batch, inFeatures]

inWeight
const Matrix &

[outFeatures, inFeatures]

inBias
const Matrix &

[outFeatures] (optional)

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::linearDataBwd( const Matrix & inGradOutput, const Matrix & inWeight )
linearDataBwd: backward for linear layer (input gradient). Computes: dInput = dOutput @ weight^T

Parameters

inGradOutput
const Matrix &

inWeight
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::linearDataReluBwd( const Matrix & inGradOutput, const Matrix & inWeight, const Matrix & inActivation )
linearDataReluBwd: fused linear data gradient followed by ReLU backward. Computes: dInput = (dOutput @ weight) * (activation > 0)

Parameters

inGradOutput
const Matrix &

inWeight
const Matrix &

inActivation
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::linearGelu( const Matrix & inX, const Matrix & inWeight, const Matrix & inBias )
linearGelu: fused linear + GELU. output = GELU(input @ weight^T + bias) The fused forward discards the pre-activation; the autograd node recomputes it (one GEMM) for geluBwd in the backward pass.

Parameters

inX
const Matrix &

inWeight
const Matrix &

inBias
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::linearRelu( const Matrix & inX, const Matrix & inWeight, const Matrix & inBias )
linearRelu: fused linear + ReLU. output = reLU(input @ weight^T + bias)

Parameters

inX
const Matrix &

inWeight
const Matrix &

inBias
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::linearReluBwdData( const Matrix & inGradOutput, const Matrix & inWeight, const Matrix & inActivation )
linearReluBwdData: fused in-layer linearRelu(x,W,b) backward, data path. For y = reLU(x @ W^T + b), computes dx = (dy * (act > 0)) @ W in a single dispatch. gate is applied INSIDE the inner sum (no materialization of dz), the opposite fusion direction of linearDataReluBwd.

Parameters

inGradOutput
const Matrix &

inWeight
const Matrix &

inActivation
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::linearSilu( const Matrix & inX, const Matrix & inWeight, const Matrix & inBias )
linearSilu: fused linear + SiLU. output = siLU(input @ weight^T + bias)

Parameters

inX
const Matrix &

inWeight
const Matrix &

inBias
const Matrix &

Returns

Matrix

The declared return value.

LinearWeightBiasBwdResult oa::FnMatrix::linearWeightBiasBwd( const Matrix & inInput, const Matrix & inGradOutput )
linearWeightBiasBwd: fused weight and bias gradient for linear layer. Computes: dWeight = input^T @ dOutput, dBias = sum(dOutput, dim=0)

Parameters

inInput
const Matrix &

inGradOutput
const Matrix &

Returns

LinearWeightBiasBwdResult

The declared return value.

Matrix oa::FnMatrix::linearWeightBwd( const Matrix & inInput, const Matrix & inGradOutput )
linearWeightBwd: backward for linear layer (weight gradient). Computes: dWeight = input^T @ dOutput

Parameters

inInput
const Matrix &

inGradOutput
const Matrix &

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::log( const oa::Matrix & inA )
log: Element-wise natural log: out = log(A).

Parameters

inA
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

oa::Matrix oa::FnMatrix::logSoftmax( const oa::Matrix & inA, oa::I32 inDim = -1 )
logSoftmax: Stable log-softmax over the selected dimension; -1 selects the last dimension.

Parameters

inA
const oa::Matrix &

inDim
oa::I32

Default: -1

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::logSoftmaxBwd( const Matrix & inForwardOutput, const Matrix & inGradOutput, oa::I32 inDim = -1 )
No public source comment is attached to this declaration.

Parameters

inForwardOutput
const Matrix &

inGradOutput
const Matrix &

inDim
oa::I32

Default: -1

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::mamba3Mimo( const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const Matrix & inMimoX, const Matrix & inMimoZ, const Matrix & inMimoO, const Matrix & inNormWeight, const SsmConfig & inConfig )
--- Mamba-3 MIMO selective scan ---

Parameters

inC
const Matrix &

inB
const Matrix &

inX
const Matrix &

inZ
const Matrix &

inAdt
const Matrix &

inDt
const Matrix &

inTrap
const Matrix &

inAngle
const Matrix &

inCBias
const Matrix &

inBBias
const Matrix &

inD
const Matrix &

inMimoX
const Matrix &

inMimoZ
const Matrix &

inMimoO
const Matrix &

inNormWeight
const Matrix &

inConfig
const SsmConfig &

Returns

Matrix

The declared return value.

Mamba3MimoBwdResult oa::FnMatrix::mamba3MimoBwd( const Matrix & inDOut, const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const Matrix & inMimoX, const Matrix & inMimoZ, const Matrix & inMimoO, const Matrix & inNormWeight, const SsmConfig & inConfig )
No public source comment is attached to this declaration.

Parameters

inDOut
const Matrix &

inC
const Matrix &

inB
const Matrix &

inX
const Matrix &

inZ
const Matrix &

inAdt
const Matrix &

inDt
const Matrix &

inTrap
const Matrix &

inAngle
const Matrix &

inCBias
const Matrix &

inBBias
const Matrix &

inD
const Matrix &

inMimoX
const Matrix &

inMimoZ
const Matrix &

inMimoO
const Matrix &

inNormWeight
const Matrix &

inConfig
const SsmConfig &

Returns

Mamba3MimoBwdResult

The declared return value.

Matrix oa::FnMatrix::mamba3MimoStep( const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const Matrix & inMimoX, const Matrix & inMimoZ, const Matrix & inMimoO, const Matrix & inNormWeight, const Matrix & inSsmState, const Matrix & inAngleState, const Matrix & inKState, const Matrix & inVState, const SsmConfig & inConfig )
No public source comment is attached to this declaration.

Parameters

inC
const Matrix &

inB
const Matrix &

inX
const Matrix &

inZ
const Matrix &

inAdt
const Matrix &

inDt
const Matrix &

inTrap
const Matrix &

inAngle
const Matrix &

inCBias
const Matrix &

inBBias
const Matrix &

inD
const Matrix &

inMimoX
const Matrix &

inMimoZ
const Matrix &

inMimoO
const Matrix &

inNormWeight
const Matrix &

inSsmState
const Matrix &

inAngleState
const Matrix &

inKState
const Matrix &

inVState
const Matrix &

inConfig
const SsmConfig &

Returns

Matrix

The declared return value.

Mamba3PreprocessResult oa::FnMatrix::mamba3Preprocess( const Matrix & inProjected, const Matrix & inDtBias, const Mamba3PreprocessConfig & inConfig )
--- Mamba3Preprocess: fused in_proj split + RMSNorm + dt + A·dt ---

Parameters

inProjected
const Matrix &

inDtBias
const Matrix &

inConfig
const Mamba3PreprocessConfig &

Returns

Mamba3PreprocessResult

The declared return value.

Mamba3PreprocessBwdResult oa::FnMatrix::mamba3PreprocessBwd( const Matrix & inProjected, const Matrix & inDtBias, const Matrix & inDZ, const Matrix & inDX, const Matrix & inDBh, const Matrix & inDCh, const Matrix & inDDT, const Matrix & inDADT, const Matrix & inDTrap, const Matrix & inDAngle, const Mamba3PreprocessConfig & inConfig )
No public source comment is attached to this declaration.

Parameters

inProjected
const Matrix &

inDtBias
const Matrix &

inDZ
const Matrix &

inDX
const Matrix &

inDBh
const Matrix &

inDCh
const Matrix &

inDDT
const Matrix &

inDADT
const Matrix &

inDTrap
const Matrix &

inDAngle
const Matrix &

inConfig
const Mamba3PreprocessConfig &

Returns

Mamba3PreprocessBwdResult

The declared return value.

Matrix oa::FnMatrix::mamba3Siso( const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const SsmConfig & inConfig )
--- Mamba-3 SISO selective scan ---

Parameters

inC
const Matrix &

inB
const Matrix &

inX
const Matrix &

inZ
const Matrix &

inAdt
const Matrix &

inDt
const Matrix &

inTrap
const Matrix &

inAngle
const Matrix &

inCBias
const Matrix &

inBBias
const Matrix &

inD
const Matrix &

inConfig
const SsmConfig &

Returns

Matrix

The declared return value.

SsmBwdResult oa::FnMatrix::mamba3SisoBwd( const Matrix & inDOut, const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const SsmConfig & inConfig )
No public source comment is attached to this declaration.

Parameters

inDOut
const Matrix &

inC
const Matrix &

inB
const Matrix &

inX
const Matrix &

inZ
const Matrix &

inAdt
const Matrix &

inDt
const Matrix &

inTrap
const Matrix &

inAngle
const Matrix &

inCBias
const Matrix &

inBBias
const Matrix &

inD
const Matrix &

inConfig
const SsmConfig &

Returns

SsmBwdResult

The declared return value.

Matrix oa::FnMatrix::mamba3SisoStep( const Matrix & inC, const Matrix & inB, const Matrix & inX, const Matrix & inZ, const Matrix & inAdt, const Matrix & inDt, const Matrix & inTrap, const Matrix & inAngle, const Matrix & inCBias, const Matrix & inBBias, const Matrix & inD, const Matrix & inSsmState, const Matrix & inAngleState, const Matrix & inKState, const Matrix & inVState, const SsmConfig & inConfig )
No public source comment is attached to this declaration.

Parameters

inC
const Matrix &

inB
const Matrix &

inX
const Matrix &

inZ
const Matrix &

inAdt
const Matrix &

inDt
const Matrix &

inTrap
const Matrix &

inAngle
const Matrix &

inCBias
const Matrix &

inBBias
const Matrix &

inD
const Matrix &

inSsmState
const Matrix &

inAngleState
const Matrix &

inKState
const Matrix &

inVState
const Matrix &

inConfig
const SsmConfig &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::maskedCategoricalAccuracyCount( const Matrix & inLogits, const Matrix & inLabels, const Matrix & inMask )
No public source comment is attached to this declaration.

Parameters

inLogits
const Matrix &

inLabels
const Matrix &

inMask
const Matrix &

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::matMulNt( const oa::Matrix & inA, const oa::Matrix & inB, oa::MatMulPrecision inPrecision = oa::MatMulPrecision::Auto ) oa::Matrix oa::FnMatrix::matMulNt( const oa::Matrix & inInput, const oa::QuantMatrix & inWeight )
matMulNt: oa::Matrix multiplication: B is [N,K] and out = A @ Bᵀ (the OA weight convention, shared with Linear/attention; NOT PyTorch-standard A with B as [K,N]). For batched/standard A use Bmm. Router resolves precision at context execution.

Parameters

inA
const oa::Matrix &

inB
const oa::Matrix &

inPrecision
oa::MatMulPrecision

Default: oa::MatMulPrecision::Auto

Returns

oa::Matrix

The declared return value.

oa::Matrix oa::FnMatrix::max( const oa::Matrix & inA, oa::I32 inDim = -1 )
max: Reduce all values by maximum; dim is retained as a compatibility parameter and is not a dimensional reduction.

Parameters

inA
const oa::Matrix &

inDim
oa::I32

Default: -1

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::maxBwd( const Matrix & inInput, const Matrix & inMaxValue, const Matrix & inGradOutput )
No public source comment is attached to this declaration.

Parameters

inInput
const Matrix &

inMaxValue
const Matrix &

inGradOutput
const Matrix &

Returns

Matrix

The declared return value.

MaxPool2dResult oa::FnMatrix::maxPool2d( const Matrix & inX, oa::I32 inKernelSize, oa::I32 inStride, oa::I32 inPadding )
No public source comment is attached to this declaration.

Parameters

inX
const Matrix &

inKernelSize
oa::I32

inStride
oa::I32

inPadding
oa::I32

Returns

MaxPool2dResult

The declared return value.

Matrix oa::FnMatrix::maxPool2dBwd( const Matrix & inX, const Matrix & inIndices, const Matrix & inGradOutput, oa::I32 inKernelSize, oa::I32 inStride, oa::I32 inPadding )
maxPool2dBwd: backward for 2D max pooling.

Parameters

inX
const Matrix &

inIndices
const Matrix &

inGradOutput
const Matrix &

inKernelSize
oa::I32

inStride
oa::I32

inPadding
oa::I32

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::mean( const oa::Matrix & inA, oa::I32 inDim = -1 )
mean: Reduce by arithmetic mean; a valid non-negative Dim produces a keep-dimension axis reduction, while -1 produces a full reduction.

Parameters

inA
const oa::Matrix &

inDim
oa::I32

Default: -1

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::mergeHeads( const Matrix & inX, oa::I32 inBatch, oa::I32 inSeqLen, oa::I32 inNumHeads )
mergeHeads: [B*H,S,D/H] -> [B*S,D]. exact inverse of splitHeads.

Parameters

inX
const Matrix &

inBatch
oa::I32

inSeqLen
oa::I32

inNumHeads
oa::I32

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::mish( const oa::Matrix & inA )
mish: Mish activation: out = A * tanh(softplus(A)).

Parameters

inA
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::mishBwd( const Matrix & inInput, const Matrix & inGradOutput )
mishBwd: backward pass for Mish activation.

Parameters

inInput
const Matrix &

forward INPUT x (mish'(x) depends on x directly)

inGradOutput
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::moeCombine( const Matrix & inPacked, const Matrix & inRouteGate, const Matrix & inInverse, const Matrix & inPackedSlot )
No public source comment is attached to this declaration.

Parameters

inPacked
const Matrix &

inRouteGate
const Matrix &

inInverse
const Matrix &

inPackedSlot
const Matrix &

Returns

Matrix

The declared return value.

MoeCombineBwdResult oa::FnMatrix::moeCombineBwd( const Matrix & inDOut, const Matrix & inPacked, const Matrix & inRouteGate, const Matrix & inInverse, const Matrix & inPackedSlot )
No public source comment is attached to this declaration.

Parameters

inDOut
const Matrix &

inPacked
const Matrix &

inRouteGate
const Matrix &

inInverse
const Matrix &

inPackedSlot
const Matrix &

Returns

MoeCombineBwdResult

The declared return value.

MoeExpertPlan oa::FnMatrix::moeExpertPlan( const Matrix & inExpertIndices, oa::I32 inNumExperts )
No public source comment is attached to this declaration.

Parameters

inExpertIndices
const Matrix &

inNumExperts
oa::I32

Returns

MoeExpertPlan

The declared return value.

Matrix oa::FnMatrix::moeGather( const Matrix & inSelf, const Matrix & inIndices, const Matrix & inInverse )
No public source comment is attached to this declaration.

Parameters

inSelf
const Matrix &

inIndices
const Matrix &

inInverse
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::moeGatherBwd( const Matrix & inSource, const Matrix & inInverse, oa::I32 inOutRows )
No public source comment is attached to this declaration.

Parameters

inSource
const Matrix &

inInverse
const Matrix &

inOutRows
oa::I32

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::moeRouteWeights( const Matrix & inProbs, const Matrix & inExpertIndices )
No public source comment is attached to this declaration.

Parameters

inProbs
const Matrix &

inExpertIndices
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::moeRouteWeightsBwd( const Matrix & inDOut, const Matrix & inProbs, const Matrix & inExpertIndices, const Matrix & inRouteWeights )
No public source comment is attached to this declaration.

Parameters

inDOut
const Matrix &

inProbs
const Matrix &

inExpertIndices
const Matrix &

inRouteWeights
const Matrix &

Returns

Matrix

The declared return value.

void oa::FnMatrix::moeRoutingBiasUpdate( const Matrix & inSelectionMask, Matrix & inOutBias, oa::I32 inExpertsPerToken, oa::F32 inGamma )
No public source comment is attached to this declaration.

Parameters

inSelectionMask
const Matrix &

inOutBias
Matrix &

inExpertsPerToken
oa::I32

inGamma
oa::F32

Returns

void

The declared return value.

oa::Matrix oa::FnMatrix::mul( const oa::Matrix & inA, const oa::Matrix & inB )
mul: Element-wise multiplication: out = A * B.

Parameters

inA
const oa::Matrix &

inB
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

void oa::FnMatrix::mulInPlace( Matrix & inSelf, const Matrix & inOther )
No public source comment is attached to this declaration.

Parameters

inSelf
Matrix &

inOther
const Matrix &

Returns

void

The declared return value.

oa::Matrix oa::FnMatrix::neg( const oa::Matrix & inA )
neg: Element-wise negation: out = -A.

Parameters

inA
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::ones( MatrixShape inShape, oa::ScalarType inDtype = weightDtype() )
No public source comment is attached to this declaration.

Parameters

inShape
MatrixShape

inDtype
oa::ScalarType

Default: weightDtype()

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::philoxNormal( const oa::Matrix & inA, oa::F32 inMean = 0.0F, oa::F32 inStddev = 1.0F, oa::U64 inSeed = 0 )
philoxNormal: Generate normal-distribution random values with Philox.

Parameters

inA
const oa::Matrix &

inMean
oa::F32

Default: 0.0F

inStddev
oa::F32

Default: 1.0F

inSeed
oa::U64

Default: 0

Returns

oa::Matrix

The declared return value.

oa::Matrix oa::FnMatrix::philoxUniform( const oa::Matrix & inA, oa::F32 inLow = 0.0F, oa::F32 inHigh = 1.0F, oa::U64 inSeed = 0 )
philoxUniform: Generate uniform-distribution random values with Philox.

Parameters

inA
const oa::Matrix &

inLow
oa::F32

Default: 0.0F

inHigh
oa::F32

Default: 1.0F

inSeed
oa::U64

Default: 0

Returns

oa::Matrix

The declared return value.

oa::Matrix oa::FnMatrix::pow( const oa::Matrix & inA, oa::F32 inExponent )
pow: Element-wise power: out = A^Exponent.

Parameters

inA
const oa::Matrix &

inExponent
oa::F32

Returns

oa::Matrix

The declared return value.

oa::QuantMatrix oa::FnMatrix::quantize( const oa::Matrix & inInput, oa::Quantization inQuantization )
quantize Float32 storage into one native OA Q4 or Q8 weight value. The returned value retains the source shape; its physical planes remain private.

Parameters

inInput
const oa::Matrix &

inQuantization
oa::Quantization

Returns

oa::QuantMatrix

The declared return value.

Matrix oa::FnMatrix::rand( MatrixShape inShape, oa::ScalarType inDtype = weightDtype() )
No public source comment is attached to this declaration.

Parameters

inShape
MatrixShape

inDtype
oa::ScalarType

Default: weightDtype()

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::randGlorotUniform( MatrixShape inShape, oa::ScalarType inDtype = weightDtype() )
No public source comment is attached to this declaration.

Parameters

inShape
MatrixShape

inDtype
oa::ScalarType

Default: weightDtype()

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::randKaimingUniform( MatrixShape inShape, oa::ScalarType inDtype = weightDtype() )
No public source comment is attached to this declaration.

Parameters

inShape
MatrixShape

inDtype
oa::ScalarType

Default: weightDtype()

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::randN( MatrixShape inShape, oa::ScalarType inDtype = weightDtype() )
No public source comment is attached to this declaration.

Parameters

inShape
MatrixShape

inDtype
oa::ScalarType

Default: weightDtype()

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::randXavier( MatrixShape inShape, oa::ScalarType inDtype = weightDtype() )
No public source comment is attached to this declaration.

Parameters

inShape
MatrixShape

inDtype
oa::ScalarType

Default: weightDtype()

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::reciprocal( const oa::Matrix & inA )
reciprocal: Element-wise reciprocal: out = 1 / A.

Parameters

inA
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

oa::Matrix oa::FnMatrix::relu( const oa::Matrix & inA )
relu: ReLU activation: out = max(0, A).

Parameters

inA
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::reluBwd( const Matrix & inForwardOutput, const Matrix & inGradOutput )
reluBwd: backward pass for ReLU activation. Computes: dInput = dOutput * (forwardOutput > 0)

Parameters

inForwardOutput
const Matrix &

inGradOutput
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::repeatInterleave( const Matrix & inA, oa::I32 inRepeats, oa::I32 inDim )
Shape helpers

Parameters

inA
const Matrix &

inRepeats
oa::I32

inDim
oa::I32

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::repeatInterleaveBwd( const Matrix & inGradOut, MatrixShape inInputShape, oa::I32 inRepeats, oa::I32 inDim )
No public source comment is attached to this declaration.

Parameters

inGradOut
const Matrix &

inInputShape
MatrixShape

inRepeats
oa::I32

inDim
oa::I32

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::reshape( const oa::Matrix & inA, oa::MatrixShape inShape )
reshape: Reshape tensor to new shape (view operation, no copy).

Parameters

inA
const oa::Matrix &

inShape
oa::MatrixShape

Returns

oa::Matrix

The declared return value.

ResidualRmsNormResult oa::FnMatrix::residualRmsNorm( const Matrix & inA, const Matrix & inB, const Matrix & inWeight, oa::F32 inEps )
--- ResidualRmsNorm: fused residual + RmsNorm ---

Parameters

inA
const Matrix &

inB
const Matrix &

inWeight
const Matrix &

inEps
oa::F32

Returns

ResidualRmsNormResult

The declared return value.

oa::Matrix oa::FnMatrix::rmsNorm( const oa::Matrix & inSelf, const oa::Matrix & inWeight, oa::F32 inEps )
rmsNorm: Weighted root mean square normalization over the last dimension: out = (A / sqrt(mean(A^2) + Eps)) * Weight.

Parameters

inSelf
const oa::Matrix &

inWeight
const oa::Matrix &

inEps
oa::F32

Returns

oa::Matrix

The declared return value.

RmsNormBwdResult oa::FnMatrix::rmsNormBwd( const Matrix & inX, const Matrix & inWeight, const Matrix & inGradOutput, oa::F32 inEps = 1e-5F )
rmsNormBwd: backward pass for RmsNorm.

Parameters

inX
const Matrix &

inWeight
const Matrix &

inGradOutput
const Matrix &

inEps
oa::F32

Default: 1e-5F

Returns

RmsNormBwdResult

The declared return value.

Matrix oa::FnMatrix::rmsNormGated( const Matrix & inSelf, const Matrix & inWeight, const Matrix & inBias, const Matrix & inZ, oa::F32 inEps, bool inNormBeforeGate = true )
LayerNorm and RmsNorm forward declarations are generated from MlFnMatrixNorm.toml.

Parameters

inSelf
const Matrix &

inWeight
const Matrix &

inBias
const Matrix &

inZ
const Matrix &

inEps
oa::F32

inNormBeforeGate
bool

Default: true

Returns

Matrix

The declared return value.

RmsNormGatedBwdResult oa::FnMatrix::rmsNormGatedBwd( const Matrix & inX, const Matrix & inWeight, const Matrix & inBias, const Matrix & inZ, const Matrix & inGradOutput, oa::F32 inEps )
rmsNormGatedBwd: backward for rmsNormGated (normBeforeGate = true). Returns grads w.r.t. x, weight, bias, z.

Parameters

inX
const Matrix &

inWeight
const Matrix &

inBias
const Matrix &

inZ
const Matrix &

inGradOutput
const Matrix &

inEps
oa::F32

Returns

RmsNormGatedBwdResult

The declared return value.

Matrix oa::FnMatrix::rnnCellLinear( const Matrix & inGatesI, const Matrix & inHidden, const Matrix & inWeightHh, oa::U32 inTimeOffset = 0, oa::U32 inBatchStride = 1, const Matrix & inBiasHh = Matrix{} )
rnnCellLinear: fused vanilla-RNN recurrent step — Linear(h, W_hh) + rnnCellPointwise. Replaces the per-timestep pair of dispatches with one kernel. inGatesI is the whole input projection [B*T, H]; inTimeOffset/inBatchStride index the current timestep's row directly, so oa::Rnn needs no per-step Slice. The hidden projection required by reverse mode is retained internally rather than exposed as an output parameter.

Parameters

inGatesI
const Matrix &

inHidden
const Matrix &

inWeightHh
const Matrix &

inTimeOffset
oa::U32

Default: 0

inBatchStride
oa::U32

Default: 1

inBiasHh
const Matrix &

Default: Matrix{}

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::rnnCellPointwise( const Matrix & inGatesI, const Matrix & inGatesH )
rnnCellPointwise: fused vanilla-RNN pointwise forward, h_new = tanh(gatesI + gatesH).

Parameters

inGatesI
const Matrix &

[B, H] input projection (W_ih x + b_ih)

inGatesH
const Matrix &

[B, H] hidden projection (W_hh h_prev + b_hh)

Returns

Matrix

The declared return value.

RnnCellPointwiseBwdResult oa::FnMatrix::rnnCellPointwiseBwd( const Matrix & inGatesI, const Matrix & inGatesH, const Matrix & inGradOutput, oa::I32 inHiddenSize, oa::U32 inTimeOffset = 0, oa::U32 inBatchStride = 1 )
rnnCellPointwiseBwd: fused vanilla-RNN pointwise backward. Returns gradients w.r.t. gatesI and gatesH (both equal to dL/da). inGatesI is the whole-sequence [B*T, H] projection; inTimeOffset/inBatchStride select this timestep's rows so dGatesI is scattered into the full buffer (zeros elsewhere).

Parameters

inGatesI
const Matrix &

inGatesH
const Matrix &

inGradOutput
const Matrix &

inHiddenSize
oa::I32

inTimeOffset
oa::U32

Default: 0

inBatchStride
oa::U32

Default: 1

Returns

RnnCellPointwiseBwdResult

The declared return value.

RnnScanResult oa::FnMatrix::rnnScan( const Matrix & inGatesI, const Matrix & inWeightHh, oa::I32 inHiddenSize, oa::I32 inSeqLen, oa::I32 inBatch, const Matrix & inBiasHh = Matrix{} )
rnnScan: whole-sequence vanilla-RNN recurrent scan in ONE dispatch. Mathematically identical to running rnnCellLinear for each timestep, but collapses S dispatches into 1. The recurrent weight/bias gradient is computed separately via linearWeightBiasBwd on the saved hPrev.

Parameters

inGatesI
const Matrix &

[B*S, H] precomputed input projection (row b*S+t = timestep t)

inWeightHh
const Matrix &

inHiddenSize
oa::I32

inSeqLen
oa::I32

inBatch
oa::I32

inBiasHh
const Matrix &

Default: Matrix{}

Returns

RnnScanResult

The declared return value.

RnnScanBwdResult oa::FnMatrix::rnnScanBwd( const Matrix & inDOut, const Matrix & inGatesI, const Matrix & inHPrev, const Matrix & inWeightHh, oa::I32 inHiddenSize, oa::I32 inSeqLen, oa::I32 inBatch, const Matrix & inBiasHh = Matrix{} )
rnnScanBwd: BPTT recurrence scan (backward of rnnScan) in ONE dispatch.

Parameters

inDOut
const Matrix &

inGatesI
const Matrix &

inHPrev
const Matrix &

inWeightHh
const Matrix &

inHiddenSize
oa::I32

inSeqLen
oa::I32

inBatch
oa::I32

inBiasHh
const Matrix &

Default: Matrix{}

Returns

RnnScanBwdResult

The declared return value.

Matrix oa::FnMatrix::sampleLogits( const Matrix & inLogits, oa::F32 inTemperature = 1.0F, oa::I32 inTopK = 0, oa::F32 inTopP = 1.0F, oa::U64 inSeed = 0 )
samples one class per last-axis row. temperature < = 0 is greedy; inTopK < = 0 keeps the full vocabulary; inTopP is clamped to (0,1].

Parameters

inLogits
const Matrix &

inTemperature
oa::F32

Default: 1.0F

inTopK
oa::I32

Default: 0

inTopP
oa::F32

Default: 1.0F

inSeed
oa::U64

Default: 0

Returns

Matrix

The declared return value.

oa::F32 oa::FnMatrix::scalar( const Matrix & inSrc )
Extract first element as F32 scalar (requires single-element matrix).

Parameters

inSrc
const Matrix &

Returns

oa::F32

The declared return value.

oa::Matrix oa::FnMatrix::scale( const oa::Matrix & inA, oa::F32 inScalar )
scale: Scalar multiplication: out = A * Scalar.

Parameters

inA
const oa::Matrix &

inScalar
oa::F32

Returns

oa::Matrix

The declared return value.

void oa::FnMatrix::scaleInPlace( Matrix & inSelf, oa::F32 inScalar )
No public source comment is attached to this declaration.

Parameters

inSelf
Matrix &

inScalar
oa::F32

Returns

void

The declared return value.

Matrix oa::FnMatrix::scatterAddRows( const Matrix & inSource, const Matrix & inIndices, oa::I32 inOutRows )
No public source comment is attached to this declaration.

Parameters

inSource
const Matrix &

inIndices
const Matrix &

inOutRows
oa::I32

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::scatterRows( const Matrix & inSelf, const Matrix & inSource, const Matrix & inRowMap, const Matrix & inCount ) Matrix oa::FnMatrix::scatterRows( const Matrix & inSelf, const Matrix & inSource, const CompactRowsResult & inPlan )
No public source comment is attached to this declaration.

Parameters

inSelf
const Matrix &

inSource
const Matrix &

inRowMap
const Matrix &

inCount
const Matrix &

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::scatterRowsBwdSource( const Matrix & inGradOut, const Matrix & inRowMap, const Matrix & inCount ) Matrix oa::FnMatrix::scatterRowsBwdSource( const Matrix & inGradOut, const Matrix & inRowMap, const Matrix & inCount, const Matrix & inDispatchArgs )
No public source comment is attached to this declaration.

Parameters

inGradOut
const Matrix &

inRowMap
const Matrix &

inCount
const Matrix &

Returns

Matrix

The declared return value.

void oa::FnMatrix::setRngSeed( oa::U64 inSeed )
--- RNG --- seed the host-side seed generator. call once at startup for reproducibility.

Parameters

inSeed
oa::U64

Returns

void

The declared return value.

oa::Matrix oa::FnMatrix::sigmoid( const oa::Matrix & inA )
sigmoid: Sigmoid activation: out = 1 / (1 + exp(-A)).

Parameters

inA
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::sigmoidBwd( const Matrix & inForwardOutput, const Matrix & inGradOutput )
sigmoidBwd: backward pass for Sigmoid activation. Computes: dInput = dOutput * sigmoid(x) * (1 - sigmoid(x))

Parameters

inForwardOutput
const Matrix &

inGradOutput
const Matrix &

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::silu( const oa::Matrix & inA )
silu: SiLU (Swish) activation: out = A * sigmoid(A).

Parameters

inA
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::siluBwd( const Matrix & inInput, const Matrix & inGradOutput )
siluBwd: backward pass for SiLU activation.

Parameters

inInput
const Matrix &

forward INPUT x (silu'(x) is a function of input, not output)

inGradOutput
const Matrix &

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::siluMul( const oa::Matrix & inA, oa::U32 inIntermediateSize )
siluMul: SiLU on first half, multiply with second half: out = SiLU(A[:N]) * A[N:].

Parameters

inA
const oa::Matrix &

inIntermediateSize
oa::U32

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::siluMulBwd( const Matrix & inInput, const Matrix & inGradOutput )
siluMulBwd: backward pass for SiluMul activation.

Parameters

inInput
const Matrix &

forward INPUT (gate||up); the forward output is not invertible

inGradOutput
const Matrix &

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::sin( const oa::Matrix & inA )
sin: Element-wise sine: out = sin(A).

Parameters

inA
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

oa::Matrix oa::FnMatrix::slice( const oa::Matrix & inSelf, oa::I32 inDim, oa::I64 inStart, oa::I64 inEnd )
slice: Materialize the half-open interval [Start, End) along one dimension.

Parameters

inSelf
const oa::Matrix &

inDim
oa::I32

inStart
oa::I64

inEnd
oa::I64

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::sliceBwd( MatrixShape inInputShape, oa::I32 inDim, oa::I64 inStart, oa::I64 inEnd, const Matrix & inDOut )
No public source comment is attached to this declaration.

Parameters

inInputShape
MatrixShape

inDim
oa::I32

inStart
oa::I64

inEnd
oa::I64

inDOut
const Matrix &

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::softmax( const oa::Matrix & inA, oa::I32 inDim = -1 )
softmax: Stable softmax over the selected dimension; -1 selects the last dimension.

Parameters

inA
const oa::Matrix &

inDim
oa::I32

Default: -1

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::softmaxBwd( const Matrix & inForwardOutput, const Matrix & inGradOutput, oa::I32 inDim = -1 )
backward ops

Parameters

inForwardOutput
const Matrix &

inGradOutput
const Matrix &

inDim
oa::I32

Default: -1

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::softmaxScaledMasked( const Matrix & inScores, const Matrix & inMask, oa::F32 inScale )
softmaxScaledMasked: fused transformer attention score normalisation. Computes: out = softmax(scores * scale + mask) over the last dimension.

Parameters

inScores
const Matrix &

inMask
const Matrix &

inScale
oa::F32

Returns

Matrix

The declared return value.

Matrix oa::FnMatrix::softmaxScaledMaskedBwd( const Matrix & inForwardOutput, const Matrix & inGradOutput, oa::F32 inScale )
softmaxScaledMaskedBwd: backward for the fused attention score op. Returns dScores = softmaxOut * (dOut - sum(dOut * softmaxOut)) * scale.

Parameters

inForwardOutput
const Matrix &

inGradOutput
const Matrix &

inScale
oa::F32

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::softplus( const oa::Matrix & inA )
softplus: Softplus: out = log(1+exp(A)), computed stably as max(A,0)+log1p(exp(-|A|)) (no f32 overflow).

Parameters

inA
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::softplusBwd( const Matrix & inForwardOutput, const Matrix & inGradOutput )
softplusBwd: backward pass for Softplus activation.

Parameters

inForwardOutput
const Matrix &

output y = softplus(a) from the forward pass

inGradOutput
const Matrix &

Returns

Matrix

dOut * sigmoid(a) = dOut * (1 - e^-y)

oa::Vector<Matrix> oa::FnMatrix::split( const Matrix & inSelf, oa::Span<oa::I64> inSizes, oa::I32 inDim = 0 )
No public source comment is attached to this declaration.

Parameters

inSelf
const Matrix &

inSizes
oa::Span<oa::I64>

inDim
oa::I32

Default: 0

Returns

oa::Vector<Matrix>

The declared return value.

Matrix oa::FnMatrix::splitHeads( const Matrix & inX, oa::I32 inBatch, oa::I32 inSeqLen, oa::I32 inNumHeads )
splitHeads: [B*S,D] -> [B*H,S,D/H]. Multi-head permutation.

Parameters

inX
const Matrix &

inBatch
oa::I32

inSeqLen
oa::I32

inNumHeads
oa::I32

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::sqrt( const oa::Matrix & inA )
sqrt: Element-wise square root: out = sqrt(A).

Parameters

inA
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

oa::Matrix oa::FnMatrix::sub( const oa::Matrix & inA, const oa::Matrix & inB )
Element-wise binary ops — broadcast-aware.

Parameters

inA
const oa::Matrix &

inB
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

void oa::FnMatrix::subInPlace( Matrix & inSelf, const Matrix & inOther )
No public source comment is attached to this declaration.

Parameters

inSelf
Matrix &

inOther
const Matrix &

Returns

void

The declared return value.

oa::Matrix oa::FnMatrix::subScalar( const oa::Matrix & inA, oa::F32 inScalar )
subScalar: Scalar subtraction: out = A - Scalar.

Parameters

inA
const oa::Matrix &

inScalar
oa::F32

Returns

oa::Matrix

The declared return value.

void oa::FnMatrix::subScalarInPlace( Matrix & inSelf, oa::F32 inScalar )
No public source comment is attached to this declaration.

Parameters

inSelf
Matrix &

inScalar
oa::F32

Returns

void

The declared return value.

oa::Matrix oa::FnMatrix::sum( const oa::Matrix & inA, oa::I32 inDim = -1 )
sum: Reduce by summation; a valid non-negative Dim produces a keep-dimension axis reduction, while -1 produces a full reduction.

Parameters

inA
const oa::Matrix &

inDim
oa::I32

Default: -1

Returns

oa::Matrix

The declared return value.

oa::Matrix oa::FnMatrix::swiglu( const oa::Matrix & inA, const oa::Matrix & inB )
swiglu: SwiGLU activation: out = SiLU(gate) * up.

Parameters

inA
const oa::Matrix &

inB
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

SwigluBwdResult oa::FnMatrix::swigluBwd( const Matrix & inGate, const Matrix & inUp, const Matrix & inOut, const Matrix & inGradOutput )
swigluBwd: backward pass for SwiGLU activation.

Parameters

inGate
const Matrix &

inUp
const Matrix &

inOut
const Matrix &

inGradOutput
const Matrix &

Returns

SwigluBwdResult

SwigluBwdResult with dGate, dUp

oa::Matrix oa::FnMatrix::tanh( const oa::Matrix & inA )
tanh: Tanh activation: out = tanh(A).

Parameters

inA
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::tanhBwd( const Matrix & inForwardOutput, const Matrix & inGradOutput )
tanhBwd: backward pass for Tanh activation. Computes: dInput = dOutput * (1 - tanh(x)^2), using saved tanh(x) output.

Parameters

inForwardOutput
const Matrix &

inGradOutput
const Matrix &

Returns

Matrix

The declared return value.

TopKResult oa::FnMatrix::topK( const Matrix & inA, oa::I32 inK, oa::I32 inDim = -1 )
No public source comment is attached to this declaration.

Parameters

inA
const Matrix &

inK
oa::I32

inDim
oa::I32

Default: -1

Returns

TopKResult

The declared return value.

Matrix oa::FnMatrix::topKMask( const Matrix & inIndices, oa::I32 inNumExperts )
No public source comment is attached to this declaration.

Parameters

inIndices
const Matrix &

inNumExperts
oa::I32

Returns

Matrix

The declared return value.

oa::Matrix oa::FnMatrix::transpose( const oa::Matrix & inA, oa::I32 inDim0 = -2, oa::I32 inDim1 = -1 )
transpose: Materialize a swap of the last two axes for rank-2 or rank-3 matrices.

Parameters

inA
const oa::Matrix &

inDim0
oa::I32

Default: -2

inDim1
oa::I32

Default: -1

Returns

oa::Matrix

The declared return value.

Matrix oa::FnMatrix::upsampleBwd( const Matrix & inInput, const Matrix & inDOut, oa::I32 inScaleFactor, bool inIsBilinear )
upsampleBwd: backward pass for Upsample (Nearest or Bilinear).

Parameters

inInput
const Matrix &

inDOut
const Matrix &

inScaleFactor
oa::I32

inIsBilinear
bool

Returns

Matrix

The declared return value.

VqAssignResult oa::FnMatrix::vqAssign( const Matrix & inZe, const Matrix & inCodebook )
vqAssign: vector-quantization nearest-code assignment (VQ-VAE codebook lookup). inZe: [N, D] latents. inCodebook: [K, D] codes. Returns the per-row argmin index (int32 [N]) and the gathered winning code (float [N, D]) by squared L2 distance.

Parameters

inZe
const Matrix &

inCodebook
const Matrix &

Returns

VqAssignResult

The declared return value.

void oa::FnMatrix::vqEmaUpdate( const Matrix & inZe, const Matrix & inIdx, Matrix & ioEmbedSum, Matrix & ioClusterSize, Matrix & outCodebook, oa::F32 inDecay, oa::F32 inEps, oa::F32 inDeadThreshold, oa::U32 inSeed, bool inNormalize )
vqEmaUpdate: EMA codebook update + dead-code reinit (van den Oord 2017). The codebook is NOT gradient-trained; each entry tracks the running mean of encoder outputs assigned to it, and dead codes are revived from live encoder rows. inZe [N,D], inIdx [N] int32 (from vqAssign), ioEmbedSum [K,D], ioClusterSize [K], outCodebook [K,D]. inDecay = EMA γ; inEps = division floor; inDeadThreshold = revive codes whose EMA count falls below it; inSeed = per-step seed; inNormalize rescales each codebook row to unit RMS (cosine VQ).

Parameters

inZe
const Matrix &

inIdx
const Matrix &

ioEmbedSum
Matrix &

ioClusterSize
Matrix &

outCodebook
Matrix &

inDecay
oa::F32

inEps
oa::F32

inDeadThreshold
oa::F32

inSeed
oa::U32

inNormalize
bool

Returns

void

The declared return value.

oa::ScalarType oa::FnMatrix::weightDtype()
--- Configuration --- weight allocation follows the precision of the active engine context.

Returns

oa::ScalarType

The declared return value.

Matrix oa::FnMatrix::zeros( MatrixShape inShape, oa::ScalarType inDtype = weightDtype() )
No public source comment is attached to this declaration.

Parameters

inShape
MatrixShape

inDtype
oa::ScalarType

Default: weightDtype()

Returns

Matrix

The declared return value.