Uses of Class
ai.beestream.jitnn.Tensor
Packages that use Tensor
Package
Description
The jitNN API:
Tensor (n-dimensional arrays, lazy on TornadoVM
devices), reverse-mode differentiation (Tensor.backward(), Grad),
the functional operators of F, linear algebra (Linalg),
Fourier transforms (Fft), sparse matrices (SparseMatrix),
mixed precision (Autocast) and user-defined operators
(CustomOp).Datasets: MNIST and CIFAR-10 readers, a byte-level text corpus, and synthetic data, held in memory as
a
Dataset.Several devices: collectives (all-reduce, broadcast, reduce-scatter, all-gather) among ranks,
staged through the host (
HostCollective) or run by NCCL on NVIDIA GPUs
(NcclCollective), and ProcessGroup, which
runs one rank per device.A Deep Java Library engine named
jitNN: DJL's NDArrays, blocks, Trainer and
Predictor run on jitNN (JitnnEngine).The execution engine, which records operators in a per-thread trace and, at a sync point, compiles
the trace into one TornadoVM task graph, cached by structure and replayed, or runs it on the host
with the double-precision reference.
The GGUF reader (llama.cpp's model format):
GgufFile gives a file's
metadata and its tensors, memory-mapped without a copy, in their quantised blocks or as F32, F16
and BF16.Checkpoints: named tensors and values (
StateDict) saved and loaded in
Hugging Face's safetensors format (SafeTensors).Classical machine learning after scikit-learn, run on the device: k-means, k-nearest neighbours,
PCA, linear and logistic regression, linear SVM, naive Bayes, decision trees, random forests,
gradient boosting and t-SNE.
Neural-network modules after PyTorch's
torch.nn: Module and
Sequential, linear and convolution layers, pooling, normalisation,
attention, embeddings, recurrent layers (LSTM, GRU), graph convolution, activations, and data-parallel
training (DataParallel).Complete models: ResNet, MobileNetV2, GPT-2, a Llama-style decoder, BERT, a VAE, DCGAN, U-Net and
character RNNs, and the embedding models word2vec, doc2vec and GloVe.
Optimisers with PyTorch's semantics (SGD, Adam and AdamW, AdaGrad, RMSProp, AdaDelta, AdaMax,
NAdam, LAMB, LARS), learning-rate schedules (
LRScheduler) and dynamic
loss scaling for FP16 training (GradScaler).Vocabularies and training examples for the embedding models in
ai.beestream.jitnn.nn.models.The ONNX importer:
OnnxSession loads an ONNX file and runs it on
jitNN's operators.The TensorFlow importer:
TfModel loads SavedModels and frozen GraphDefs,
translating them into ONNX graphs that the ONNX importer runs on jitNN.-
Uses of Tensor in ai.beestream.jitnn
Methods in ai.beestream.jitnn that return TensorModifier and TypeMethodDescriptionTensor.abs()|x|, element-wise.Tensor.acos()Element-wise arccosine.Tensor.acosh()Element-wise inverse hyperbolic cosine.static TensorF.adaptiveAvgPool(Tensor x, int... out) Adaptive average pooling of x [N, C, ...] (1 to 3 spatial axes) to the given output sizes (PyTorch's bins).static TensorF.adaptiveMaxPool(Tensor x, int... out) Adaptive max pooling of x [N, C, ...] (1 to 3 spatial axes) to the given output sizes.Tensor.add(float c) this + c.this + o, element-wise with broadcasting.static TensorA tensor that sharesbase's storage under another shape.Applies the operator with integer and float attributes (part of the plan's cache key); returns its first output.Applies the operator; returns its first output.Tensor[]The gradient of each input ofnode(null where none is needed), from the gradientgradOutof its first output.Tensor[][dL/da, dL/db], from the inputs a and b, the output y and dL/dy.dL/dx, from the input x, the output y and dL/dy.Tensor[]Applies the operator; returns all its outputs.static TensorTensor.arange(float start, float end, float step) start, start + step, ... below end (above end for a negative step): torch.arange, ONNX Range.Tensor.argmax(int axis) Index of the maximum alongaxis, as an INT32 tensor (no gradient).Tensor.argmin(int axis) INT32 index of the first minimum alongaxis.Tensor.argsort(int axis, boolean descending) INT32 indices that sort alongaxis(stable).Tensor.asin()Element-wise arcsine.Tensor.asinh()Element-wise inverse hyperbolic sine.Tensor.atan()Element-wise arctangent.atan2(this, o), the angle of the point (o, this), with broadcasting.Tensor.atanh()Element-wise inverse hyperbolic tangent.static TensorF.attentionSoftmax(Tensor scores, float scale, boolean causal) softmax(scores * scale) over the last axis of attention scores [..., T, S], in one kernel;causal: query t sees keys 0 .. t, as PyTorch'sis_causal.static TensorAverage pooling of x [N, C, L], PyTorch's avg_pool1d; padding counts in the divisor, as PyTorch's default.static TensorAverage pooling of x [N, C, H, W] over square windows, PyTorch's avg_pool2d; padding counts in the divisor, as PyTorch's default.static TensorAverage pooling of x [N, C, D, H, W] over cubic windows, PyTorch's avg_pool3d; padding counts in the divisor.static TensorF.batchNorm(Tensor x, Tensor runningMean, Tensor runningVar, Tensor weight, Tensor bias, boolean training, float momentum, float eps) Batch normalisation of an NCHW (or NC) tensor.static TensorF.batchNormRelu(Tensor x, Tensor runningMean, Tensor runningVar, Tensor weight, Tensor bias, boolean training, float momentum, float eps) relu(batchNorm(...)), fused.Tensor.bfloat16()This tensor converted to BF16 (to(DType.BF16)).static TensorF.binaryCrossEntropy(Tensor p, Tensor target) Binary cross-entropy of probabilitiespin [0, 1] againsttarget, PyTorch semantics: the logs are clamped at -100, so p = 0 or 1 gives finite values and gradients.static TensorF.binaryCrossEntropy(Tensor p, Tensor target, F.Reduction reduction) F.binaryCrossEntropy(Tensor, Tensor)reduced asreductionsays.static TensorF.binaryCrossEntropyWithLogits(Tensor logits, Tensor target) Binary cross-entropy on logits, sigmoid folded in without overflow (PyTorch's BCEWithLogits).static TensorF.binaryCrossEntropyWithLogits(Tensor logits, Tensor target, F.Reduction reduction) F.binaryCrossEntropyWithLogits(Tensor, Tensor)reduced asreductionsays.Tensor.bitwiseAnd(Tensor o) Bitwise and of INT32 tensors, with broadcasting.Tensor.bitwiseNot()Bitwise complement of an INT32 tensor.Bitwise or of INT32 tensors, with broadcasting.Tensor.bitwiseXor(Tensor o) Bitwise exclusive or of INT32 tensors, with broadcasting.static TensorJoins tensors along an existing axis.Tensor.ceil()Element-wise ceiling.Tensor.celu(float alpha) CELU: max(0, x) + min(0, alpha (exp(x / alpha) - 1)).static TensorF.centerCrop(Tensor x, int height, int width) The central height x width window of images [..., H, W] (torchvision's center_crop, top-left rounding down).static TensorGrad.checkpoint(Function<Tensor[], Tensor> segment, Tensor... inputs) Activation checkpointing, as PyTorch'storch.utils.checkpoint: runssegmentoninputsand keeps none of its activations for the backward pass, which runs the segment again to get them.static TensorLower Cholesky factor L, A = L L^T, of symmetric positive-definite matrices (only the lower triangle is read).Tensor[]Tensor.chunk(int chunks, int axis) Splitsaxisintochunksequal pieces.Tensor.clamp(float lo, float hi) x clamped to [lo, hi].static TensorRescales the gradients ofparamsso that their global L2 norm is at mostmaxNorm, as PyTorch'sclip_grad_norm_: every gradient is multiplied by min(1, maxNorm / (norm + 1e-6)).static TensorF.contrastiveLoss(Tensor a, Tensor b, Tensor similar, float margin, F.Reduction reduction) Contrastive loss (Hadsell et al., 2006) withsimilar1 for similar pairs and 0 for dissimilar ones: similar d^2 + (1 - similar) max(margin - d, 0)^2.static TensorConvolution over 1 to 3 spatial axes with a size per axis:padsholds the padding before every axis, then after every axis (ONNX's order), so it may be asymmetric.static Tensor1-D convolution of x [N, C, L] with weight [Cout, C, K]; bias may be null.static TensorGrouped 1-D convolution: weight [Cout, C / groups, K]; groups = C is depthwise.static Tensor2-D convolution (NCHW), square kernel; bias may be null.static TensorF.conv2dRelu(Tensor x, Tensor weight, Tensor bias, int stride, int padding, int dilation, int groups) relu(conv2d(...)) with the bias and ReLU fused into the convolution's output.static Tensor3-D convolution of x [N, C, D, H, W] with weight [Cout, C, KD, KH, KW]; bias may be null.static TensorGrouped 3-D convolution: weight [Cout, C / groups, KD, KH, KW].static TensorF.convTranspose2d(Tensor x, Tensor weight, Tensor bias, int stride, int padding, int outputPadding, int dilation, int groups) Transposed 2-D convolution (NCHW), PyTorch's conv_transpose2d: weight [Cin, Cout/groups, K, K], square kernel; bias may be null.Tensor.cos()Element-wise cosine.Tensor.cosh()Element-wise hyperbolic cosine.static TensorF.cosineEmbeddingLoss(Tensor a, Tensor b, Tensor target, float margin, F.Reduction reduction) Cosine embedding loss: 1 - cos(a, b) for target 1, max(0, cos(a, b) - margin) for -1.static TensorF.cosineProximityLoss(Tensor input, Tensor target, F.Reduction reduction) Cosine proximity loss (DL4J, Keras): minus the cosine similarity along the last axis, reduced.static TensorF.cosineSimilarity(Tensor a, Tensor b, int axis, float eps) Cosine similarity alongaxis: a . b / (max(|a|, eps) max(|b|, eps)), PyTorch's cosine_similarity.static TensorF.crossEntropy(Tensor logits, Tensor labels) Mean cross-entropy betweenlogits[N, C] and INT32 class labels [N] (fused kernels).static TensorF.ctcLoss(Tensor logProbs, Tensor targets, int[] inputLengths, int[] targetLengths, int blank, F.Reduction reduction) CTC loss, PyTorch's ctc_loss: log-probabilities [T, B, C] (log_softmax over C), INT32 targets [B, L] padded, input and target lengths; blank indexblank.Tensor.cube()x^3 (DL4J's Cube activation).Tensor.cumprod(int axis) Inclusive cumulative product alongaxis; its gradient is exact with zeros.Tensor.cumsum(int axis) Inclusive cumulative sum alongaxis.static TensorThe firstlengthentries of dimensionaxisoft, copied on the host (a device result is read back first).static TensorF.depthToSpace(Tensor x, int block, String mode) Moves blocks of channels into space: x [N, C, H, W] to [N, C / b^2, H b, W b].static TensorF.dequantize(Tensor q) A Q8_0 tensor back to FP32.static TensorDeterminants [...] of square matrices.Tensor.detach()The same data without gradient history.this / o, element-wise with broadcasting.static TensorInverted dropout with a fresh mask per step:seedis an INT32 [2] host tensor.static Tensor[]Eigenvalues (ascending) [..., n] and eigenvectors (columns) [..., n, n] of symmetric matrices, torch.linalg.eigh.static TensorEigenvalues (ascending) of symmetric matrices, torch.linalg.eigvalsh.Tensor.elu(float alpha) ELU: x for x > 0, else alpha (exp(x) - 1).static TensorRows ofweight[V, D] picked by the INT32index: shape index.shape + [D].static TensorAsF.embedding(Tensor, Tensor); rowpaddingIdxreceives no gradient.static TensorF.embeddingBag(Tensor indices, int[] offsets, Tensor weight, F.BagMode mode) EmbeddingBag (PyTorch's, 1-D input with offsets): the rows ofweightpicked by the INT32indices, combined per bag bymode.1 where this == o, else 0, with broadcasting.Tensor.erf()Element-wise error function.Tensor.erfc()Element-wise complementary error function.Tensor.exp()e^x, element-wise.Broadcast copy totargetshape.Tensor.expm1()Element-wise exp(x) - 1, accurate near 0.static TensorTensor.eye(int n, int m, int k) The n x m matrix with ones on diagonal k (0 main, positive above, negative below), zeros elsewhere.static TensorTensor.eye(int, int, int)with the shape of the rank-2 tensorlike(ONNX EyeLike).static TensorF.fakeQuantize(Tensor x, float scale, float lowest, int bits) Quantises x tobits(8 or 16) bits and back: clamp(round_half_even(x / scale), lowest, lowest + 2^bits - 1) * scale,lowestbeing the lowest code minus the zero point (ONNX QuantizeLinear followed by DequantizeLinear).static Tensortorch.fft.fft of complex x along the last axis, full length, BACKWARD scaling.static Tensortorch.fft.fft of complex x [..., 2]; n > 0 crops or zero-pads axisdimto n.static Tensortorch.fft.fft2: the transform over the last two complex axes.static Tensorx reversed along each ofaxes(torch.flip).Tensor.floor()Element-wise floor.Element-wise maximum ignoring a NaN operand (torch.fmax).Element-wise minimum ignoring a NaN operand (torch.fmin).this - trunc(this / o) o, with broadcasting: the remainder with the sign of the dividend (torch.fmod).static TensorFolds columns back into an image, summing overlaps (torch fold, ONNX Col2Im); seeSpatial.fold.static TensorTensor.full(float value, int... dims) An FP32 tensor of the given shape with every elementvalue.torch.gather alongaxiswith an INT32 index of this shape except along the axis.static TensorSlices of data picked by INT32 index rows indices [..., k] (ONNX GatherND, batch_dims 0); differentiable in data.static TensorF.gaussianKl(Tensor mu, Tensor logvar) KL divergence of N(mu, exp(logvar)) from N(0, 1), summed over every element: -0.5 * sum(1 + logvar - mu^2 - exp(logvar)), the VAE regulariser.1 where this >= o, else 0, with broadcasting.Tensor.gelu()GELU, exact form x * Phi(x) (PyTorch's default, approximate='none').Tensor.geluTanh()GELU with the tanh approximation (GPT-2's form, PyTorch's approximate='tanh').static TensorF.globalAvgPool2d(Tensor x) Mean over the spatial dimensions: [N, C, H, W] to [N, C].static TensorGloVe's weighted least squares (Pennington et al., 2014) over a batch of co-occurrences: mean of weight (wi . wj + bi + bj - logX)^2, with wi, wj [B, D] and the rest [B].Tensor.grad()The accumulated gradient of a leaf tensor afterTensor.backward(), or null.static TensorGroupNorm (Wu and He) of x [N, C, ...] ingroupsgroups of channels: each (sample, group) normalised over its channels and positions, then a per-channel affine (weight and bias may be null, as PyTorch with affine=False).static Tensor[]One GRU layer over x [T, B, I] (time first), PyTorch's equations and gate order (r, z, n): wih [3H, I], whh [3H, H], biases [3H], h0 [B, H].static Tensor[]AsF.gru(Tensor, Tensor, Tensor, Tensor, Tensor, Tensor)for padded batches oflengths.1 where this > o, else 0, with broadcasting.Tensor.half()This tensor converted to FP16 (to(DType.F16)).Tensor.hardSigmoid()HardSigmoid, PyTorch's form: clamp(x / 6 + 1/2, 0, 1).Tensor.hardSwish()HardSwish: x hardSigmoid(x).Tensor.hardTanh(float lo, float hi) HardTanh: x clamped to [lo, hi] (PyTorch's default -1, 1).static TensorF.hingeLoss(Tensor input, Tensor target, F.Reduction reduction) Hinge loss with targets in {-1, 1}: max(0, 1 - target * input), Keras's hinge (mean).static TensorF.huberLoss(Tensor input, Tensor target, float delta, F.Reduction reduction) Huber loss with thresholddelta: 0.5 d^2 where |d| < delta, else delta (|d| - delta / 2), d = input - target (PyTorch's huber_loss).static Tensortorch.fft.ifft of complex x along the last axis, full length, BACKWARD scaling (1/n).static Tensortorch.fft.ifft.static Tensortorch.fft.ifft2.Tensor.indexSelect(int axis, Tensor idx) Elements idx[0 .. m-1] (INT32 [m]) ofaxis, torch.index_select.static TensorRuns a forward pass for inference: no gradient recording, and every tensor created inside except the returned one is internal, so its buffer is reused as soon as the computation no longer needs it.static TensorF.instanceNorm(Tensor x, Tensor weight, Tensor bias, float eps) InstanceNorm: GroupNorm with one channel per group (affine when weight and bias are given).static TensorF.interpolate(Tensor x, int height, int width, boolean bilinear, boolean alignCorners) Resizes x [N, C, H, W] to [N, C, height, width], nearest or bilinear (PyTorch's interpolate with size).static TensorInverse of square matrices.static Tensortorch.fft.irfft along the last axis: a real signal of length 2 (m - 1), BACKWARD scaling (1/n).static Tensortorch.fft.irfft: the real signal of length n (default 2 (m - 1)) whose spectrum's non-negative half is x [..., m, 2]; the imaginary parts at frequency 0 and n / 2 are ignored.Tensor.isFiniteMask()1 where finite, else 0.Tensor.isInf()1 where +inf or -inf, else 0.Tensor.isNaN()1 where NaN, else 0 (tested by bit pattern).static TensorFft.istft(Tensor x, int nFft, int hop, Tensor window, boolean center, boolean normalized, int length) torch.istft(x, nFft, hop, window=window, center, normalized, onesided=True, length): x [(B,) nFft / 2 + 1, frames, 2] back to [(B,) length] (length <= 0: as long as the frames reach, less the centre padding), by overlap-add divided by the summed squared window.static TensorMarkstas read by the caller: its buffer is never reused.static TensorF.l1Loss(Tensor input, Tensor target, F.Reduction reduction) Mean absolute error (L1), PyTorch's l1_loss.static TensorLayerNorm over the last axis: (x - mean) / sqrt(var + eps) * weight + bias (bias may be null).1 where this <= o, else 0, with broadcasting.Tensor.leakyRelu(float slope) LeakyReLU: x for x > 0, elseslope* x (PyTorch's default slope is 0.01).static Tensory = x W^T + b, with W stored [out, in] and b of shape [out] (b may be null); one fused GEMM. x may have any leading dimensions: [..., in] gives [..., out].static Tensory = x W^T + b with Q8_0 weights W [out, in]; the gradient reaches x, not W.static TensorF.linearRelu(Tensor x, Tensor weight, Tensor bias) relu(x W^T + b), with the bias and ReLU fused into the GEMM epilogue.static TensorF.localResponseNorm(Tensor x, int size, float alpha, float beta, float k) Local response normalisation across channels, PyTorch's local_response_norm (k 1, alpha 1e-4, beta 0.75 by default).Tensor.log()The natural logarithm, element-wise.Tensor.log1p()Element-wise log(1 + x), accurate near 0.Tensor.logicalAnd(Tensor o) 1 where both are non-zero, with broadcasting.Tensor.logicalNot()Element-wise logical not: 1 where x is 0, else 0.1 where either is non-zero, with broadcasting.Tensor.logicalXor(Tensor o) 1 where exactly one is non-zero, with broadcasting.static TensorF.logSigmoid(Tensor x) log sigmoid(x) = -softplus(-x), without overflow.Tensor.logSoftmax()Log-softmax along the last axis.static TensorF.lpNormalize(Tensor x, int p, int axis, float eps) x / max(||x||_p, eps) alongaxis, p = 1 or 2 (torch.nn.functional.normalize; ONNX LpNormalization with eps 0).static Tensor[]One LSTM layer over x [T, B, I] (time first), PyTorch's equations and gate order (i, f, g, o): wih [4H, I], whh [4H, H], biases [4H], h0 and c0 [B, H].static Tensor[]F.lstm(Tensor x, Tensor wih, Tensor whh, Tensor bih, Tensor bhh, Tensor h0, Tensor c0, int[] lengths) AsF.lstm(Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor)for padded batches: INT32lengths[B] (null: all T); outputs past a sequence's length are 0 and h_n, c_n are each sequence's last valid state.1 where this < o, else 0, with broadcasting.static Tensor[]P, L, U with A = P L U, torch.linalg.lu for square matrices.static Tensor[]LU factorisation with partial pivoting, torch.linalg.lu_factor: the packed factors (L unit lower below the diagonal, U on and above) and INT32 row indices perm, with row i of P^T A being row perm[i] of A (0-based, unlike LAPACK's swap list).static TensorF.mapeLoss(Tensor input, Tensor target, F.Reduction reduction) Mean absolute percentage error: 100 |target - input| / max(|target|, eps) (Keras's MAPE, eps 1e-7).static TensorF.marginRankingLoss(Tensor x1, Tensor x2, Tensor target, float margin, F.Reduction reduction) Margin ranking loss: max(0, -target (x1 - x2) + margin), target 1 or -1.Tensor.maskedSelect(Tensor mask) The elements wheremask(broadcast) is not zero, as a vector (torch.masked_select); reads the count back to the host.The matrix product this b: [M, K] x [K, N] to [M, N], or batched over leading axes, which must match unless one side is a plain matrix shared by every batch.op(this) * op(b), where op transposes when the flag is set, without materialising the transpose.Tensor.max(int axis, boolean keepDim) The maximum alongaxis, which is kept with size 1 whenkeepDimis set;Tensor.argmax(int)gives its index.The element-wise maximum of this and o, with broadcasting (Tensor.maximumNaN(Tensor)propagates NaN).Tensor.maximumNaN(Tensor o) Element-wise maximum propagating NaN (torch.maximum).static TensorMax pooling of x [N, C, L] over windows ofkernelwith the given stride and padding (padding never wins), PyTorch's max_pool1d.static TensorMax pooling of x [N, C, H, W] over square windows ofkernelwith the given stride and padding, PyTorch's max_pool2d.static TensorMax pooling of x [N, C, D, H, W] over cubic windows ofkernel(padding never wins), PyTorch's max_pool3d.Tensor.mean()The mean of all elements, as a scalar.Tensor.mean(int axis, boolean keepDim) The mean alongaxis, which is kept with size 1 whenkeepDimis set.Tensor.min(int axis, boolean keepDim) The minimum alongaxis, which is kept with size 1 whenkeepDimis set;Tensor.argmin(int)gives its index.The element-wise minimum of this and o, with broadcasting (Tensor.minimumNaN(Tensor)propagates NaN).Tensor.minimumNaN(Tensor o) Element-wise minimum propagating NaN (torch.minimum).Tensor.mish()Mish: x tanh(softplus(x)).A dense with A's stored valuesvalues[nnz] (coordinate order); dense [cols, feat] gives [rows, feat].This matrix times dense [cols, feat].static TensorMean squared error betweeninputandtarget(same shape).static TensorF.mseLoss(Tensor input, Tensor target, F.Reduction reduction) Squared error betweeninputandtarget(same shape), reduced asreductionsays.static TensorF.msleLoss(Tensor input, Tensor target, F.Reduction reduction) Mean squared logarithmic error: (log1p(input) - log1p(target))^2 (Keras's MSLE).Tensor.mul(float c) this * c.this * o, element-wise with broadcasting.static TensorF.multiHeadAttention(Tensor x, Tensor wqkv, Tensor bqkv, Tensor wout, Tensor bout, int heads, Tensor mask, boolean causal) Multi-head self-attention on x [B, T, D], as PyTorch'snn.MultiheadAttentionwith batch_first: q, k, v = split(x Wqkv^T + bqkv),headsheads, then the output projection.static TensorF.multinomial(Tensor weights, Tensor seed, int stream) One INT32 index per row of non-negative weights [..., V] (probabilities, or any unnormalised weights), drawn in proportion to the weight.Tensor.nanToNum(float nan, float posInf) NaN tonan, +inf toposInfand -inf to -posInf (torch.nan_to_num with a symmetric infinity).Tensor.narrow(int axis, int start, int length) Elementsstart .. start + length - 1alongaxis, as a new tensor.1 where this !Tensor.neg()-this.static TensorF.negativeSamplingLoss(Tensor hidden, Tensor target, Tensor negatives) Negative-sampling loss of word2vec (Mikolov et al., 2013): hidden [B, D] (the centre word, or the averaged context), target [B, D] (the output vector of the true word) and negatives [B, K, D] (output vectors of sampled words); mean over B of -log sigmoid(h . t) - sum_k log sigmoid(-h . n_k).static TensorPer-sample negative log-likelihood of INT32labelsunder log-probabilitieslogp.static TensorF.nllLoss(Tensor logp, Tensor labels, F.Reduction reduction) Negative log-likelihood of INT32 labels under log-probabilities [N, C], reduced.static Tensortorch.nonzero_static: INT32 coordinates [size, rank] of the firstsizenon-zero elements, the rest of the rowsfill.Tensor.nonzero()INT32 coordinates [count, rank] of the non-zero elements (torch.nonzero); reads the count back to the host.Tensor.norm(int p, int axis, boolean keepDim) The p-norm (p = 1 or 2) alongaxis: sum |x| or sqrt(sum x^2).static TensorTensor.normal(long seed, float mean, float std, int... dims) Normal with the given mean and standard deviation, counter-based likeTensor.uniform(long, float, float, int...).static TensorAsTensor.normal(long, float, float, int...)with the seed in an INT32 [2] tensor.static TensorF.normalizeImage(Tensor x, float[] mean, float[] std) Normalises images x [N, C, H, W] per channel: (x - mean[c]) / std[c], as torchvision's Normalize.static TensorTensor.of(float[] data, int... dims) An FP32 tensor with a copy ofdatain the shapedims(a vector of all the values when no dims are given).static TensorTensor.of(int[] data, int... dims) An INT32 tensor (labels, indices) with a copy ofdata;Tensor.of(float[], int...)for int data.static TensorTensor.of(uk.ac.manchester.tornado.api.types.arrays.HalfFloatArray data, int... dims) An FP16 input overdata, held without a copy (an FP16 image batch for half-precision inference, say): plans read it as they read any host input.static TensorINT32 labels [...] to a one-hot [..., classes].static TensorTensor.ones(int... dims) An FP32 tensor of ones.static Tensortwith dimensionaxisgrown tosize, the new elements set tovalue; built on the host (a device result is read back first).static TensorPads the spatial axes of x [N, C, ...]:before[k]andafter[k]elements on spatial axis k, PyTorch's F.pad for constant, reflect and replicate modes.static TensorF.pairwiseDistance(Tensor a, Tensor b) Euclidean distance of each row pair (last axis), PyTorch's pairwise_distance with eps 1e-6.static TensorA trainable parameter: persistent storage (it stays on the device across steps), gradient tracking on, initialised with the values ofinit.Tensor.permute(int... order) The axes reordered: axis i of the result is axisorder[i]of this tensor.static TensorTensor.persistent(Tensor init) Persistent storage without gradient tracking (optimiser state, running statistics).static TensorTensor.persistent(uk.ac.manchester.tornado.api.types.arrays.TornadoNativeArray array, DType dtype, int... dims) A persistent tensor (a weight that stays on the device) over an existing native array, without copying it: for example an array that wraps a memory-mapped file.static TensorTensor.persistentHalf(float[] values, int... dims) Persistent FP16 storage (weights kept in half precision on the device), from FP32 values rounded to nearest.static TensorF.poissonNllLoss(Tensor input, Tensor target, boolean logInput, float eps, F.Reduction reduction) Poisson negative log-likelihood, PyTorch's poisson_nll_loss without the Stirling term: exp(input) - target input withlogInput, else input - target log(input + eps).static TensorF.pool(Tensor x, F.PoolMode mode, int[] kernel, int[] stride, int[] pads, int[] dilation, boolean ceil, boolean countIncludePad, float p) Pooling over 1 to 3 spatial axes of x [N, C, ...] with a size per axis, as ONNX's MaxPool, AveragePool and LpPool and PyTorch's pooling layers:padsholds the padding before every axis, then after every axis;ceilrounds the output size up (a window must still start inside the input or its leading padding); average pooling counts the padding whencountIncludePad(never the positions added byceil); LP pooling computes (sum |x|^p)^(1/p).Tensor.pow(float exponent) x^exponent, element-wise.x^exponent, element-wise, with broadcasting.static TensorPReLU: x where x > 0, else a x, with a learnable slopeweightof one element or one per channel (axis 1 of x, as PyTorch).Tensor.prod()Product of all elements.Tensor.prod(int axis, boolean keepDim) Product alongaxis.static Tensor[]Reduced QR, torch.linalg.qr: Q [..., m, k] and R [..., k, n], k = min(m, n).static TensorA weight in one of GGUF's block-quantised formats (Q8_0, Q4_0, Q4_1, Q4_K, Q5_K, Q6_K, Q5_0, Q5_1, Q2_K, Q3_K) from its raw blocks, as a GGUF file stores them: persistent, so it stays on the device.static TensorF.quantizeQ8(Tensor x) FP32 x (last axis a multiple of 32) quantised to Q8_0, GGUF's 8-bit block format.Tensor.reciprocal()1 / x, element-wise.Tensor.relu()max(x, 0), element-wise.Tensor.relu6()min(max(x, 0), 6).this - floor(this / o) o, with broadcasting: the remainder with the sign of the divisor (torch.remainder).Tensor.requiresGrad(boolean on) Turns gradient tracking on or off for a leaf tensor.Tensor.reshape(int... dims) Same data, new shape; one dimension may be -1.static TensorAn output tensor for an operator; its storage is allocated when the operator runs.static TensorF.reverseSequences(Tensor x, int[] lengths) x [T, B, ...] with each sequence reversed within its length (padding left in place), as a bidirectional layer reads it; lengths null reverses the whole time axis.static Tensortorch.fft.rfft of real x along the last axis, full length, BACKWARD scaling.static Tensortorch.fft.rfft of real x: the n / 2 + 1 non-negative frequencies, complex [..., n / 2 + 1, 2].static Tensortorch.fft.rfft2: rfft over the last axis, then fft over the one before.static TensorF.rgbToGrayscale(Tensor x) RGB images [N, 3, H, W] to luminance [N, 1, H, W] with torchvision's weights (0.2989, 0.587, 0.114).static TensorRMSNorm over the last axis: x / sqrt(mean(x^2) + eps) * weight.static TensorRotary position embedding of x [..., T, D] at positions offset .. offset + T - 1, frequency base^(-2i / D) for pair i.static TensorRotary position embedding of x [..., T, H, D] (the heads of a token share its position); seeF.rope(Tensor, float, int, boolean).static TensorF.ropeHeads(Tensor x, float base, RopeScaling scaling, int offset, boolean interleaved) F.ropeHeads(Tensor, float, int, boolean)with the frequencies rescaled for longer contexts (Llama 3.1's rope_scaling; null for none).Tensor.round()Element-wise rounding to the nearest integer, halves to even (PyTorch's round).static TensorRReLU (Xu et al., 2015): in training, a slope drawn uniformly from [lower, upper) for every element, seeded by the INT32 [2]seedtensor (seeTensor.seed(long)); in evaluation the mean slope (lower + upper) / 2.static TensorTensor.scalar(float value) A rank-0 FP32 tensor holdingvalue.static TensorF.scaledDotProductAttention(Tensor q, Tensor k, Tensor v, Tensor mask, boolean causal, float scale) Scaled dot-product attention, PyTorch semantics: softmax(q k^T * scale + mask) v, for q [..., T, E], k [..., S, E], v [..., S, Ev].static TensorF.scaledDotProductAttentionBTHD(Tensor q, Tensor k, Tensor v, Tensor mask, boolean causal, float scale) Scaled dot-product attention on q [B, T, H, E], k and v [B, S, H, E] (heads after tokens, as the projections produce them), returning [B, T, H, E]; otherwise asF.scaledDotProductAttention(Tensor, Tensor, Tensor, Tensor, boolean, float).torch.scatter: this withsrcwritten atindex(duplicates: the last wins); no gradient.Tensor.scatterAdd(int axis, Tensor index, Tensor src) torch.scatter_add: this withsrcadded atindexalongaxis.static TensorA copy of data with the update slices written ("none"), added ("add") or multiplied ("mul") at the INT32 index rows indices [..., k] (ONNX ScatterND); differentiable for none and add.static TensorTensor.seed(long seed) A 64-bit seed as the INT32 [2] host tensor [lo, hi] that the seeded random operators take.static TensorF.segmentReduce(Tensor x, int[] offsets, F.BagMode mode) Sum, mean or max of the row segments of x [rows, D]: segment b covers rows offsets[b] .. offsets[b + 1] - 1, the last to the end; an empty segment gives zeros.Tensor.selu()SELU with PyTorch's constants (alpha 1.6732632, scale 1.0507010).this << o for INT32 tensors, with broadcasting.Tensor.shiftRight(Tensor o) this >> o (arithmetic: the sign is kept) for INT32 tensors, with broadcasting.Tensor.sigmoid()The logistic sigmoid 1 / (1 + exp(-x)), element-wise.Tensor.sign()Element-wise sign: -1, 0 or 1.Tensor.silu()SiLU (swish): x * sigmoid(x).Tensor.sin()Element-wise sine.Tensor.sinh()Element-wise hyperbolic sine.Tensor.slice(int axis, int start, int end) Elementsstart .. end - 1alongaxis; negative indices count from the end.static Tensor[]torch.linalg.slogdet: [sign, log |det|], each [...]; only the logarithm carries a gradient.static TensorF.smoothL1Loss(Tensor input, Tensor target, float beta, F.Reduction reduction) Smooth L1 loss, PyTorch's smooth_l1_loss: Huber with delta = beta, divided by beta.Tensor.softmax()Softmax along the last axis.Tensor.softplus()Softplus, log(1 + exp(x)) (beta 1), computed without overflow.Tensor.softsign()Softsign: x / (1 + |x|).static TensorSolves A X = B for square A [..., n, n] and B [..., n, k] through LU with partial pivoting.static TensorLinalg.solveTriangular(Tensor t, Tensor b, boolean upper, boolean unitDiagonal) Solves T X = B for triangular T, torch.linalg.solve_triangular (left side): only T'supperor lower triangle is read, and withunitDiagonalnot its diagonal either.Tensor[]Tensor.sort(int axis, boolean descending) Stable sort alongaxis: {values, INT32 original indices}; values carry the gradient.static TensorF.spaceToDepth(Tensor x, int block) Moves blocks of space into channels: x [N, C, H, W] to [N, C b^2, H / b, W / b] (ONNX SpaceToDepth; inverse of DCR depthToSpace).static TensorSparsemax (Martins and Astudillo, 2016) along the last axis: the Euclidean projection onto the probability simplex, max(x - tau, 0) with tau set by the sorted support.Tensor[]Tensor.split(int axis, int... sizes) Splitsaxisinto consecutive pieces of the given sizes.Tensor.sqrt()The square root, element-wise.Tensor.square()x^2, element-wise.static TensorF.squaredHingeLoss(Tensor input, Tensor target, F.Reduction reduction) Squared hinge loss: max(0, 1 - target * input)^2.Tensor.squeeze(int axis) A view without the size-1 axisaxis.static TensorJoins same-shape tensors along a new axis.static Tensortorch.stft(x, nFft, hop, window=window, center, pad_mode="reflect", normalized, onesided=True, return_complex=True) as real pairs: x [L] or [B, L] gives [(B,) nFft / 2 + 1, frames, 2].this - o, element-wise with broadcasting.Tensor.sum()The sum of all elements, as a scalar.Tensor.sum(int axis, boolean keepDim) The sum alongaxis, which is kept with size 1 whenkeepDimis set.Sums broadcast dimensions away so the result hastargetshape (gradient of broadcasting).static Tensor[]Reduced SVD, torch.linalg.svd(full_matrices=False): U [..., m, k], S [..., k] descending and V [..., n, k] (V, not V^T), k = min(m, n).static TensorSingular values (descending), torch.linalg.svdvals.static TensorSwiGLU gating, silu(gate) * up, as in the Llama feed-forward block.Tensor.t()Transpose of a matrix.Tensor.tan()Element-wise tangent.Tensor.tanh()The hyperbolic tangent, element-wise.Tensor.thresholdedRelu(float theta) ThresholdedReLU (Keras): x where x > theta, else 0.Tensor.tile(int... reps) This tensor repeatedreps[i]times along each axis (torch.Tensor.repeat, numpy.tile, ONNX Tile); reps longer than the rank adds leading axes.This tensor converted todtype: between FP32, FP16 and BF16 (round to nearest even; differentiable), or between FP32 and INT32 (truncating toward zero; no gradient).Tensor.toFloat()This tensor converted to FP32 (to(DType.F32)).Tensor[]Tensor.topk(int k) The k largest values along the last axis and their INT32 indices (descending; ties: lower index first).Tensor.transpose(int a, int b) static TensorF.tripletMarginLoss(Tensor anchor, Tensor positive, Tensor negative, float margin, F.Reduction reduction) Triplet margin loss: max(d(anchor, positive) - d(anchor, negative) + margin, 0).Tensor.trunc()Element-wise rounding towards zero.static TensorTensor.uniform(long seed, float lo, float hi, int... dims) Uniform in [lo, hi), from a counter-based generator: the same seed gives the same values everywhere.static TensorAsTensor.uniform(long, float, float, int...)with the seed in an INT32 [2] tensor (seeTensor.seed(long)): a plan replayed with a new seed draws new values without recompiling, so use this for noise drawn every step.static Tensor[]torch.unique (sorted): the distinct values of x, then (when asked for, else null) the INT32 index of each element's value among them, shaped like x, and the INT32 count of each value.Tensor.unsqueeze(int axis) A view with a new size-1 axis ataxis(negative counts from the end of the result).static TensorF.upsampleBilinear(Tensor x, float scale, boolean alignCorners) Bilinear upsampling of x [N, C, H, W] byscale.static TensorF.upsampleNearest(Tensor x, float scale) Nearest-neighbour upsampling of x [N, C, H, W] byscale(PyTorch's mode='nearest').SparseMatrix.Valued.values()Returns the value of thevaluesrecord component.static TensorF.weightNorm(Tensor v, Tensor g) Weight normalisation (Salimans and Kingma): w = g v / ||v|| with the norm over every axis but 0, g of shape [out] (PyTorch's weight_norm with dim 0).static Tensorcond !static TensorTensor.wrap(float[] data, int... dims) A tensor overdataitself, without a copy, as PyTorch'sfrom_numpy: the array is read when the operators that use it run (at the next sync), so it must not change until then, and later reads of the tensor see later changes.static TensorTensor.wrap(int[] data, int... dims) Tensor.wrap(float[], int...)for int data.static TensorTensor.zeros(int... dims) An FP32 tensor of zeros.Methods in ai.beestream.jitnn with parameters of type TensorModifier and TypeMethodDescriptionstatic floatFraction of rows whose argmax equals the label; runs now and returns a host value.static TensorF.adaptiveAvgPool(Tensor x, int... out) Adaptive average pooling of x [N, C, ...] (1 to 3 spatial axes) to the given output sizes (PyTorch's bins).static TensorF.adaptiveMaxPool(Tensor x, int... out) Adaptive max pooling of x [N, C, ...] (1 to 3 spatial axes) to the given output sizes.this + o, element-wise with broadcasting.static TensorA tensor that sharesbase's storage under another shape.Applies the operator with integer and float attributes (part of the plan's cache key); returns its first output.Applies the operator; returns its first output.Tensor[]The gradient of each input ofnode(null where none is needed), from the gradientgradOutof its first output.Tensor[][dL/da, dL/db], from the inputs a and b, the output y and dL/dy.dL/dx, from the input x, the output y and dL/dy.Tensor[]Applies the operator; returns all its outputs.voidRecords a copy ofsrcinto this persistent FP32 tensor of the same size (a running statistic, an optimiser buffer): later operators see the new values.atan2(this, o), the angle of the point (o, this), with broadcasting.static TensorF.attentionSoftmax(Tensor scores, float scale, boolean causal) softmax(scores * scale) over the last axis of attention scores [..., T, S], in one kernel;causal: query t sees keys 0 .. t, as PyTorch'sis_causal.static TensorAverage pooling of x [N, C, L], PyTorch's avg_pool1d; padding counts in the divisor, as PyTorch's default.static TensorAverage pooling of x [N, C, H, W] over square windows, PyTorch's avg_pool2d; padding counts in the divisor, as PyTorch's default.static TensorAverage pooling of x [N, C, D, H, W] over cubic windows, PyTorch's avg_pool3d; padding counts in the divisor.voidBack-propagates from this tensor withgradient(its shape) as the gradient of the result.static TensorF.batchNorm(Tensor x, Tensor runningMean, Tensor runningVar, Tensor weight, Tensor bias, boolean training, float momentum, float eps) Batch normalisation of an NCHW (or NC) tensor.static TensorF.batchNormRelu(Tensor x, Tensor runningMean, Tensor runningVar, Tensor weight, Tensor bias, boolean training, float momentum, float eps) relu(batchNorm(...)), fused.static TensorF.binaryCrossEntropy(Tensor p, Tensor target) Binary cross-entropy of probabilitiespin [0, 1] againsttarget, PyTorch semantics: the logs are clamped at -100, so p = 0 or 1 gives finite values and gradients.static TensorF.binaryCrossEntropy(Tensor p, Tensor target, F.Reduction reduction) F.binaryCrossEntropy(Tensor, Tensor)reduced asreductionsays.static TensorF.binaryCrossEntropyWithLogits(Tensor logits, Tensor target) Binary cross-entropy on logits, sigmoid folded in without overflow (PyTorch's BCEWithLogits).static TensorF.binaryCrossEntropyWithLogits(Tensor logits, Tensor target, F.Reduction reduction) F.binaryCrossEntropyWithLogits(Tensor, Tensor)reduced asreductionsays.Tensor.bitwiseAnd(Tensor o) Bitwise and of INT32 tensors, with broadcasting.Bitwise or of INT32 tensors, with broadcasting.Tensor.bitwiseXor(Tensor o) Bitwise exclusive or of INT32 tensors, with broadcasting.static TensorJoins tensors along an existing axis.static TensorF.centerCrop(Tensor x, int height, int width) The central height x width window of images [..., H, W] (torchvision's center_crop, top-left rounding down).static TensorGrad.checkpoint(Function<Tensor[], Tensor> segment, Tensor... inputs) Activation checkpointing, as PyTorch'storch.utils.checkpoint: runssegmentoninputsand keeps none of its activations for the backward pass, which runs the segment again to get them.static TensorLower Cholesky factor L, A = L L^T, of symmetric positive-definite matrices (only the lower triangle is read).static TensorF.contrastiveLoss(Tensor a, Tensor b, Tensor similar, float margin, F.Reduction reduction) Contrastive loss (Hadsell et al., 2006) withsimilar1 for similar pairs and 0 for dissimilar ones: similar d^2 + (1 - similar) max(margin - d, 0)^2.static TensorConvolution over 1 to 3 spatial axes with a size per axis:padsholds the padding before every axis, then after every axis (ONNX's order), so it may be asymmetric.static Tensor1-D convolution of x [N, C, L] with weight [Cout, C, K]; bias may be null.static TensorGrouped 1-D convolution: weight [Cout, C / groups, K]; groups = C is depthwise.static Tensor2-D convolution (NCHW), square kernel; bias may be null.static TensorF.conv2dRelu(Tensor x, Tensor weight, Tensor bias, int stride, int padding, int dilation, int groups) relu(conv2d(...)) with the bias and ReLU fused into the convolution's output.static Tensor3-D convolution of x [N, C, D, H, W] with weight [Cout, C, KD, KH, KW]; bias may be null.static TensorGrouped 3-D convolution: weight [Cout, C / groups, KD, KH, KW].static TensorF.convTranspose2d(Tensor x, Tensor weight, Tensor bias, int stride, int padding, int outputPadding, int dilation, int groups) Transposed 2-D convolution (NCHW), PyTorch's conv_transpose2d: weight [Cin, Cout/groups, K, K], square kernel; bias may be null.static TensorF.cosineEmbeddingLoss(Tensor a, Tensor b, Tensor target, float margin, F.Reduction reduction) Cosine embedding loss: 1 - cos(a, b) for target 1, max(0, cos(a, b) - margin) for -1.static TensorF.cosineProximityLoss(Tensor input, Tensor target, F.Reduction reduction) Cosine proximity loss (DL4J, Keras): minus the cosine similarity along the last axis, reduced.static TensorF.cosineSimilarity(Tensor a, Tensor b, int axis, float eps) Cosine similarity alongaxis: a . b / (max(|a|, eps) max(|b|, eps)), PyTorch's cosine_similarity.static TensorF.crossEntropy(Tensor logits, Tensor labels) Mean cross-entropy betweenlogits[N, C] and INT32 class labels [N] (fused kernels).static TensorF.ctcLoss(Tensor logProbs, Tensor targets, int[] inputLengths, int[] targetLengths, int blank, F.Reduction reduction) CTC loss, PyTorch's ctc_loss: log-probabilities [T, B, C] (log_softmax over C), INT32 targets [B, L] padded, input and target lengths; blank indexblank.static TensorThe firstlengthentries of dimensionaxisoft, copied on the host (a device result is read back first).static TensorF.depthToSpace(Tensor x, int block, String mode) Moves blocks of channels into space: x [N, C, H, W] to [N, C / b^2, H b, W b].static TensorF.dequantize(Tensor q) A Q8_0 tensor back to FP32.static TensorDeterminants [...] of square matrices.this / o, element-wise with broadcasting.static TensorInverted dropout with a fresh mask per step:seedis an INT32 [2] host tensor.static Tensor[]Eigenvalues (ascending) [..., n] and eigenvectors (columns) [..., n, n] of symmetric matrices, torch.linalg.eigh.static TensorEigenvalues (ascending) of symmetric matrices, torch.linalg.eigvalsh.static TensorRows ofweight[V, D] picked by the INT32index: shape index.shape + [D].static TensorAsF.embedding(Tensor, Tensor); rowpaddingIdxreceives no gradient.static TensorF.embeddingBag(Tensor indices, int[] offsets, Tensor weight, F.BagMode mode) EmbeddingBag (PyTorch's, 1-D input with offsets): the rows ofweightpicked by the INT32indices, combined per bag bymode.1 where this == o, else 0, with broadcasting.static TensorTensor.eye(int, int, int)with the shape of the rank-2 tensorlike(ONNX EyeLike).static TensorF.fakeQuantize(Tensor x, float scale, float lowest, int bits) Quantises x tobits(8 or 16) bits and back: clamp(round_half_even(x / scale), lowest, lowest + 2^bits - 1) * scale,lowestbeing the lowest code minus the zero point (ONNX QuantizeLinear followed by DequantizeLinear).static Tensortorch.fft.fft of complex x along the last axis, full length, BACKWARD scaling.static Tensortorch.fft.fft of complex x [..., 2]; n > 0 crops or zero-pads axisdimto n.static Tensortorch.fft.fft2: the transform over the last two complex axes.static Tensorx reversed along each ofaxes(torch.flip).Element-wise maximum ignoring a NaN operand (torch.fmax).Element-wise minimum ignoring a NaN operand (torch.fmin).this - trunc(this / o) o, with broadcasting: the remainder with the sign of the dividend (torch.fmod).static TensorFolds columns back into an image, summing overlaps (torch fold, ONNX Col2Im); seeSpatial.fold.torch.gather alongaxiswith an INT32 index of this shape except along the axis.static TensorSlices of data picked by INT32 index rows indices [..., k] (ONNX GatherND, batch_dims 0); differentiable in data.static TensorF.gaussianKl(Tensor mu, Tensor logvar) KL divergence of N(mu, exp(logvar)) from N(0, 1), summed over every element: -0.5 * sum(1 + logvar - mu^2 - exp(logvar)), the VAE regulariser.1 where this >= o, else 0, with broadcasting.static TensorF.globalAvgPool2d(Tensor x) Mean over the spatial dimensions: [N, C, H, W] to [N, C].static TensorGloVe's weighted least squares (Pennington et al., 2014) over a batch of co-occurrences: mean of weight (wi . wj + bi + bj - logX)^2, with wi, wj [B, D] and the rest [B].static TensorGroupNorm (Wu and He) of x [N, C, ...] ingroupsgroups of channels: each (sample, group) normalised over its channels and positions, then a per-channel affine (weight and bias may be null, as PyTorch with affine=False).static Tensor[]One GRU layer over x [T, B, I] (time first), PyTorch's equations and gate order (r, z, n): wih [3H, I], whh [3H, H], biases [3H], h0 [B, H].static Tensor[]AsF.gru(Tensor, Tensor, Tensor, Tensor, Tensor, Tensor)for padded batches oflengths.1 where this > o, else 0, with broadcasting.static TensorF.hingeLoss(Tensor input, Tensor target, F.Reduction reduction) Hinge loss with targets in {-1, 1}: max(0, 1 - target * input), Keras's hinge (mean).static TensorF.huberLoss(Tensor input, Tensor target, float delta, F.Reduction reduction) Huber loss with thresholddelta: 0.5 d^2 where |d| < delta, else delta (|d| - delta / 2), d = input - target (PyTorch's huber_loss).static Tensortorch.fft.ifft of complex x along the last axis, full length, BACKWARD scaling (1/n).static Tensortorch.fft.ifft.static Tensortorch.fft.ifft2.Tensor.indexSelect(int axis, Tensor idx) Elements idx[0 .. m-1] (INT32 [m]) ofaxis, torch.index_select.static TensorF.instanceNorm(Tensor x, Tensor weight, Tensor bias, float eps) InstanceNorm: GroupNorm with one channel per group (affine when weight and bias are given).static TensorF.interpolate(Tensor x, int height, int width, boolean bilinear, boolean alignCorners) Resizes x [N, C, H, W] to [N, C, height, width], nearest or bilinear (PyTorch's interpolate with size).static TensorInverse of square matrices.static Tensortorch.fft.irfft along the last axis: a real signal of length 2 (m - 1), BACKWARD scaling (1/n).static Tensortorch.fft.irfft: the real signal of length n (default 2 (m - 1)) whose spectrum's non-negative half is x [..., m, 2]; the imaginary parts at frequency 0 and n / 2 are ignored.static TensorFft.istft(Tensor x, int nFft, int hop, Tensor window, boolean center, boolean normalized, int length) torch.istft(x, nFft, hop, window=window, center, normalized, onesided=True, length): x [(B,) nFft / 2 + 1, frames, 2] back to [(B,) length] (length <= 0: as long as the frames reach, less the centre padding), by overlap-add divided by the summed squared window.static TensorMarkstas read by the caller: its buffer is never reused.static TensorF.l1Loss(Tensor input, Tensor target, F.Reduction reduction) Mean absolute error (L1), PyTorch's l1_loss.static TensorLayerNorm over the last axis: (x - mean) / sqrt(var + eps) * weight + bias (bias may be null).1 where this <= o, else 0, with broadcasting.static Tensory = x W^T + b, with W stored [out, in] and b of shape [out] (b may be null); one fused GEMM. x may have any leading dimensions: [..., in] gives [..., out].static Tensory = x W^T + b with Q8_0 weights W [out, in]; the gradient reaches x, not W.static TensorF.linearRelu(Tensor x, Tensor weight, Tensor bias) relu(x W^T + b), with the bias and ReLU fused into the GEMM epilogue.static TensorF.localResponseNorm(Tensor x, int size, float alpha, float beta, float k) Local response normalisation across channels, PyTorch's local_response_norm (k 1, alpha 1e-4, beta 0.75 by default).Tensor.logicalAnd(Tensor o) 1 where both are non-zero, with broadcasting.1 where either is non-zero, with broadcasting.Tensor.logicalXor(Tensor o) 1 where exactly one is non-zero, with broadcasting.static TensorF.logSigmoid(Tensor x) log sigmoid(x) = -softplus(-x), without overflow.static TensorF.lpNormalize(Tensor x, int p, int axis, float eps) x / max(||x||_p, eps) alongaxis, p = 1 or 2 (torch.nn.functional.normalize; ONNX LpNormalization with eps 0).static Tensor[]One LSTM layer over x [T, B, I] (time first), PyTorch's equations and gate order (i, f, g, o): wih [4H, I], whh [4H, H], biases [4H], h0 and c0 [B, H].static Tensor[]F.lstm(Tensor x, Tensor wih, Tensor whh, Tensor bih, Tensor bhh, Tensor h0, Tensor c0, int[] lengths) AsF.lstm(Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor)for padded batches: INT32lengths[B] (null: all T); outputs past a sequence's length are 0 and h_n, c_n are each sequence's last valid state.1 where this < o, else 0, with broadcasting.static Tensor[]P, L, U with A = P L U, torch.linalg.lu for square matrices.static Tensor[]LU factorisation with partial pivoting, torch.linalg.lu_factor: the packed factors (L unit lower below the diagonal, U on and above) and INT32 row indices perm, with row i of P^T A being row perm[i] of A (0-based, unlike LAPACK's swap list).static TensorF.mapeLoss(Tensor input, Tensor target, F.Reduction reduction) Mean absolute percentage error: 100 |target - input| / max(|target|, eps) (Keras's MAPE, eps 1e-7).static TensorF.marginRankingLoss(Tensor x1, Tensor x2, Tensor target, float margin, F.Reduction reduction) Margin ranking loss: max(0, -target (x1 - x2) + margin), target 1 or -1.Tensor.maskedSelect(Tensor mask) The elements wheremask(broadcast) is not zero, as a vector (torch.masked_select); reads the count back to the host.The matrix product this b: [M, K] x [K, N] to [M, N], or batched over leading axes, which must match unless one side is a plain matrix shared by every batch.op(this) * op(b), where op transposes when the flag is set, without materialising the transpose.The element-wise maximum of this and o, with broadcasting (Tensor.maximumNaN(Tensor)propagates NaN).Tensor.maximumNaN(Tensor o) Element-wise maximum propagating NaN (torch.maximum).static TensorMax pooling of x [N, C, L] over windows ofkernelwith the given stride and padding (padding never wins), PyTorch's max_pool1d.static TensorMax pooling of x [N, C, H, W] over square windows ofkernelwith the given stride and padding, PyTorch's max_pool2d.static TensorMax pooling of x [N, C, D, H, W] over cubic windows ofkernel(padding never wins), PyTorch's max_pool3d.The element-wise minimum of this and o, with broadcasting (Tensor.minimumNaN(Tensor)propagates NaN).Tensor.minimumNaN(Tensor o) Element-wise minimum propagating NaN (torch.minimum).A dense with A's stored valuesvalues[nnz] (coordinate order); dense [cols, feat] gives [rows, feat].This matrix times dense [cols, feat].static TensorMean squared error betweeninputandtarget(same shape).static TensorF.mseLoss(Tensor input, Tensor target, F.Reduction reduction) Squared error betweeninputandtarget(same shape), reduced asreductionsays.static TensorF.msleLoss(Tensor input, Tensor target, F.Reduction reduction) Mean squared logarithmic error: (log1p(input) - log1p(target))^2 (Keras's MSLE).this * o, element-wise with broadcasting.static TensorF.multiHeadAttention(Tensor x, Tensor wqkv, Tensor bqkv, Tensor wout, Tensor bout, int heads, Tensor mask, boolean causal) Multi-head self-attention on x [B, T, D], as PyTorch'snn.MultiheadAttentionwith batch_first: q, k, v = split(x Wqkv^T + bqkv),headsheads, then the output projection.static TensorF.multinomial(Tensor weights, Tensor seed, int stream) One INT32 index per row of non-negative weights [..., V] (probabilities, or any unnormalised weights), drawn in proportion to the weight.1 where this !static TensorF.negativeSamplingLoss(Tensor hidden, Tensor target, Tensor negatives) Negative-sampling loss of word2vec (Mikolov et al., 2013): hidden [B, D] (the centre word, or the averaged context), target [B, D] (the output vector of the true word) and negatives [B, K, D] (output vectors of sampled words); mean over B of -log sigmoid(h . t) - sum_k log sigmoid(-h . n_k).static TensorPer-sample negative log-likelihood of INT32labelsunder log-probabilitieslogp.static TensorF.nllLoss(Tensor logp, Tensor labels, F.Reduction reduction) Negative log-likelihood of INT32 labels under log-probabilities [N, C], reduced.static Tensortorch.nonzero_static: INT32 coordinates [size, rank] of the firstsizenon-zero elements, the rest of the rowsfill.static TensorAsTensor.normal(long, float, float, int...)with the seed in an INT32 [2] tensor.static TensorF.normalizeImage(Tensor x, float[] mean, float[] std) Normalises images x [N, C, H, W] per channel: (x - mean[c]) / std[c], as torchvision's Normalize.The output's shape for these inputs and integer attributes.static TensorINT32 labels [...] to a one-hot [..., classes].static Tensortwith dimensionaxisgrown tosize, the new elements set tovalue; built on the host (a device result is read back first).static TensorPads the spatial axes of x [N, C, ...]:before[k]andafter[k]elements on spatial axis k, PyTorch's F.pad for constant, reflect and replicate modes.static TensorF.pairwiseDistance(Tensor a, Tensor b) Euclidean distance of each row pair (last axis), PyTorch's pairwise_distance with eps 1e-6.static TensorA trainable parameter: persistent storage (it stays on the device across steps), gradient tracking on, initialised with the values ofinit.static TensorTensor.persistent(Tensor init) Persistent storage without gradient tracking (optimiser state, running statistics).static TensorF.poissonNllLoss(Tensor input, Tensor target, boolean logInput, float eps, F.Reduction reduction) Poisson negative log-likelihood, PyTorch's poisson_nll_loss without the Stirling term: exp(input) - target input withlogInput, else input - target log(input + eps).static TensorF.pool(Tensor x, F.PoolMode mode, int[] kernel, int[] stride, int[] pads, int[] dilation, boolean ceil, boolean countIncludePad, float p) Pooling over 1 to 3 spatial axes of x [N, C, ...] with a size per axis, as ONNX's MaxPool, AveragePool and LpPool and PyTorch's pooling layers:padsholds the padding before every axis, then after every axis;ceilrounds the output size up (a window must still start inside the input or its leading padding); average pooling counts the padding whencountIncludePad(never the positions added byceil); LP pooling computes (sum |x|^p)^(1/p).x^exponent, element-wise, with broadcasting.static TensorPReLU: x where x > 0, else a x, with a learnable slopeweightof one element or one per channel (axis 1 of x, as PyTorch).static Tensor[]Reduced QR, torch.linalg.qr: Q [..., m, k] and R [..., k, n], k = min(m, n).static TensorF.quantizeQ8(Tensor x) FP32 x (last axis a multiple of 32) quantised to Q8_0, GGUF's 8-bit block format.static voidTensor.record(ai.beestream.jitnn.engine.Op op, Tensor[] inputs, Tensor[] outputs, int[] iattr, float[] fattr, boolean traced) Records an operator application.this - floor(this / o) o, with broadcasting: the remainder with the sign of the divisor (torch.remainder).static TensorF.reverseSequences(Tensor x, int[] lengths) x [T, B, ...] with each sequence reversed within its length (padding left in place), as a bidirectional layer reads it; lengths null reverses the whole time axis.static Tensortorch.fft.rfft of real x along the last axis, full length, BACKWARD scaling.static Tensortorch.fft.rfft of real x: the n / 2 + 1 non-negative frequencies, complex [..., n / 2 + 1, 2].static Tensortorch.fft.rfft2: rfft over the last axis, then fft over the one before.static TensorF.rgbToGrayscale(Tensor x) RGB images [N, 3, H, W] to luminance [N, 1, H, W] with torchvision's weights (0.2989, 0.587, 0.114).static TensorRMSNorm over the last axis: x / sqrt(mean(x^2) + eps) * weight.static TensorRotary position embedding of x [..., T, D] at positions offset .. offset + T - 1, frequency base^(-2i / D) for pair i.static TensorRotary position embedding of x [..., T, H, D] (the heads of a token share its position); seeF.rope(Tensor, float, int, boolean).static TensorF.ropeHeads(Tensor x, float base, RopeScaling scaling, int offset, boolean interleaved) F.ropeHeads(Tensor, float, int, boolean)with the frequencies rescaled for longer contexts (Llama 3.1's rope_scaling; null for none).static TensorRReLU (Xu et al., 2015): in training, a slope drawn uniformly from [lower, upper) for every element, seeded by the INT32 [2]seedtensor (seeTensor.seed(long)); in evaluation the mean slope (lower + upper) / 2.static TensorF.scaledDotProductAttention(Tensor q, Tensor k, Tensor v, Tensor mask, boolean causal, float scale) Scaled dot-product attention, PyTorch semantics: softmax(q k^T * scale + mask) v, for q [..., T, E], k [..., S, E], v [..., S, Ev].static TensorF.scaledDotProductAttentionBTHD(Tensor q, Tensor k, Tensor v, Tensor mask, boolean causal, float scale) Scaled dot-product attention on q [B, T, H, E], k and v [B, S, H, E] (heads after tokens, as the projections produce them), returning [B, T, H, E]; otherwise asF.scaledDotProductAttention(Tensor, Tensor, Tensor, Tensor, boolean, float).torch.scatter: this withsrcwritten atindex(duplicates: the last wins); no gradient.Tensor.scatterAdd(int axis, Tensor index, Tensor src) torch.scatter_add: this withsrcadded atindexalongaxis.static TensorA copy of data with the update slices written ("none"), added ("add") or multiplied ("mul") at the INT32 index rows indices [..., k] (ONNX ScatterND); differentiable for none and add.static TensorF.segmentReduce(Tensor x, int[] offsets, F.BagMode mode) Sum, mean or max of the row segments of x [rows, D]: segment b covers rows offsets[b] .. offsets[b + 1] - 1, the last to the end; an empty segment gives zeros.voidReplaces the gradient of this leaf tensor (same shape), for example by its average over data-parallel ranks before the optimiser step.this << o for INT32 tensors, with broadcasting.Tensor.shiftRight(Tensor o) this >> o (arithmetic: the sign is kept) for INT32 tensors, with broadcasting.static Tensor[]torch.linalg.slogdet: [sign, log |det|], each [...]; only the logarithm carries a gradient.static TensorF.smoothL1Loss(Tensor input, Tensor target, float beta, F.Reduction reduction) Smooth L1 loss, PyTorch's smooth_l1_loss: Huber with delta = beta, divided by beta.static TensorSolves A X = B for square A [..., n, n] and B [..., n, k] through LU with partial pivoting.static TensorLinalg.solveTriangular(Tensor t, Tensor b, boolean upper, boolean unitDiagonal) Solves T X = B for triangular T, torch.linalg.solve_triangular (left side): only T'supperor lower triangle is read, and withunitDiagonalnot its diagonal either.static TensorF.spaceToDepth(Tensor x, int block) Moves blocks of space into channels: x [N, C, H, W] to [N, C b^2, H / b, W / b] (ONNX SpaceToDepth; inverse of DCR depthToSpace).static TensorSparsemax (Martins and Astudillo, 2016) along the last axis: the Euclidean projection onto the probability simplex, max(x - tau, 0) with tau set by the sorted support.static TensorF.squaredHingeLoss(Tensor input, Tensor target, F.Reduction reduction) Squared hinge loss: max(0, 1 - target * input)^2.static TensorJoins same-shape tensors along a new axis.static Tensortorch.stft(x, nFft, hop, window=window, center, pad_mode="reflect", normalized, onesided=True, return_complex=True) as real pairs: x [L] or [B, L] gives [(B,) nFft / 2 + 1, frames, 2].this - o, element-wise with broadcasting.static Tensor[]Reduced SVD, torch.linalg.svd(full_matrices=False): U [..., m, k], S [..., k] descending and V [..., n, k] (V, not V^T), k = min(m, n).static TensorSingular values (descending), torch.linalg.svdvals.static TensorSwiGLU gating, silu(gate) * up, as in the Llama feed-forward block.static voidRuns everything recorded on this thread, fetchingwantedto the host.static TensorF.tripletMarginLoss(Tensor anchor, Tensor positive, Tensor negative, float margin, F.Reduction reduction) Triplet margin loss: max(d(anchor, positive) - d(anchor, negative) + margin, 0).static TensorAsTensor.uniform(long, float, float, int...)with the seed in an INT32 [2] tensor (seeTensor.seed(long)): a plan replayed with a new seed draws new values without recompiling, so use this for noise drawn every step.static Tensor[]torch.unique (sorted): the distinct values of x, then (when asked for, else null) the INT32 index of each element's value among them, shaped like x, and the INT32 count of each value.static TensorF.upsampleBilinear(Tensor x, float scale, boolean alignCorners) Bilinear upsampling of x [N, C, H, W] byscale.static TensorF.upsampleNearest(Tensor x, float scale) Nearest-neighbour upsampling of x [N, C, H, W] byscale(PyTorch's mode='nearest').static TensorF.weightNorm(Tensor v, Tensor g) Weight normalisation (Salimans and Kingma): w = g v / ||v|| with the norm over every axis but 0, g of shape [out] (PyTorch's weight_norm with dim 0).static Tensorcond !Method parameters in ai.beestream.jitnn with type arguments of type TensorModifier and TypeMethodDescriptionstatic TensorGrad.checkpoint(Function<Tensor[], Tensor> segment, Tensor... inputs) Activation checkpointing, as PyTorch'storch.utils.checkpoint: runssegmentoninputsand keeps none of its activations for the backward pass, which runs the segment again to get them.static TensorRescales the gradients ofparamsso that their global L2 norm is at mostmaxNorm, as PyTorch'sclip_grad_norm_: every gradient is multiplied by min(1, maxNorm / (norm + 1e-6)).static TensorRuns a forward pass for inference: no gradient recording, and every tensor created inside except the returned one is internal, so its buffer is reused as soon as the computation no longer needs it.voidTensor.onGradReady(Consumer<Tensor> hook) Callshookwith this leaf tensor (a parameter) during each backward pass, as soon as its gradient is final: after the last operator that contributes to it, while the rest of the backward pass is still being recorded.Constructors in ai.beestream.jitnn with parameters of type TensorModifierConstructorDescriptionValued(SparseMatrix matrix, Tensor values) Creates an instance of aValuedrecord class. -
Uses of Tensor in ai.beestream.jitnn.data
Methods in ai.beestream.jitnn.data that return TensorModifier and TypeMethodDescriptionDataLoader.Batch.x()Returns the value of thexrecord component.DataLoader.Batch.y()Returns the value of theyrecord component.Constructors in ai.beestream.jitnn.data with parameters of type Tensor -
Uses of Tensor in ai.beestream.jitnn.dist
Methods in ai.beestream.jitnn.dist that return TensorModifier and TypeMethodDescriptiondefault Tensor[]Collective.allReduced(int rank, Tensor[] tensors, Collective.ReduceOp op) The reduction over all ranks of each tensor.Tensor[]NcclCollective.allReduced(int rank, Tensor[] tensors, Collective.ReduceOp op) The reduction over the ranks of each tensor, as new tensors: one NCCL call for all of them.default Tensor[]Collective.finishAllReduce(int rank, Tensor[] tensors, Tensor buffer, Collective.ReduceOp op, int tag) The results ofCollective.startAllReduce(int, Tensor[], Tensor, Collective.ReduceOp, int)(same tensors, buffer and tag), asCollective.allReduced(int, Tensor[], Collective.ReduceOp)returns them.Tensor[]NcclCollective.finishAllReduce(int rank, Tensor[] tensors, Tensor buffer, Collective.ReduceOp op, int tag) Waits for the all-reduce started withtagand unpacks it into new tensors.Methods in ai.beestream.jitnn.dist with parameters of type TensorModifier and TypeMethodDescriptionvoidinput [n, ...] on every rank; output [worldSize * n, ...] receives every rank's input, in rank order.voidvoidPersistentoutput[world * n, ...] receives every rank's input [n, ...], in rank order.voidCollective.allReduce(int rank, Tensor tensor, Collective.ReduceOp op) Every rank's tensor replaced, in place, by the reduction over all ranks.voidHostCollective.allReduce(int rank, Tensor tensor, Collective.ReduceOp op) voidNcclCollective.allReduce(int rank, Tensor tensor, Collective.ReduceOp op) Persistenttensorreplaced, on every rank, by the reduction over the ranks.default Tensor[]Collective.allReduced(int rank, Tensor[] tensors, Collective.ReduceOp op) The reduction over all ranks of each tensor.Tensor[]NcclCollective.allReduced(int rank, Tensor[] tensors, Collective.ReduceOp op) The reduction over the ranks of each tensor, as new tensors: one NCCL call for all of them.voidEvery rank's tensor replaced, in place, by rankroot's.voidvoidPersistenttensorreplaced, on every rank, by rankroot's.default Tensor[]Collective.finishAllReduce(int rank, Tensor[] tensors, Tensor buffer, Collective.ReduceOp op, int tag) The results ofCollective.startAllReduce(int, Tensor[], Tensor, Collective.ReduceOp, int)(same tensors, buffer and tag), asCollective.allReduced(int, Tensor[], Collective.ReduceOp)returns them.Tensor[]NcclCollective.finishAllReduce(int rank, Tensor[] tensors, Tensor buffer, Collective.ReduceOp op, int tag) Waits for the all-reduce started withtagand unpacks it into new tensors.voidCollective.reduceScatter(int rank, Tensor input, Tensor output, Collective.ReduceOp op) input [worldSize * n, ...] on every rank; output [n, ...] receives on rank r the reduction of every rank's r-th slice.voidHostCollective.reduceScatter(int rank, Tensor input, Tensor output, Collective.ReduceOp op) voidNcclCollective.reduceScatter(int rank, Tensor input, Tensor output, Collective.ReduceOp op) Persistentoutput[n, ...] receives the reduction of every rank's slice r of input [world * n, ...].default voidCollective.startAllReduce(int rank, Tensor[] tensors, Tensor buffer, Collective.ReduceOp op, int tag) Starts the reduction over all ranks oftensors, packed into the persistentbuffer(exactly their total size), so that it runs while the operators recorded after it do: NCCL runs it on a stream of its own.voidNcclCollective.startAllReduce(int rank, Tensor[] tensors, Tensor buffer, Collective.ReduceOp op, int tag) Packstensorsinto persistentbufferand starts its all-reduce on NCCL's side stream (seeCollective.startAllReduce(int, Tensor[], Tensor, Collective.ReduceOp, int)). -
Uses of Tensor in ai.beestream.jitnn.djl
Methods in ai.beestream.jitnn.djl that return TensorModifier and TypeMethodDescriptionJitnnNDArray.tensor()The jitNN tensor behind this array (FP32).Methods in ai.beestream.jitnn.djl with parameters of type TensorModifier and TypeMethodDescriptionWraps a jitNN tensor as an array of this manager. -
Uses of Tensor in ai.beestream.jitnn.engine
Fields in ai.beestream.jitnn.engine declared as TensorModifier and TypeFieldDescriptionfinal Tensor[]Node.inputsThe operator's inputs.final Tensor[]Node.outputsThe operator's outputs.Methods in ai.beestream.jitnn.engine that return TensorMethods in ai.beestream.jitnn.engine with parameters of type TensorModifier and TypeMethodDescriptionuk.ac.manchester.tornado.api.types.arrays.ShortArraybfloat16 tensors are stored as their raw 16-bit patterns.uk.ac.manchester.tornado.api.types.arrays.ByteArrayGGUF block-quantised tensors: their raw blocks.uk.ac.manchester.tornado.api.types.arrays.HalfFloatArrayThe device array of FP16 tensort.uk.ac.manchester.tornado.api.types.arrays.FloatArrayThe device array of FP32 tensort, to pass to a kernel.uk.ac.manchester.tornado.api.types.arrays.ByteArrayFP8 tensors: one byte per value.uk.ac.manchester.tornado.api.types.arrays.IntArrayThe device array of INT32 tensort.uk.ac.manchester.tornado.api.types.arrays.ByteArrayQ8_0 tensors: GGUF's 34-byte blocks of 32 values.booleanTrue when nothing readstafter this plan: an internal output (no user code holds it) that no later operator of the trace consumes and that was not requested.Constructors in ai.beestream.jitnn.engine with parameters of type Tensor -
Uses of Tensor in ai.beestream.jitnn.gguf
Methods in ai.beestream.jitnn.gguf that return TensorModifier and TypeMethodDescriptionTensornameas a persistent jitNN tensor, memory-mapped where possible (see the class comment).Tensorname;copyreads it into memory instead of mapping it.Methods in ai.beestream.jitnn.gguf that return types with arguments of type Tensor -
Uses of Tensor in ai.beestream.jitnn.io
Methods in ai.beestream.jitnn.io that return TensorModifier and TypeMethodDescriptionTensornameas a new persistent tensor (a weight that stays on the device).Methods in ai.beestream.jitnn.io with parameters of type TensorModifier and TypeMethodDescriptionvoidvoidOverwrites the persistent tensortarget(a parameter, a buffer, optimiser state) with tensorname, in place, so plans compiled withtargetkeep using it.Adds a tensor; its contents are read when the dictionary is saved. -
Uses of Tensor in ai.beestream.jitnn.ml
Methods in ai.beestream.jitnn.ml that return TensorModifier and TypeMethodDescriptionKMeans.centres()The cluster centres [k, features].LinearRegression.coef()Coefficients [d] (one target) or [t, d].LinearSvc.coef()The weights: [1, features] for two classes, else [classes, features].LogisticRegression.coef()Coefficients [1, d] for two classes, [c, d] otherwise.Pca.components()The components [k, d].GradientBoosting.decisionFunction(Tensor x) Raw scores [m, outputs]: the baseline plus every tree.LinearSvc.decisionFunction(Tensor x) The decision values x w^T + b of each sample.LogisticRegression.decisionFunction(Tensor x) The decision values x W^T + b of each sample.NaiveBayes.featureLogProb()Multinomial: the per-class log probabilities of the features [classes, features].Tsne.fitTransform(Tensor x) The embedding [n, components] of samples x [n, features], starting from their PCA projection.LinearRegression.intercept()The fitted intercept (zero without one).LinearSvc.intercept()The intercepts, one per row ofLinearSvc.coef().LogisticRegression.intercept()The intercepts, one per row of the weights.Pca.inverseTransform(Tensor z) Back from the projection to the feature space.NaiveBayes.jointLogLikelihood(Tensor x) Joint log-likelihood [m, c].KNeighbors.kneighbors(Tensor q) INT32 indices [m, k] of the k nearest training rows of each query row.Predictions x w + b for samples x [n, features].GradientBoosting.predictProba(Tensor x) Class probabilities [n, classes] for samples x.KNeighbors.predictProba(Tensor q) Class probabilities [m, c]: the fraction of neighbours per class.LogisticRegression.predictProba(Tensor x) Class probabilities [m, c].NaiveBayes.predictProba(Tensor x) Class probabilities [n, classes] for samples x.GradientBoosting.predictValues(Tensor x) Regression predictions [m].KNeighbors.predictValues(Tensor q) Regression predictions [m, t].RandomForest.predictValues(Tensor x) Mean of the trees' leaf values: class probabilities [m, c] or predictions [m, 1].NaiveBayes.theta()Gaussian: the per-class feature means [classes, features].Projection [n, k] of x onto the components.NaiveBayes.var()Gaussian: the per-class feature variances [classes, features], smoothed.Methods in ai.beestream.jitnn.ml with parameters of type TensorModifier and TypeMethodDescriptionGradientBoosting.decisionFunction(Tensor x) Raw scores [m, outputs]: the baseline plus every tree.LinearSvc.decisionFunction(Tensor x) The decision values x w^T + b of each sample.LogisticRegression.decisionFunction(Tensor x) The decision values x W^T + b of each sample.Fits a classifier to samples x [n, features] and labels y.Regression targets [n].Fits from k-means++ seeds.Fits from the given initial centres [k, d].Classification: integer labels.Regression: targets [n] or [n, t].y [n] or [n, t].Fits samples x [n, features] and labels y.Fits samples x [n, features] and labels y.Fits samples x [n, features] (counts for the multinomial kind) and labels y.Fits samples x [n, features].Fits a classifier to samples x [n, features] and labels y.Regression targets [n].Tsne.fitTransform(Tensor x) The embedding [n, components] of samples x [n, features], starting from their PCA projection.Pca.inverseTransform(Tensor z) Back from the projection to the feature space.NaiveBayes.jointLogLikelihood(Tensor x) Joint log-likelihood [m, c].KNeighbors.kneighbors(Tensor q) INT32 indices [m, k] of the k nearest training rows of each query row.int[]The most probable label of each sample.int[]Index of the nearest centre of each row.int[]The majority label of each query's neighbours (a classifier'sfitonly).Predictions x w + b for samples x [n, features].int[]The predicted label of each sample.int[]The most probable label of each sample.int[]The most probable label of each sample.int[]The label with the highest averaged probability, for each sample.GradientBoosting.predictProba(Tensor x) Class probabilities [n, classes] for samples x.KNeighbors.predictProba(Tensor q) Class probabilities [m, c]: the fraction of neighbours per class.LogisticRegression.predictProba(Tensor x) Class probabilities [m, c].NaiveBayes.predictProba(Tensor x) Class probabilities [n, classes] for samples x.GradientBoosting.predictValues(Tensor x) Regression predictions [m].KNeighbors.predictValues(Tensor q) Regression predictions [m, t].RandomForest.predictValues(Tensor x) Mean of the trees' leaf values: class probabilities [m, c] or predictions [m, 1].Projection [n, k] of x onto the components. -
Uses of Tensor in ai.beestream.jitnn.nn
Methods in ai.beestream.jitnn.nn that return TensorModifier and TypeMethodDescriptionConv2d.bias()The bias [out], or null without one.ConvTranspose2d.bias()The bias [out], or null without one.LayerNorm.bias()The shift [features], or null without one.Linear.bias()The bias [out], or null without one.protected TensorRegisters persistent state that is not trained (running statistics).LSTM.Output.c()Returns the value of thecrecord component.static TensorA causal token model (GPT-2, Llama) over INT32 tokens [B, T]: rows padded to abatchsize, positions padded at the end to aseqsize withpadToken, which the real positions never attend to; the result [B, T, ...] for the real rows and positions.static TensorBucketing.crossEntropy(Tensor logits, Tensor labels) Mean cross-entropy of the first N rows oflogits[B, C] (B a padded batch) against INT32labels[N]: each real row weighs 1/N and each padded row 0, through a weight tensor, so every N in the bucket runs the same plan.Every index its own bag.One row per bag: bag b covers indices offsets[b] .. offsets[b + 1] - 1.GraphConv.forward(Tensor x, SparseMatrix.Valued adjacency) Applies the layer to node features x [nodes, in] over the graph's normalised adjacency (seeSparseMatrix.gcn(int, int[], int[])).Output sequence of the last layer, from zero initial states.Output sequence of the last layer, from zero initial states.abstract TensorApplies the module tox.Attention over x [B, T, D] with an optional additivemask(null for none) and optional causal masking.Applies the layers, fusing a ReLU into the layer before it: Linear + ReLU and Conv2d + ReLU run as one GEMM with the activation in the epilogue, BatchNorm2d + ReLU as one kernel.BatchNorm2d.forwardRelu(Tensor x) relu(forward(x)), fused into the normalisation kernel.Conv2d.forwardRelu(Tensor x) relu(forward(x)), with the bias and ReLU fused into the convolution's output.Linear.forwardRelu(Tensor x) relu(forward(x)) as one fused GEMM;Sequentialuses it for a Linear followed by ReLU.GRU.Output.h()Returns the value of thehrecord component.LSTM.Output.h()Returns the value of thehrecord component.static TensorBucketing.masked(Buckets batch, Buckets seq, Tensor idx, Tensor mask, int padToken, BinaryOperator<Tensor> model) An encoder with an additive attention mask (BERT):modeltakes tokens [B, T] and a mask [B, 1, 1, T] or [B, 1, T, T] (masknull for none).protected TensorRegisters a trainable parameter initialised frominit.static TensorBucketing.rows(Buckets batch, Tensor x, UnaryOperator<Tensor> model) modeloverx[N, ...] with N padded to abatchsize by zero rows; the result's first N rows.BatchNorm2d.runningMean()The running mean [channels], updated in training mode.SyncBatchNorm2d.runningMean()The running mean [channels], updated in training mode.BatchNorm2d.runningVar()The running variance [channels], updated in training mode.SyncBatchNorm2d.runningVar()The running variance [channels], updated in training mode.Conv1d.weight()The weight [out, in, kernel].Conv2d.weight()The weight [out, in/groups, kernel, kernel].Conv3d.weight()The weight [out, in, kernel, kernel, kernel].ConvTranspose2d.weight()The weight [in, out/groups, kernel, kernel].Embedding.weight()The table [count, dim].EmbeddingBag.weight()The table [count, dim].GraphConv.weight()The weight [out, in].LayerNorm.weight()The scale [features].Linear.weight()The weight [out, in].PReLU.weight()The slopes [parameters].RMSNorm.weight()The scale [features].GRU.Output.y()Returns the value of theyrecord component.LSTM.Output.y()Returns the value of theyrecord component.Methods in ai.beestream.jitnn.nn that return types with arguments of type TensorModifier and TypeMethodDescriptionModule.buffers()This module's buffers and its children's.Module.parameters()This module's parameters and its children's, in registration order.Methods in ai.beestream.jitnn.nn with parameters of type TensorModifier and TypeMethodDescriptionprotected TensorRegisters persistent state that is not trained (running statistics).static TensorA causal token model (GPT-2, Llama) over INT32 tokens [B, T]: rows padded to abatchsize, positions padded at the end to aseqsize withpadToken, which the real positions never attend to; the result [B, T, ...] for the real rows and positions.static TensorBucketing.crossEntropy(Tensor logits, Tensor labels) Mean cross-entropy of the first N rows oflogits[B, C] (B a padded batch) against INT32labels[N]: each real row weighs 1/N and each padded row 0, through a weight tensor, so every N in the bucket runs the same plan.Every index its own bag.One row per bag: bag b covers indices offsets[b] .. offsets[b + 1] - 1.GraphConv.forward(Tensor x, SparseMatrix.Valued adjacency) Applies the layer to node features x [nodes, in] over the graph's normalised adjacency (seeSparseMatrix.gcn(int, int[], int[])).Output sequence of the last layer, from zero initial states.From initial states [layers directions, B, H] (null: zeros), for sequences oflengths(null: all T).Output sequence of the last layer, from zero initial states.From initial states [layers directions, B, H] (null: zeros), for sequences oflengths(null: all T).abstract TensorApplies the module tox.Attention over x [B, T, D] with an optional additivemask(null for none) and optional causal masking.Applies the layers, fusing a ReLU into the layer before it: Linear + ReLU and Conv2d + ReLU run as one GEMM with the activation in the epilogue, BatchNorm2d + ReLU as one kernel.BatchNorm2d.forwardRelu(Tensor x) relu(forward(x)), fused into the normalisation kernel.Conv2d.forwardRelu(Tensor x) relu(forward(x)), with the bias and ReLU fused into the convolution's output.Linear.forwardRelu(Tensor x) relu(forward(x)) as one fused GEMM;Sequentialuses it for a Linear followed by ReLU.static TensorBucketing.masked(Buckets batch, Buckets seq, Tensor idx, Tensor mask, int padToken, BinaryOperator<Tensor> model) An encoder with an additive attention mask (BERT):modeltakes tokens [B, T] and a mask [B, 1, 1, T] or [B, 1, T, T] (masknull for none).protected TensorRegisters a trainable parameter initialised frominit.static TensorBucketing.rows(Buckets batch, Tensor x, UnaryOperator<Tensor> model) modeloverx[N, ...] with N padded to abatchsize by zero rows; the result's first N rows.Method parameters in ai.beestream.jitnn.nn with type arguments of type TensorModifier and TypeMethodDescriptionstatic TensorA causal token model (GPT-2, Llama) over INT32 tokens [B, T]: rows padded to abatchsize, positions padded at the end to aseqsize withpadToken, which the real positions never attend to; the result [B, T, ...] for the real rows and positions.static TensorBucketing.masked(Buckets batch, Buckets seq, Tensor idx, Tensor mask, int padToken, BinaryOperator<Tensor> model) An encoder with an additive attention mask (BERT):modeltakes tokens [B, T] and a mask [B, 1, 1, T] or [B, 1, T, T] (masknull for none).static TensorBucketing.rows(Buckets batch, Tensor x, UnaryOperator<Tensor> model) modeloverx[N, ...] with N padded to abatchsize by zero rows; the result's first N rows.Constructors in ai.beestream.jitnn.nn with parameters of type Tensor -
Uses of Tensor in ai.beestream.jitnn.nn.models
Methods in ai.beestream.jitnn.nn.models that return TensorModifier and TypeMethodDescriptionDecodes latent vectors z [B, latent] to [B, in], each value in (0, 1).Hidden states [B, T, dim];maskis additive, broadcast to [B, heads, T, T] (e.g.Hidden states [B, T, dim] with INT32 token types [B, T] (null for all 0; ignored by a model without token-type embeddings) and an additivemask(null for none).Hidden states [B, T, dim] for INT32 tokens [B, T], without a padding mask.The document vectors of ids x.The word vectors W + W~ of ids x.Logits [B, T, vocab] for INT32 tokens [B, T].Logits [B, T, vocab] for INT32 tokens [B, T].Logits [B, 1, H, W] for x [B, in, H, W] (H and W divisible by 4).Reconstruction with the mean latent (no sampling).The word vectors of ids x.Vae.Output.logvar()Returns the value of thelogvarrecord component.Doc2Vec.loss(int[] documents, int[] targets, int[] contexts, int[] negatives, int k) The loss of a batch: document ids [B], the predicted words [B], for PV-DM the context words [B * window2] (null for PV-DBOW), and k negatives per sample.GloVe.loss(int[] rows, int[] cols, float[] x) The loss of a batch of co-occurrences x at (rows, cols), all > 0.static TensorVae.loss(Vae.Output o, Tensor x) The negative ELBO per sample: (binary cross-entropy summed over pixels + KL) / B.Word2Vec.loss(int[] centres, int[] contexts, int[] negatives, int k) The loss of a batch: skip-gram takes centres [B] and contexts [B]; CBOW takes the centre words [B] and their contexts [B * window2] (window2 per sample). negatives holds k words per sample.MLM logits [M, vocab] at the INT32 flat positionsrows[M] (indices into B * T): the hidden rows are gathered first, so the head runs on the masked positions only.Vae.Output.mu()Returns the value of themurecord component.The pooler output [B, dim]: tanh(dense(hidden state of the first token)); needs the pooler.Vae.Output.recon()Returns the value of thereconrecord component.Methods in ai.beestream.jitnn.nn.models with parameters of type TensorModifier and TypeMethodDescriptionDecodes latent vectors z [B, latent] to [B, in], each value in (0, 1).Hidden states [B, T, dim];maskis additive, broadcast to [B, heads, T, T] (e.g.Hidden states [B, T, dim] with INT32 token types [B, T] (null for all 0; ignored by a model without token-type embeddings) and an additivemask(null for none).Hidden states [B, T, dim] for INT32 tokens [B, T], without a padding mask.The document vectors of ids x.The word vectors W + W~ of ids x.Logits [B, T, vocab] for INT32 tokens [B, T].Logits [B, T, vocab] for INT32 tokens [B, T].Logits [B, 1, H, W] for x [B, in, H, W] (H and W divisible by 4).Reconstruction with the mean latent (no sampling).The word vectors of ids x.voidCopies weightnameinto parametertargetof the same shape.voidHfCheckpoint.loadConcatenated(Tensor target, String... names) Copies the concatenation, along the first axis, ofnamesintotarget.voidHfCheckpoint.loadTransposed(Tensor target, String name) Copies the transpose of 2-D weightnameintotarget(GPT-2's Conv1D layers store [in, out]).static TensorVae.loss(Vae.Output o, Tensor x) The negative ELBO per sample: (binary cross-entropy summed over pixels + KL) / B.MLM logits [M, vocab] at the INT32 flat positionsrows[M] (indices into B * T): the hidden rows are gathered first, so the head runs on the masked positions only.The pooler output [B, dim]: tanh(dense(hidden state of the first token)); needs the pooler.Encodes x [B, in], samples z = mu + exp(logvar / 2) eps with the given noise eps [B, latent], decodes.Constructors in ai.beestream.jitnn.nn.models with parameters of type Tensor -
Uses of Tensor in ai.beestream.jitnn.nn.optim
Fields in ai.beestream.jitnn.nn.optim with type parameters of type TensorMethods in ai.beestream.jitnn.nn.optim that return TensorModifier and TypeMethodDescriptionOptimizer.clipGradNorm(float maxNorm) Clips the gradients of this optimiser's parameters to a global L2 norm of at mostmaxNormat the nextOptimizer.step(), as PyTorch'sclip_grad_norm_, and returns the norm before clipping (after loss unscaling).loss * scale.protected TensorOptimizer.takeStats()The statistics the next update uses (computed now when a pre-scale is pending), or null; clears them.Methods in ai.beestream.jitnn.nn.optim with parameters of type TensorMethod parameters in ai.beestream.jitnn.nn.optim with type arguments of type TensorModifier and TypeMethodDescriptionstatic AdamAdamW: Adam with decoupled weight decay, PyTorch's default betas and eps.Constructor parameters in ai.beestream.jitnn.nn.optim with type arguments of type TensorModifierConstructorDescriptionAdaDelta with decayrho,epsand L2 weight decay.AdaGrad(List<Tensor> params, float lr, float lrDecay, float weightDecay, float initialAccumulator, float eps) AdaGrad with learning-rate decay, L2 weight decay, the accumulator's starting value, andeps.Adam with PyTorch's defaults: betas 0.9 and 0.999, eps 1e-8, no weight decay.Adam(List<Tensor> params, float lr, float beta1, float beta2, float eps, float weightDecay, boolean decoupled) Adam with the given hyper-parameters;decoupledmakes the weight decay AdamW's.Adam(List<Tensor> params, float lr, float beta1, float beta2, float eps, float weightDecay, boolean decoupled, boolean amsgrad) Adam with the given hyper-parameters;decoupledmakes the weight decay AdamW's,amsgraduses AMSGrad's maximum of the second moment.AdaMax with the given betas,epsand L2 weight decay.LAMB with the given betas,epsand decoupled weight decay.LARS with the given momentum, weight decay, trust coefficientetaandeps.NAdam(List<Tensor> params, float lr, float beta1, float beta2, float eps, float weightDecay, float momentumDecay) NAdam with the given betas,eps, L2 weight decay and momentum decay psi.protectedAn optimiser overparamswith learning ratelr.RMSProp(List<Tensor> params, float lr, float alpha, float eps, float weightDecay, float momentum, boolean centered) RMSProp with smoothingalpha,eps, L2 weight decay, momentum (0 for none) and, withcentered, the variance estimated around the mean gradient.Plain SGD: no momentum, no weight decay.SGD with the given momentum (0 for none), L2 weight decay, and Nesterov momentum whennesterovis set. -
Uses of Tensor in ai.beestream.jitnn.nn.text
Methods in ai.beestream.jitnn.nn.text that return TensorModifier and TypeMethodDescriptionTokenizer.Batch.additiveMask()An additive attention mask [batch, 1, 1, length]: 0 for tokens, -10000 for padding.Tokenizer.Batch.ids()The token ids as an INT32 tensor[batch, length].Tokenizer.Batch.typeIds()The token type (segment) ids as an INT32 tensor[batch, length]. -
Uses of Tensor in ai.beestream.jitnn.onnx
Methods in ai.beestream.jitnn.onnx that return types with arguments of type TensorModifier and TypeMethodDescriptionRuns the graph oninputs(by graph input name) and returns every graph output, as lazy jitNN tensors (read them with toFloatArray, or keep computing with them).Methods in ai.beestream.jitnn.onnx with parameters of type TensorModifier and TypeMethodDescriptionstatic voidOnnxExport.export(Path, Function, Tensor[], String[], String)for a one-input model.static voidOnnxExport.export(Path file, Function<Tensor[], Tensor> forward, Tensor[] inputs, String[] inputNames, String outputName) Recordsforwardoninputs(put the model in evaluation mode first) and writes it tofilewith graph inputsinputNamesand the outputoutputName.Method parameters in ai.beestream.jitnn.onnx with type arguments of type TensorModifier and TypeMethodDescriptionstatic voidOnnxExport.export(Path, Function, Tensor[], String[], String)for a one-input model.static voidOnnxExport.export(Path, Function, Tensor[], String[], String)for a one-input model.static voidOnnxExport.export(Path file, Function<Tensor[], Tensor> forward, Tensor[] inputs, String[] inputNames, String outputName) Recordsforwardoninputs(put the model in evaluation mode first) and writes it tofilewith graph inputsinputNamesand the outputoutputName.Runs the graph oninputs(by graph input name) and returns every graph output, as lazy jitNN tensors (read them with toFloatArray, or keep computing with them). -
Uses of Tensor in ai.beestream.jitnn.tf
Methods in ai.beestream.jitnn.tf that return types with arguments of type TensorModifier and TypeMethodDescriptionRuns the model; outputs are lazy jitNN tensors, by signature output name.Method parameters in ai.beestream.jitnn.tf with type arguments of type Tensor