Docs / nablatensor-tensor / com.nablatensor.tensor
final class
Tensor
An immutable, fluent tensor handle. Every operation returns a new Tensor; materialization happens on the backend as operations are issued, and eval() / blockUntilReady() wait for completion.
Backends normally reclaim device memory only once a wrapper becomes unreachable and the GC/Cleaner get around to it, which is heuristic and can lag under sustained allocation pressure. Tight loops that discard a result every iteration (benchmarks, training steps) should call close() (or use try-with-resources) to free it deterministically instead.
Methods
Move to another device, re-uploading through the target backend.
Cholesky factor L of this SPD matrix (this = L·Lᵀ). See cholesky.
LU factorization with partial pivoting. See lu.
Householder QR factorization. See qr.
Symmetric eigendecomposition (cyclic Jacobi). See eigh.
Thin singular value decomposition (one-sided Jacobi). See svd.
Solves this · X = b for X. See solve.
The inverse of this square matrix. See inv.
The determinant of this square matrix. See det.
Batched matrix multiplication: (B,M,K) x (B,K,N) -> (B,M,N).
Copies one leading-axis slice and removes the leading dimension.
Stacks equally-shaped tensors along a new leading axis.
Returns an independent tensor with the same elements and a different shape.
2-D convolution of batched images (one image per row) against weights of shape (outChannels, inChannels * k * k).
Gradient of conv2d with respect to the input it was given.
Gradient of conv2d with respect to its weights; this is the input.
Routes this (an upstream gradient) through a ReLU evaluated at input.
Sums every element, returning a single-element (shape (1)) tensor.
Mean over every element, returning a single-element (shape (1)) tensor.
Maximum over every element, returning a single-element (shape (1)) tensor.
Sums a rank-2 tensor over axis 0 (the batch axis), returning shape (cols).
Returns maximum-value indices along axis as F32 values. Indices up to 2^24 are exact.
Routes reduced gradients to the first maximum position along axis.
Broadcasts to target, following broadcast's rules.
Force completion of all pending kernels and return this handle.
Deterministically frees this tensor's device buffer now, instead of waiting on GC/Cleaner timing. Safe to call even if the GC later also reclaims the same (by-then-unreachable) buffer - backends guarantee the underlying free only ever runs once. Do not use this tensor after closing it.