Class Tensor
java.lang.Object
ai.beestream.jitnn.Tensor
- All Implemented Interfaces:
AutoCloseable
An n-dimensional array. Operations are lazy on TornadoVM: they are recorded and run at the next
sync point (
item(), toFloatArray(), Engine.sync(Tensor...)). Tensors are always
contiguous and row-major; reshape(int...) shares storage, permute(int...) copies.-
Method Summary
Modifier and TypeMethodDescriptionabs()|x|, element-wise.acos()Element-wise arccosine.acosh()Element-wise inverse hyperbolic cosine.add(float c) this + c.this + o, element-wise with broadcasting.static TensorA tensor that sharesbase's storage under another shape.static Tensorarange(float start, float end, float step) start, start + step, ... below end (above end for a negative step): torch.arange, ONNX Range.argmax(int axis) Index of the maximum alongaxis, as an INT32 tensor (no gradient).argmin(int axis) INT32 index of the first minimum alongaxis.argsort(int axis, boolean descending) INT32 indices that sort alongaxis(stable).asin()Element-wise arcsine.asinh()Element-wise inverse hyperbolic sine.voidRecords a copy ofsrcinto this persistent FP32 tensor of the same size (a running statistic, an optimiser buffer): later operators see the new values.atan()Element-wise arctangent.atan2(this, o), the angle of the point (o, this), with broadcasting.atanh()Element-wise inverse hyperbolic tangent.voidbackward()Back-propagates from this scalar.voidBack-propagates from this tensor withgradient(its shape) as the gradient of the result.bfloat16()This tensor converted to BF16 (to(DType.BF16)).bitwiseAnd(Tensor o) Bitwise and of INT32 tensors, with broadcasting.Bitwise complement of an INT32 tensor.Bitwise or of INT32 tensors, with broadcasting.bitwiseXor(Tensor o) Bitwise exclusive or of INT32 tensors, with broadcasting.static TensorJoins tensors along an existing axis.ceil()Element-wise ceiling.celu(float alpha) CELU: max(0, x) + min(0, alpha (exp(x / alpha) - 1)).Tensor[]chunk(int chunks, int axis) Splitsaxisintochunksequal pieces.clamp(float lo, float hi) x clamped to [lo, hi].voidclose()release(), for try-with-resources.voidcopyFrom(float[] values) Overwrites a persistent tensor's contents from the host (e.g. loading weights).cos()Element-wise cosine.cosh()Element-wise hyperbolic cosine.cube()x^3 (DL4J's Cube activation).cumprod(int axis) Inclusive cumulative product alongaxis; its gradient is exact with zeros.cumsum(int axis) Inclusive cumulative sum alongaxis.detach()The same data without gradient history.intdim(int axis) The size of axisaxis; a negative axis counts from the end.this / o, element-wise with broadcasting.dtype()The element type of this tensor.elu(float alpha) ELU: x for x > 0, else alpha (exp(x) - 1).1 where this == o, else 0, with broadcasting.erf()Element-wise error function.erfc()Element-wise complementary error function.exp()e^x, element-wise.Broadcast copy totargetshape.expm1()Element-wise exp(x) - 1, accurate near 0.static Tensoreye(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 Tensoreye(int, int, int)with the shape of the rank-2 tensorlike(ONNX EyeLike).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 Tensorfull(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.1 where this >= o, else 0, with broadcasting.gelu()GELU, exact form x * Phi(x) (PyTorch's default, approximate='none').geluTanh()GELU with the tanh approximation (GPT-2's form, PyTorch's approximate='tanh').grad()The accumulated gradient of a leaf tensor afterbackward(), or null.1 where this > o, else 0, with broadcasting.half()This tensor converted to FP16 (to(DType.F16)).HardSigmoid, PyTorch's form: clamp(x / 6 + 1/2, 0, 1).HardSwish: x hardSigmoid(x).hardTanh(float lo, float hi) HardTanh: x clamped to [lo, hi] (PyTorch's default -1, 1).indexSelect(int axis, Tensor idx) Elements idx[0 .. m-1] (INT32 [m]) ofaxis, torch.index_select.1 where finite, else 0.isInf()1 where +inf or -inf, else 0.booleanisLeaf()True unless the tensor is the output of an operator that tracks gradients (it is a leaf of autograd).isNaN()1 where NaN, else 0 (tested by bit pattern).booleanTrue for persistent device storage: weights (persistent(Tensor),parameter(Tensor)) and their views.floatitem()The value of a single-element tensor, as a float.1 where this <= o, else 0, with broadcasting.leakyRelu(float slope) LeakyReLU: x for x > 0, elseslope* x (PyTorch's default slope is 0.01).log()The natural logarithm, element-wise.log1p()Element-wise log(1 + x), accurate near 0.logicalAnd(Tensor o) 1 where both are non-zero, with broadcasting.Element-wise logical not: 1 where x is 0, else 0.1 where either is non-zero, with broadcasting.logicalXor(Tensor o) 1 where exactly one is non-zero, with broadcasting.Log-softmax along the last axis.1 where this < o, else 0, with broadcasting.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.max(int axis, boolean keepDim) The element-wise maximum of this and o, with broadcasting (maximumNaN(Tensor)propagates NaN).maximumNaN(Tensor o) Element-wise maximum propagating NaN (torch.maximum).mean()The mean of all elements, as a scalar.mean(int axis, boolean keepDim) The mean alongaxis, which is kept with size 1 whenkeepDimis set.min(int axis, boolean keepDim) The element-wise minimum of this and o, with broadcasting (minimumNaN(Tensor)propagates NaN).minimumNaN(Tensor o) Element-wise minimum propagating NaN (torch.minimum).mish()Mish: x tanh(softplus(x)).mul(float c) this * c.this * o, element-wise with broadcasting.nanToNum(float nan, float posInf) NaN tonan, +inf toposInfand -inf to -posInf (torch.nan_to_num with a symmetric infinity).narrow(int axis, int start, int length) Elementsstart .. start + length - 1alongaxis, as a new tensor.1 where this !neg()-this.nonzero()INT32 coordinates [count, rank] of the non-zero elements (torch.nonzero); reads the count back to the host.norm(int p, int axis, boolean keepDim) The p-norm (p = 1 or 2) alongaxis: sum |x| or sqrt(sum x^2).static Tensornormal(long seed, float mean, float std, int... dims) Normal with the given mean and standard deviation, counter-based likeuniform(long, float, float, int...).static TensorAsnormal(long, float, float, int...)with the seed in an INT32 [2] tensor.intnumel()The number of elements (1 for a scalar).static Tensorof(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 Tensorof(int[] data, int... dims) An INT32 tensor (labels, indices) with a copy ofdata;of(float[], int...)for int data.static Tensorof(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 Tensorones(int... dims) An FP32 tensor of ones.voidonGradReady(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.static TensorA trainable parameter: persistent storage (it stays on the device across steps), gradient tracking on, initialised with the values ofinit.permute(int... order) The axes reordered: axis i of the result is axisorder[i]of this tensor.static Tensorpersistent(Tensor init) Persistent storage without gradient tracking (optimiser state, running statistics).static Tensorpersistent(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 TensorpersistentHalf(float[] values, int... dims) Persistent FP16 storage (weights kept in half precision on the device), from FP32 values rounded to nearest.pow(float exponent) x^exponent, element-wise.x^exponent, element-wise, with broadcasting.prod()Product of all elements.prod(int axis, boolean keepDim) Product alongaxis.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.intrank()The number of axes (0 for a scalar).1 / x, element-wise.static voidrecord(ai.beestream.jitnn.engine.Op op, Tensor[] inputs, Tensor[] outputs, int[] iattr, float[] fattr, boolean traced) Records an operator application.voidrelease()Declares the tensor no longer used; using it, or a view of it, afterwards is an error.relu()max(x, 0), element-wise.relu6()min(max(x, 0), 6).this - floor(this / o) o, with broadcasting: the remainder with the sign of the divisor (torch.remainder).booleanWhether gradients are tracked for this tensor.requiresGrad(boolean on) Turns gradient tracking on or off for a leaf 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.round()Element-wise rounding to the nearest integer, halves to even (PyTorch's round).static Tensorscalar(float value) A rank-0 FP32 tensor holdingvalue.torch.scatter: this withsrcwritten atindex(duplicates: the last wins); no gradient.scatterAdd(int axis, Tensor index, Tensor src) torch.scatter_add: this withsrcadded atindexalongaxis.static Tensorseed(long seed) A 64-bit seed as the INT32 [2] host tensor [lo, hi] that the seeded random operators take.selu()SELU with PyTorch's constants (alpha 1.6732632, scale 1.0507010).voidReplaces the gradient of this leaf tensor (same shape), for example by its average over data-parallel ranks before the optimiser step.shape()The shape of this tensor.this << o for INT32 tensors, with broadcasting.shiftRight(Tensor o) this >> o (arithmetic: the sign is kept) for INT32 tensors, with broadcasting.sigmoid()The logistic sigmoid 1 / (1 + exp(-x)), element-wise.sign()Element-wise sign: -1, 0 or 1.silu()SiLU (swish): x * sigmoid(x).sin()Element-wise sine.sinh()Element-wise hyperbolic sine.slice(int axis, int start, int end) Elementsstart .. end - 1alongaxis; negative indices count from the end.softmax()Softmax along the last axis.softplus()Softplus, log(1 + exp(x)) (beta 1), computed without overflow.softsign()Softsign: x / (1 + |x|).Tensor[]sort(int axis, boolean descending) Stable sort alongaxis: {values, INT32 original indices}; values carry the gradient.Tensor[]split(int axis, int... sizes) Splitsaxisinto consecutive pieces of the given sizes.sqrt()The square root, element-wise.square()x^2, element-wise.squeeze(int axis) A view without the size-1 axisaxis.static TensorJoins same-shape tensors along a new axis.ai.beestream.jitnn.engine.Storagestorage()The memory behind this tensor, shared with its views.this - o, element-wise with broadcasting.sum()The sum of all elements, as a scalar.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).t()Transpose of a matrix.tan()Element-wise tangent.tanh()The hyperbolic tangent, element-wise.thresholdedRelu(float theta) ThresholdedReLU (Keras): x where x > theta, else 0.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).toFloat()This tensor converted to FP32 (to(DType.F32)).float[]The elements in row-major order, converted to float from any element type (INT32, FP16, BF16, FP8, GGUF blocks).float[]toFloatArray(float[] dst) Copies an F32, F16 or BF16 tensor intodst(lengthnumel()) without allocating: for BERT's [32, 128, 768] output, a fresh float[] costs more than the copy itself.int[]The elements of an INT32 tensor in row-major order.Tensor[]topk(int k) The k largest values along the last axis and their INT32 indices (descending; ties: lower index first).toString()transpose(int a, int b) trunc()Element-wise rounding towards zero.static Tensoruniform(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 TensorAsuniform(long, float, float, int...)with the seed in an INT32 [2] tensor (seeseed(long)): a plan replayed with a new seed draws new values without recompiling, so use this for noise drawn every step.unsqueeze(int axis) A view with a new size-1 axis ataxis(negative counts from the end of the result).static Tensorwrap(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 Tensorwrap(int[] data, int... dims) wrap(float[], int...)for int data.voidzeroGrad()Clears the accumulated gradient of this leaf tensor.static Tensorzeros(int... dims) An FP32 tensor of zeros.
-
Method Details
-
of
An FP32 tensor with a copy ofdatain the shapedims(a vector of all the values when no dims are given).wrap(float[], int...)shares the array instead. -
wrap
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.of(float[], int...)copies instead. -
of
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. -
wrap
wrap(float[], int...)for int data. -
of
An INT32 tensor (labels, indices) with a copy ofdata;of(float[], int...)for int data. -
scalar
A rank-0 FP32 tensor holdingvalue. -
full
An FP32 tensor of the given shape with every elementvalue. -
eye
The n x m matrix with ones on diagonal k (0 main, positive above, negative below), zeros elsewhere. -
eyeLike
eye(int, int, int)with the shape of the rank-2 tensorlike(ONNX EyeLike). -
arange
start, start + step, ... below end (above end for a negative step): torch.arange, ONNX Range. -
zeros
An FP32 tensor of zeros. -
ones
An FP32 tensor of ones. -
uniform
Uniform in [lo, hi), from a counter-based generator: the same seed gives the same values everywhere. -
uniform
Asuniform(long, float, float, int...)with the seed in an INT32 [2] tensor (seeseed(long)): a plan replayed with a new seed draws new values without recompiling, so use this for noise drawn every step. -
normal
Asnormal(long, float, float, int...)with the seed in an INT32 [2] tensor. -
seed
A 64-bit seed as the INT32 [2] host tensor [lo, hi] that the seeded random operators take. -
normal
Normal with the given mean and standard deviation, counter-based likeuniform(long, float, float, int...). -
parameter
-
persistent
-
quantized
A 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. The last axis must be a multiple of the format's block size. -
persistent
public static Tensor 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. The array class must be the one that holdsdtype(FloatArrayfor F32,HalfFloatArrayfor F16,ShortArrayfor BF16,IntArrayfor I32,ByteArrayfor the GGUF block formats) and its size must matchdims; for a block format the last axis must be a multiple of the block size. -
persistentHalf
Persistent FP16 storage (weights kept in half precision on the device), from FP32 values rounded to nearest. -
result
-
alias
-
record
public static void record(ai.beestream.jitnn.engine.Op op, Tensor[] inputs, Tensor[] outputs, int[] iattr, float[] fattr, boolean traced) Records an operator application. Outputs track gradients when gradient mode is on and any input does; the node is traced (run at the next sync) unlesstracedis false. -
storage
public ai.beestream.jitnn.engine.Storage storage()The memory behind this tensor, shared with its views. Internal: for jitNN's operators and modules, not part of the API. -
release
public void release()Declares the tensor no longer used; using it, or a view of it, afterwards is an error.- A persistent tensor (a weight), as when its model is closed: compiled plans that use it can then run another model of the same structure without compiling again.
- Any other tensor, typically an output once read: its contents are dropped. When its plan runs again they need not be copied out of the plan's buffer first, and a host array of its own goes back to a pool for later outputs. Serving loops that read each output and release it (or use try-with-resources) avoid an allocation and a copy per call; without it, the array is recycled only when the tensor is collected.
-
close
public void close()release(), for try-with-resources.- Specified by:
closein interfaceAutoCloseable
-
isLeaf
public boolean isLeaf()True unless the tensor is the output of an operator that tracks gradients (it is a leaf of autograd). -
isPersistent
public boolean isPersistent()True for persistent device storage: weights (persistent(Tensor),parameter(Tensor)) and their views. -
assign
Records a copy ofsrcinto this persistent FP32 tensor of the same size (a running statistic, an optimiser buffer): later operators see the new values. -
onGradReady
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. Data-parallel training starts the gradient all-reduce from it (DataParallel.overlapGradients). One hook per tensor; null removes it. -
setGrad
Replaces the gradient of this leaf tensor (same shape), for example by its average over data-parallel ranks before the optimiser step. -
shape
The shape of this tensor. -
dtype
The element type of this tensor. -
numel
public int numel()The number of elements (1 for a scalar). -
rank
public int rank()The number of axes (0 for a scalar). -
dim
public int dim(int axis) The size of axisaxis; a negative axis counts from the end. -
requiresGrad
public boolean requiresGrad()Whether gradients are tracked for this tensor. -
requiresGrad
Turns gradient tracking on or off for a leaf tensor. -
grad
The accumulated gradient of a leaf tensor afterbackward(), or null. -
zeroGrad
public void zeroGrad()Clears the accumulated gradient of this leaf tensor. -
backward
public void backward()Back-propagates from this scalar. -
backward
Back-propagates from this tensor withgradient(its shape) as the gradient of the result. -
detach
The same data without gradient history. -
item
public float item()The value of a single-element tensor, as a float. A sync point: runs every operator recorded so far. -
toFloatArray
public float[] toFloatArray()The elements in row-major order, converted to float from any element type (INT32, FP16, BF16, FP8, GGUF blocks). A sync point: runs every operator recorded so far. -
toFloatArray
public float[] toFloatArray(float[] dst) Copies an F32, F16 or BF16 tensor intodst(lengthnumel()) without allocating: for BERT's [32, 128, 768] output, a fresh float[] costs more than the copy itself. -
toIntArray
public int[] toIntArray()The elements of an INT32 tensor in row-major order. A sync point: runs every operator recorded so far. -
copyFrom
public void copyFrom(float[] values) Overwrites a persistent tensor's contents from the host (e.g. loading weights). -
add
-
sub
-
mul
-
div
-
maximum
The element-wise maximum of this and o, with broadcasting (maximumNaN(Tensor)propagates NaN). -
minimum
The element-wise minimum of this and o, with broadcasting (minimumNaN(Tensor)propagates NaN). -
gt
-
lt
-
ge
-
eq
-
add
this + c. -
mul
this * c. -
neg
-this. -
exp
e^x, element-wise. -
log
The natural logarithm, element-wise. -
sqrt
The square root, element-wise. -
abs
|x|, element-wise. -
relu
max(x, 0), element-wise. -
relu6
min(max(x, 0), 6). -
pow
-
pow
x^exponent, element-wise. -
clamp
x clamped to [lo, hi]. -
reciprocal
1 / x, element-wise. -
square
x^2, element-wise. -
tanh
The hyperbolic tangent, element-wise. -
sigmoid
The logistic sigmoid 1 / (1 + exp(-x)), element-wise. -
gelu
GELU, exact form x * Phi(x) (PyTorch's default, approximate='none'). -
geluTanh
GELU with the tanh approximation (GPT-2's form, PyTorch's approximate='tanh'). -
silu
SiLU (swish): x * sigmoid(x). -
leakyRelu
LeakyReLU: x for x > 0, elseslope* x (PyTorch's default slope is 0.01). -
sin
Element-wise sine. -
cos
Element-wise cosine. -
tan
Element-wise tangent. -
asin
Element-wise arcsine. -
acos
Element-wise arccosine. -
atan
Element-wise arctangent. -
sinh
Element-wise hyperbolic sine. -
cosh
Element-wise hyperbolic cosine. -
asinh
Element-wise inverse hyperbolic sine. -
acosh
Element-wise inverse hyperbolic cosine. -
atanh
Element-wise inverse hyperbolic tangent. -
erf
Element-wise error function. -
erfc
Element-wise complementary error function. -
round
Element-wise rounding to the nearest integer, halves to even (PyTorch's round). -
trunc
Element-wise rounding towards zero. -
floor
Element-wise floor. -
ceil
Element-wise ceiling. -
sign
Element-wise sign: -1, 0 or 1. -
log1p
Element-wise log(1 + x), accurate near 0. -
expm1
Element-wise exp(x) - 1, accurate near 0. -
logicalNot
Element-wise logical not: 1 where x is 0, else 0. -
atan2
-
bitwiseAnd
-
bitwiseOr
-
bitwiseXor
-
bitwiseNot
Bitwise complement of an INT32 tensor. -
shiftLeft
-
shiftRight
-
remainder
-
fmod
-
ne
-
le
-
logicalAnd
-
logicalOr
-
logicalXor
-
indexSelect
-
gather
-
scatterAdd
-
scatter
-
cumsum
Inclusive cumulative sum alongaxis. -
cumprod
Inclusive cumulative product alongaxis; its gradient is exact with zeros. -
nonzero
INT32 coordinates [count, rank] of the non-zero elements (torch.nonzero); reads the count back to the host. -
maskedSelect
-
sort
Stable sort alongaxis: {values, INT32 original indices}; values carry the gradient. -
argsort
INT32 indices that sort alongaxis(stable). -
isNaN
1 where NaN, else 0 (tested by bit pattern). -
isInf
1 where +inf or -inf, else 0. -
isFiniteMask
1 where finite, else 0. -
nanToNum
NaN tonan, +inf toposInfand -inf to -posInf (torch.nan_to_num with a symmetric infinity). -
maximumNaN
-
minimumNaN
-
fmax
-
fmin
-
elu
ELU: x for x > 0, else alpha (exp(x) - 1). -
selu
SELU with PyTorch's constants (alpha 1.6732632, scale 1.0507010). -
celu
CELU: max(0, x) + min(0, alpha (exp(x / alpha) - 1)). -
mish
Mish: x tanh(softplus(x)). -
softsign
Softsign: x / (1 + |x|). -
hardSigmoid
HardSigmoid, PyTorch's form: clamp(x / 6 + 1/2, 0, 1). -
hardSwish
HardSwish: x hardSigmoid(x). -
hardTanh
HardTanh: x clamped to [lo, hi] (PyTorch's default -1, 1). -
thresholdedRelu
ThresholdedReLU (Keras): x where x > theta, else 0. -
cube
x^3 (DL4J's Cube activation). -
softplus
Softplus, log(1 + exp(x)) (beta 1), computed without overflow. -
sum
The sum of all elements, as a scalar. -
sum
The sum alongaxis, which is kept with size 1 whenkeepDimis set. -
mean
The mean of all elements, as a scalar. -
mean
The mean alongaxis, which is kept with size 1 whenkeepDimis set. -
max
-
min
-
argmax
Index of the maximum alongaxis, as an INT32 tensor (no gradient). -
argmin
INT32 index of the first minimum alongaxis. -
prod
Product alongaxis. -
prod
Product of all elements. -
norm
The p-norm (p = 1 or 2) alongaxis: sum |x| or sqrt(sum x^2). -
sumTo
-
tile
This tensor repeatedreps[i]times along each axis (torch.Tensor.repeat, numpy.tile, ONNX Tile); reps longer than the rank adds leading axes. -
expand
-
reshape
Same data, new shape; one dimension may be -1. -
permute
The axes reordered: axis i of the result is axisorder[i]of this tensor. A copy, not a view. -
transpose
-
to
-
half
This tensor converted to FP16 (to(DType.F16)). -
bfloat16
This tensor converted to BF16 (to(DType.BF16)). -
toFloat
This tensor converted to FP32 (to(DType.F32)). -
topk
The k largest values along the last axis and their INT32 indices (descending; ties: lower index first). -
narrow
Elementsstart .. start + length - 1alongaxis, as a new tensor. -
slice
Elementsstart .. end - 1alongaxis; negative indices count from the end. -
split
Splitsaxisinto consecutive pieces of the given sizes. -
chunk
Splitsaxisintochunksequal pieces. -
cat
-
stack
-
unsqueeze
A view with a new size-1 axis ataxis(negative counts from the end of the result). -
squeeze
A view without the size-1 axisaxis. -
t
Transpose of a matrix. -
matmul
-
matmul
-
softmax
Softmax along the last axis. -
logSoftmax
Log-softmax along the last axis. -
toString
-