RiptideRiptide
Download Riptide SDKInstall Riptorch
Menu
Riptorch docs · Reference

Tensor

Every method and property of torch.Tensor. Every name stock PyTorch has is here; the reference marks what is the same, what is different and what Riptorch adds. PyTorch’s own page for Tensor.

import riptorch as torch
x = torch.tensor([1.0, 2.0])
577 same as PyTorch27 different7 Riptorch extras

Properties

Tensor.datapropertySame as PyTorch
data

The same tensor (in-place fills through.data update it, as in PyTorch).

Tensor.devicepropertySame as PyTorch
device

The tensor's device: always cpu, for every dtype (one unified memory).

Tensor.dtypepropertySame as PyTorch
dtype

The dtype (float32, float64, float16, bfloat16, the integer types or bool).

Tensor.gradpropertySame as PyTorch
grad

The gradient (None before backward). Assignable; in-place changes write through.

Tensor.grad_dtypepropertySame as PyTorch
grad_dtype

The dtype of this tensor's gradient (its own dtype for floating tensors, else None).

Tensor.grad_fnpropertySame as PyTorch
grad_fn

None for a leaf, else the backward node of the op that made the tensor (name: PyTorch's name, as MulBackward0).

Tensor.HpropertySame as PyTorch
H

The conjugate transpose of a matrix (2-d only, as PyTorch); for real tensors the transpose.

Tensor.imagpropertySame as PyTorch
imag

Imaginary part of a complex tensor; TypeError for real tensors, as PyTorch.

Tensor.is_cpupropertySame as PyTorch
is_cpu

True: Riptorch tensors live in one unified memory the CPU reads.

Tensor.is_cudapropertySame as PyTorch
is_cuda

False: no CUDA.

Tensor.is_distributed_propertyRiptorch extra
is_distributed_

False: Riptorch has no distributed tensors.

Riptorch extra: not in stock PyTorch.

Tensor.is_ipupropertySame as PyTorch
is_ipu

False: Riptorch has no ipu tensors.

Tensor.is_leafpropertySame as PyTorch
is_leaf

A tensor that needs no gradient, or one made by the user (not by an op that records gradients). grad_fn is None for leaves, else an object naming the op.

Tensor.is_maiapropertySame as PyTorch
is_maia

False: Riptorch has no maia tensors.

Tensor.is_metapropertySame as PyTorch
is_meta

False: no meta tensors.

Tensor.is_mkldnnpropertySame as PyTorch
is_mkldnn

False: Riptorch has no mkldnn tensors.

Tensor.is_mpspropertySame as PyTorch
is_mps

False: the GPU is used internally, tensors are not MPS tensors.

Tensor.is_mtiapropertySame as PyTorch
is_mtia

False: Riptorch has no mtia tensors.

Tensor.is_nestedpropertySame as PyTorch
is_nested

False for non-nested tensors.

Tensor.is_quantizedpropertySame as PyTorch
is_quantized

False for non-quantized tensors.

Tensor.is_quantized_propertyRiptorch extra
is_quantized_

False: Riptorch has no quantized tensors.

Riptorch extra: not in stock PyTorch.

Tensor.is_sparsepropertySame as PyTorch
is_sparse

False for dense tensors.

Tensor.is_sparse_csrpropertySame as PyTorch
is_sparse_csr

False: Riptorch has no sparse_csr tensors.

Tensor.is_vulkanpropertySame as PyTorch
is_vulkan

False: Riptorch has no vulkan tensors.

Tensor.is_xlapropertySame as PyTorch
is_xla

False: Riptorch has no xla tensors.

Tensor.is_xpupropertySame as PyTorch
is_xpu

False: Riptorch has no xpu tensors.

Tensor.itemsizepropertySame as PyTorch
itemsize

Bytes per element of the dtype.

Tensor.layoutpropertySame as PyTorch
layout

torch.strided: a dense tensor's layout.

Tensor.mHpropertySame as PyTorch
mH

The conjugate transpose of the last two dims (the transpose: real tensors).

Tensor.mTpropertySame as PyTorch
mT

The last two dims transposed.

Tensor.namepropertySame as PyTorch
name

The tensor's name (None unless set; named-tensor dims are not supported).

Tensor.namespropertyRiptorch extra
names

Dimension names: None for every dim (no named tensors).

Riptorch extra: not in stock PyTorch.

Tensor.nbytespropertySame as PyTorch
nbytes

numel * itemsize.

Tensor.ndimpropertySame as PyTorch
ndim

The number of dimensions (len(shape)).

Tensor.output_nrpropertySame as PyTorch
output_nr

0: the output index of this tensor in the op that made it (always 0 here).

Tensor.realpropertySame as PyTorch
real

self (a real tensor is its own real part).

Tensor.requires_gradpropertySame as PyTorch
requires_grad

Whether autograd records operations on this tensor (settable; float dtypes).

Tensor.retains_gradpropertySame as PyTorch
retains_grad

True after retain_grad on a non-leaf tensor (its.grad is kept by backward).

Tensor.shapepropertySame as PyTorch
shape

The shape as a tuple of ints (torch.Size).

Tensor.TpropertySame as PyTorch
T

t: the transpose of a 0-, 1- or 2-d tensor (PyTorch also reverses the dims of higher-dimensional tensors, deprecated there; Riptorch raises).

Tensor.volatilepropertySame as PyTorch
volatile

Removed in PyTorch: False, with its warning.

Core methods

Tensor.backwardfunctionSame as PyTorch
backward(self, gradient=None, retain_graph=None, create_graph=False, inputs=None)

Backpropagates from the given tensor(s): the gradients of the graph's leaves accumulate into.grad (gradient= supplies the vector for a non-scalar output; retain_graph / create_graph as PyTorch). Callbacks queued with queue_callback run when it finishes.

Tensor.bfloat16functionSame as PyTorch
bfloat16(self)

to(bfloat16).

Tensor.boolfunctionSame as PyTorch
bool(self, memory_format=None)

self.to(torch.bool).

Tensor.bytefunctionSame as PyTorch
byte(self)

to(uint8).

Tensor.cdoublefunctionSame as PyTorch
cdouble(self, memory_format=None)

self.to(torch.complex128).

Tensor.cfloatfunctionSame as PyTorch
cfloat(self, memory_format=None)

self.to(torch.complex64).

Tensor.charfunctionSame as PyTorch
char(self)

to(int8).

Tensor.clonefunctionSame as PyTorch
clone(input, *, memory_format=None)

Same as PyTorch’s torch.Tensor.clone.

Tensor.contiguousfunctionSame as PyTorch
contiguous(self, memory_format=None)

self: Riptorch tensors are always contiguous.

Tensor.cpufunctionSame as PyTorch
cpu(self, *args, **kwargs)

Tensor.cpu / cuda / mps / pin_memory: the tensor itself (one unified memory and one layout).

Tensor.cudafunctionSame as PyTorch
cuda(self, *args, **kwargs)

Tensor.cpu / cuda / mps / pin_memory: the tensor itself (one unified memory and one layout).

Tensor.data_ptrfunctionSame as PyTorch
data_ptr(self)

A stable integer identity of the tensor (id(self)); Riptorch does not expose buffer addresses.

Tensor.detachfunctionSame as PyTorch
detach(self)

The same values without autograd history (requires_grad False).

Tensor.detach_functionSame as PyTorch
detach_(self)

In place: self stops recording gradients; returns self.

Tensor.dimfunctionSame as PyTorch
dim(self)

The number of dimensions (ndimension too).

Tensor.doublefunctionSame as PyTorch
double(self)

to(float64).

Tensor.element_sizefunctionSame as PyTorch
element_size(self)

Bytes per element.

Tensor.expandfunctionSame as PyTorch
expand(input, *size)

A broadcast view to the given size (-1 keeps a dimension); size-1 dims repeat without copying. Dtypes: every dtype (autograd for the floating-point types).

Tensor.expand_asfunctionSame as PyTorch
expand_as(self, other)

The tensor expanded to other's shape.

Tensor.floatfunctionSame as PyTorch
float(self)

to(float32).

Tensor.halffunctionSame as PyTorch
half(self)

to(float16).

Tensor.intfunctionSame as PyTorch
int(self)

to(int32).

Tensor.is_contiguousfunctionSame as PyTorch
is_contiguous(self, *a, **k)

True: Riptorch tensors have one row-major layout.

Tensor.itemfunctionSame as PyTorch
item(self)

The value of a one-element tensor as a Python number (more elements raise, as PyTorch).

Tensor.longfunctionSame as PyTorch
long(self)

to(int64).

Tensor.mpsfunctionRiptorch extra
mps(self, *args, **kwargs)

Tensor.cpu / cuda / mps / pin_memory: the tensor itself (one unified memory and one layout).

Riptorch extra: not in stock PyTorch.

Tensor.nelementfunctionSame as PyTorch
nelement(self)

The number of elements (numel).

Tensor.new_emptyfunctionSame as PyTorch
new_empty(self, *size, dtype=None, device=None, requires_grad=False, **kw)

A new tensor of the given size filled with the constant (new_ones: 1; new_zeros and new_empty: 0), self's dtype unless dtype=.

Tensor.new_fullfunctionSame as PyTorch
new_full(self, size, fill_value, *, dtype=None, device=None, requires_grad=False, **kw)

A new tensor of the given size filled with fill_value, self's dtype unless dtype=.

Tensor.new_onesfunctionSame as PyTorch
new_ones(self, *size, dtype=None, device=None, requires_grad=False, **kw)

A new tensor of the given size filled with the constant (new_ones: 1; new_zeros and new_empty: 0), self's dtype unless dtype=.

Tensor.new_tensorfunctionSame as PyTorch
new_tensor(self, data, *, dtype=None, device=None, requires_grad=False, **kw)

A new tensor from data, self's dtype unless dtype=.

Tensor.new_zerosfunctionSame as PyTorch
new_zeros(self, *size, dtype=None, device=None, requires_grad=False, **kw)

A new tensor of the given size filled with the constant (new_ones: 1; new_zeros and new_empty: 0), self's dtype unless dtype=.

Tensor.numelfunctionSame as PyTorch
numel(self)

The number of elements.

Tensor.numpyfunctionSame as PyTorch
numpy(self, *, force=False)

The tensor's values as a NumPy array (a copy; PyTorch shares memory on the CPU).

Raises RuntimeError when the tensor requires grad, unless force=True; bfloat16 raises TypeError, as PyTorch.

Tensor.register_hookfunctionSame as PyTorch
register_hook(self, hook)

Leaves: the hook sees the gradient before it accumulates into.grad (and autograd.grad's result). Non-leaves: the hook applies to the gradient of the uses made after registering (PyTorch: of every use).

Tensor.requires_grad_functionSame as PyTorch
requires_grad_(self, requires_grad=True)

Sets requires_grad in place; returns self. A tensor that records no gradient becomes a leaf that does (whatever op made it); a non-leaf cannot stop (RuntimeError, as PyTorch: detach it).

Tensor.reshapefunctionSame as PyTorch
reshape(self, *shape)

The values in a new shape (sizes or one sequence; one -1 is inferred); view is the same.

Tensor.reshape_asfunctionSame as PyTorch
reshape_as(self, other)

The tensor reshaped to other's shape (reshape_as too).

Tensor.retain_gradfunctionSame as PyTorch
retain_grad(self)

backward also keeps this non-leaf tensor's gradient in.grad (a leaf keeps its own anyway); RuntimeError on a tensor that does not require gradients, as PyTorch.

Tensor.shortfunctionSame as PyTorch
short(self)

to(int16).

Tensor.sizefunctionSame as PyTorch
size(self, dim=None)

The shape, or its size along dim.

Tensor.storagefunctionSame as PyTorch
storage(self)

A TypedStorage over this tensor's elements (PyTorch's deprecation warning once); writes go to the tensor.

Tensor.stridefunctionSame as PyTorch
stride(self, dim=None)

The row-major (contiguous) strides of the shape, or the one of dim: Riptorch tensors are always laid out contiguously.

Tensor.tofunctionSame as PyTorch
to(self, dtype=None, *args, **kwargs)

The tensor in another dtype (from a dtype, a tensor's dtype, or dtype=); a device argument changes nothing (one unified memory). Returns self when nothing changes.

Tensor.tolistfunctionSame as PyTorch
tolist(self)

The values as nested Python lists (a 0-d tensor gives a number).

Tensor.typefunctionSame as PyTorch
type(self, dtype=None)

With no argument, the dtype (PyTorch returns a type string such as 'torch.FloatTensor'); with one, to(dtype).

Tensor.type_asfunctionSame as PyTorch
type_as(self, other)

The tensor converted to other's dtype.

Tensor.untyped_storagefunctionSame as PyTorch
untyped_storage(self)

An UntypedStorage holding this tensor's bytes (a copy read when called; Riptorch shares no storage).

Tensor.viewfunctionSame as PyTorch
view(self, *shape)

The values in a new shape (sizes or one sequence; one -1 is inferred); view is the same.

Tensor.view_asfunctionSame as PyTorch
view_as(self, other)

The tensor reshaped to other's shape (reshape_as too).

More methods

Tensor.absfunctionSame as PyTorch
abs(input)

Elementwise absolute value. Every dtype; autograd for the floating-point types.

Tensor.absolutefunctionSame as PyTorch
absolute(input)

Alias of Tensor.abs.

Elementwise absolute value. Every dtype; autograd for the floating-point types.

Tensor.acosfunctionSame as PyTorch
acos(input, *, out=None)

Arccosine, elementwise, as atan2(sqrt(1 - x^2), x); differentiable. Integer input is computed in float32.

Tensor.acoshfunctionSame as PyTorch
acosh(input)

Inverse hyperbolic cosine (NaN below 1). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.addfunctionSame as PyTorch
add(input, other, *, alpha=1)

self + alpha * other, with broadcasting and PyTorch type promotion. Every dtype; autograd for the floating-point types.

Tensor.addbmmfunctionSame as PyTorch
addbmm(input, batch1, batch2, *, beta=1, alpha=1, out=None)

beta * input + alpha * sum over the batch of batch1[i] @ batch2[i].

Tensor.addcdivfunctionSame as PyTorch
addcdiv(input, tensor1, tensor2, *, value=1)

input + value * tensor1 / tensor2.

Tensor.addcmulfunctionSame as PyTorch
addcmul(input, tensor1, tensor2, *, value=1)

input + value * tensor1 * tensor2.

Tensor.addmmfunctionSame as PyTorch
addmm(input, mat1, mat2, *, beta=1, alpha=1)

beta * self + alpha * (mat1 @ mat2). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.addmvfunctionSame as PyTorch
addmv(input, mat, vec, *, beta=1, alpha=1, out=None)

torch.addmv(self, *args, **kwargs).

beta * input + alpha * (mat @ vec).

Tensor.addrfunctionSame as PyTorch
addr(input, vec1, vec2, *, beta=1, alpha=1, out=None)

beta * input + alpha * outer(vec1, vec2).

Tensor.adjointfunctionSame as PyTorch
adjoint(self)

The transpose of the last two dims (conjugated for complex tensors in PyTorch).

Tensor.allfunctionSame as PyTorch
all(Tensor self, int? dim=None, bool keepdim=False) -> Tensor

Whether every element is nonzero, over all elements or along dim; returns bool. Every dtype; autograd for the floating-point types.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.allclosefunctionSame as PyTorch
allclose(input, other, rtol=1e-05, atol=1e-08, equal_nan=False)

Whether isclose holds everywhere; a Python bool.

Tensor.amaxfunctionSame as PyTorch
amax(Tensor self, int[] dim=[], bool keepdim=False) -> Tensor

Maximum along the given dims (all dims when empty); gradients split evenly between tied maxima, as PyTorch. Every dtype; autograd for the floating-point types.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.aminfunctionSame as PyTorch
amin(Tensor self, int[] dim=[], bool keepdim=False) -> Tensor

Minimum along the given dims (all dims when empty); gradients split evenly between tied minima, as PyTorch. Every dtype; autograd for the floating-point types.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.aminmaxfunctionSame as PyTorch
aminmax(self, *, dim=None, keepdim=False)

torch.aminmax(self, dim=dim, keepdim=keepdim).

Tensor.anglefunctionSame as PyTorch
angle(x)

torch.angle(self, *args, **kwargs).

The argument atan2(imag, real) of each complex value (0 or pi for real values).

Tensor.anyfunctionSame as PyTorch
any(Tensor self, int? dim=None, bool keepdim=False) -> Tensor

Whether any element is nonzero, over all elements or along dim; returns bool. Every dtype; autograd for the floating-point types.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.arccosfunctionSame as PyTorch
arccos(input, *, out=None)

Alias of Tensor.acos.

Arccosine, elementwise, as atan2(sqrt(1 - x^2), x); differentiable. Integer input is computed in float32.

Tensor.arccoshfunctionSame as PyTorch
arccosh(input)

Inverse hyperbolic cosine (NaN below 1). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.arcsinfunctionSame as PyTorch
arcsin(input, *, out=None)

Alias of Tensor.asin.

Arcsine, elementwise, as atan2(x, sqrt(1 - x^2)); differentiable. Integer input is computed in float32.

Tensor.arcsinhfunctionSame as PyTorch
arcsinh(input)

Inverse hyperbolic sine. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.arctanfunctionSame as PyTorch
arctan(input, *, out=None)

arctan: odd, with x > 1 folded through atan(x) = pi/2 - atan(1/x), then a polynomial on [0, 1] (|error| <= 2e-8) written with Riptorch ops.

Tensor.arctan2functionSame as PyTorch
arctan2(input, other, *, out=None)

The angle of (other, input) in (-pi, pi], quadrant by quadrant from atan. Computed in float32 (float64 inputs give a float32 result; PyTorch keeps float64). Lazy and differentiable.

Tensor.arctanhfunctionSame as PyTorch
arctanh(input)

Inverse hyperbolic tangent (inf at +-1, NaN outside). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.argmaxfunctionSame as PyTorch
argmax(Tensor self, int? dim=None, bool keepdim=False) -> Tensor

The first index of the maximum (as PyTorch), int64.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.argminfunctionSame as PyTorch
argmin(Tensor self, int? dim=None, bool keepdim=False) -> Tensor

Index of the minimum over the flattened tensor or along dim (the first one on ties); int64.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.argsortfunctionSame as PyTorch
argsort(Tensor self, int dim=-1, bool descending=False, *, bool stable=False) -> Tensor

Indices that sort along dim (descending= for largest first); ties keep their original order.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.argwherefunctionSame as PyTorch
argwhere(input, *, as_tuple=False)

The indices of the nonzero elements, as an n x ndim int64 tensor or (as_tuple=True) one tensor per dim; argwhere too.

Tensor.as_stridedfunctionSame as PyTorch
as_strided(input, size, stride, storage_offset=0)

A tensor whose element [i0, i1,...] is the input's flat element storage_offset + sum(ik * stride[k]) (a copy: Riptorch has no shared storage).

Tensor.as_strided_scatterfunctionSame as PyTorch
as_strided_scatter(input, src, size, stride, storage_offset=None)

input with the elements that as_strided(input, size, stride, storage_offset) would view replaced by src.

Tensor.as_subclassfunctionSame as PyTorch
as_subclass(self, cls)

This tensor's data as an instance of cls (a Tensor subclass); keeps autograd history.

Tensor.asinfunctionSame as PyTorch
asin(input, *, out=None)

Arcsine, elementwise, as atan2(x, sqrt(1 - x^2)); differentiable. Integer input is computed in float32.

Tensor.asinhfunctionSame as PyTorch
asinh(input)

Inverse hyperbolic sine. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.atanfunctionSame as PyTorch
atan(input, *, out=None)

arctan: odd, with x > 1 folded through atan(x) = pi/2 - atan(1/x), then a polynomial on [0, 1] (|error| <= 2e-8) written with Riptorch ops.

Tensor.atan2functionSame as PyTorch
atan2(input, other, *, out=None)

The angle of (other, input) in (-pi, pi], quadrant by quadrant from atan. Computed in float32 (float64 inputs give a float32 result; PyTorch keeps float64). Lazy and differentiable.

Tensor.atanhfunctionSame as PyTorch
atanh(input)

Inverse hyperbolic tangent (inf at +-1, NaN outside). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.baddbmmfunctionSame as PyTorch
baddbmm(input, batch1, batch2, *, beta=1, alpha=1, out=None)

beta * input + alpha * (batch1 @ batch2), batched.

Tensor.bernoullifunctionSame as PyTorch
bernoulli(self, p=None, *, generator=None)

Tensor.bernoulli: torch.bernoulli(self, p).

Tensor.bincountfunctionSame as PyTorch
bincount(input, weights=None, minlength=0)

Counts of each non-negative integer in the 1-d input (int64), or the sums of weights per value (float32 weights give float32, others float64); at least minlength entries.

Tensor.bitwise_andfunctionSame as PyTorch
bitwise_and(input, other)

Bitwise AND of integers, logical AND of bools (also &, and torch.logical_and on bool casts). Every dtype.

Tensor.bitwise_left_shiftfunctionSame as PyTorch
bitwise_left_shift(input, other, *, out=None)

Shift left: input << other, elementwise on integers, wrapping to input's width as PyTorch.

Tensor.bitwise_notfunctionSame as PyTorch
bitwise_not(input)

Bitwise NOT of integers, logical NOT of bools (also ~, and logical_not on bool casts). Every dtype.

Tensor.bitwise_orfunctionSame as PyTorch
bitwise_or(input, other)

Bitwise OR of integers, logical OR of bools (also |, and torch.logical_or on bool casts). Every dtype.

Tensor.bitwise_right_shiftfunctionSame as PyTorch
bitwise_right_shift(input, other, *, out=None)

Shift right: input >> other (arithmetic for signed types), elementwise on integers, wrapping to input's width as PyTorch.

Tensor.bitwise_xorfunctionSame as PyTorch
bitwise_xor(input, other)

Bitwise XOR of integers, logical XOR of bools (also ^). Every dtype.

Tensor.bmmfunctionSame as PyTorch
bmm(input, mat2, *, out=None)

mm / bmm / mv / dot / inner / outer / addmv / baddbmm / einsum

Each checks its operands' dims as PyTorch does and is a matmul (or the einsum row).

Tensor.broadcast_tofunctionSame as PyTorch
broadcast_to(input, size)

The tensor expanded to size (-1 keeps a dim), a broadcast view.

Tensor.ccol_indicesfunctionSame as PyTorch
ccol_indices(self, *a, **k)

Raises RuntimeError as PyTorch on a dense tensor: ccol_indices needs a sparse column compressed tensor.

Tensor.ceilfunctionSame as PyTorch
ceil(input)

Rounds up to an integer value (the dtype is kept). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.chalffunctionDifferent from PyTorch
chalf(self, memory_format=None)

Raises NotImplementedError: Riptorch has no complex32.

Different from PyTorch: Raises NotImplementedError: Riptorch has no complex32.

Tensor.choleskyfunctionSame as PyTorch
cholesky(A, upper=False, *, out=None)

torch.cholesky (deprecated in PyTorch): linalg.cholesky(A, upper=upper).

Tensor.cholesky_inversefunctionSame as PyTorch
cholesky_inverse(L, upper=False, *, out=None)

torch.cholesky_inverse(L, upper=False): (L L^T)^-1 (or (U^T U)^-1). Gradient: -R (G + G^T) R L (lower).

Tensor.cholesky_solvefunctionSame as PyTorch
cholesky_solve(B, L, upper=False, *, out=None)

torch.cholesky_solve(B, L, upper=False): solves A X = B with A = L L^T (or U^T U). Gradients as PyTorch's: L as a full matrix in A = L L^T (not only its triangle).

Tensor.chunkfunctionSame as PyTorch
chunk(Tensor self, int chunks, int dim=0) -> Tensor[]

Splits into chunks of ceil(n / chunks) along dim (the last chunk may be smaller, or fewer chunks may come back), as PyTorch.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.clampfunctionSame as PyTorch
clamp(input, min=None, max=None)

Limits values to [min, max] (either may be None; clip too).

Tensor.clamp_maxfunctionSame as PyTorch
clamp_max(input, max)

min(x, max). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.clamp_minfunctionSame as PyTorch
clamp_min(input, min)

clamp(input, min=min).

Tensor.clipfunctionSame as PyTorch
clip(input, min=None, max=None)

Limits values to [min, max] (either may be None; clip too).

Tensor.coalescefunctionDifferent from PyTorch
coalesce(self, *a, **k)

Different from PyTorch: duplicate entries summed in float64 and rounded once: duplicates [1e8, 1, -1e8] give 1.0, PyTorch's float32 sum gives 0.0

PyTorch
sums duplicate entries in the values' dtype, in order (float32: 1e8 + 1 - 1e8 = 0)
Riptorch
sums duplicates in float64 and rounds once
Measured
duplicates [1e8, 1, -1e8]: PyTorch 0.0, Riptorch 1.0 (the exact sum)
Stock behaviour
torch.set_compat("pytorch")
Tensor.col_indicesfunctionSame as PyTorch
col_indices(self, *a, **k)

Raises RuntimeError as PyTorch on a dense tensor: col_indices needs a sparse row compressed tensor.

Tensor.conjfunctionSame as PyTorch
conj(self)

self (a real tensor is its own conjugate).

Tensor.conj_physicalfunctionSame as PyTorch
conj_physical(x)

torch.conj_physical(self, *args, **kwargs).

The complex conjugate (a real tensor is returned as it is).

Tensor.const_data_ptrfunctionSame as PyTorch
const_data_ptr(self)

data_ptr (Riptorch has no read-only pointer distinction).

Tensor.copysignfunctionSame as PyTorch
copysign(input, other, *, out=None)

abs(input) with the sign of other, elementwise (other's sign bit decides, so -0.0 counts as negative); float.

Tensor.corrcoeffunctionSame as PyTorch
corrcoef(input)

The Pearson correlation matrix of the rows of input, clamped to [-1, 1].

Tensor.cosfunctionDifferent from PyTorch
cos(input)

Different from PyTorch: float32 cos within 1 ulp of the correctly rounded value: worst 1.08 ulps of the exact value on [-100, 100] where PyTorch's CPU kernel has 1.57 (CPU and MPS: 2 ulps after rounding)

PyTorch
float32 cos up to 2 ulps off
Riptorch
float32: sin(x + pi/2) with the roundings of x + pi/2 and of pi/2 put back; float64: Cody-Waite reduction by pi/2 in three parts
Measured
1500 points of [-100, 100]: Riptorch 1.08, PyTorch CPU 1.57 ulps of the exact value max 1 vs 2 ulps on [-1e-3, 1e-3], [1.5, 1.65], [-100, 100]
Stock behaviour
none: an accuracy gain, PyTorch's rounding is not reproduced
Tensor.coshfunctionSame as PyTorch
cosh(input)

Hyperbolic cosine. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.count_nonzerofunctionSame as PyTorch
count_nonzero(*a, **k)

The number of non-zero entries (int64), over all or along dim (an int or a tuple).

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.covfunctionSame as PyTorch
cov(input, *, correction=1, fweights=None, aweights=None)

The covariance matrix of the rows (variables) of input over its columns (observations); correction=1 is Bessel's; fweights / aweights weight the observations. A 1-d input gives a 0-d variance.

Tensor.crossfunctionSame as PyTorch
cross(input, other, dim=-1)

The 3-d cross product along dim (size 3), broadcasting.

Tensor.crow_indicesfunctionSame as PyTorch
crow_indices(self, *a, **k)

Raises RuntimeError as PyTorch on a dense tensor: crow_indices needs a sparse row compressed tensor.

Tensor.cummaxfunctionSame as PyTorch
cummax(input, dim)

Running maximum along dim and the index where it was reached, as (values, indices).

On ties the later index wins; a NaN propagates from where it appears. The values carry gradients (a gather of the input); the indices are int64.

Tensor.cumminfunctionSame as PyTorch
cummin(input, dim)

Running minimum along dim and the index where it was reached, as (values, indices).

On ties the later index wins; a NaN propagates from where it appears. The values carry gradients (a gather of the input); the indices are int64.

Tensor.cumprodfunctionSame as PyTorch
cumprod(*a, **k)

Products along dim: for float32, a sequential product of slices (differentiable).

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.cumsumfunctionSame as PyTorch
cumsum(self, dim, *, dtype=None)

torch.cumsum(self, dim, dtype=dtype).

Tensor.deg2radfunctionSame as PyTorch
deg2rad(input)

Degrees to radians. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.dense_dimfunctionSame as PyTorch
dense_dim(self)

dim: every dim of a dense tensor is dense.

Tensor.dequantizefunctionDifferent from PyTorch
dequantize(self)

The float values of a quantized tensor; a float tensor is returned as it is (float16: as float32).

Different from PyTorch: one rounding of (q - zero_point) * scale; PyTorch's float32 scale gives a wrong last bit on 50 of 256 integers at scale 0.1

PyTorch
(q - zero_point) * float32(scale): the scale rounded to float32 first
Riptorch
the float32 nearest to (q - zero_point) * scale (one rounding)
Measured
scale 0.1, q in 0..255: PyTorch differs from the correctly rounded value at 22 of 256 integers (1 ulp)
Stock behaviour
torch.set_compat("pytorch")
Tensor.detfunctionSame as PyTorch
det(A, *, out=None, maths=None, exact=False)

Same as PyTorch’s torch.Tensor.det.

Tensor.diagfunctionSame as PyTorch
diag(input, diagonal=0)

diag of a 1-d tensor: the square matrix with it on diagonal k; of a 2-d tensor: its diagonal k.

Tensor.diag_embedfunctionSame as PyTorch
diag_embed(self, offset=0, dim1=-2, dim2=-1)

torch.diag_embed(self, offset, dim1, dim2).

Tensor.diagflatfunctionSame as PyTorch
diagflat(input, offset=0)

A square 2-d tensor with input's elements (flattened) on the offset diagonal and zeros elsewhere.

Tensor.diagonalfunctionSame as PyTorch
diagonal(input, offset=0, dim1=0, dim2=1)

Tensor.diagonal / torch.diagonal: the diagonal at offset between dim1 and dim2, moved to the last dim (gradients flow).

Tensor.diagonal_scatterfunctionDifferent from PyTorch
diagonal_scatter(input, src, offset=0, dim1=0, dim2=1)

A copy of a 2-d input with its offset diagonal replaced by src. Only 2-d input with dims (0, 1) (or (-2, -1)); others raise NotImplementedError.

Different from PyTorch: Only 2-d input with dims (0, 1) (or (-2, -1)); others raise NotImplementedError.

Tensor.difffunctionSame as PyTorch
diff(*a, **k)

The n-th forward difference along dim, after prepend / append are joined on; bool inputs use !=.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.digammafunctionDifferent from PyTorch
digamma(input, *, out=None)

Different from PyTorch: correctly rounded float32 values (computed in float64, rounded once); 1499 inputs in [-4.9, 5.7]: worst 125285 ulp (PyTorch) vs 0; MLX has no digamma

PyTorch
float32 kernels in float32 precision: values off by several ulp
Riptorch
computed in float64, rounded once to float32 (correctly rounded)
Measured
float32: 1499 inputs in [-4.9, 5.7]: worst 125285 ulp (PyTorch) vs 0
Stock behaviour
not reproduced: PyTorch's values come from its own float32 polynomial kernels, which Riptorch does not copy (compat keeps Riptorch's correctly rounded values)
Tensor.dim_orderfunctionSame as PyTorch
dim_order(self, *, ambiguity_check=False)

Dims ordered from outermost to innermost in memory (by stride).

Tensor.distfunctionSame as PyTorch
dist(input, other, p=2)

The p-norm (default 2) of input - other over all elements.

Tensor.divfunctionSame as PyTorch
div(input, other, *, rounding_mode=None)

Division, true by default; rounding_mode="trunc" or "floor" rounds the quotient. Integer inputs give float32, as PyTorch. Every dtype; autograd for the floating-point types.

Tensor.dividefunctionSame as PyTorch
divide(input, other, *, rounding_mode=None)

Division, true by default; rounding_mode="trunc" or "floor" rounds the quotient. Integer inputs give float32, as PyTorch. Every dtype; autograd for the floating-point types.

Tensor.dotfunctionSame as PyTorch
dot(input, other, *, out=None)

The dot product of two 1-d tensors.

Tensor.dsplitfunctionSame as PyTorch
dsplit(input, sections)

tensor_split along dim 2.

Tensor.eigfunctionSame as PyTorch
eig(*a, _m='This function was deprecated since version 1.9 and is now removed. Please use the `torch.linalg.eig` function instead.', **k)

Removed from PyTorch: raises RuntimeError as PyTorch does (This function was deprecated since version 1.9 and is now removed. Please use the torch.linalg.eig function instead.)

Tensor.eqfunctionSame as PyTorch
eq(input, other)

Elementwise ==, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.

Tensor.equalfunctionSame as PyTorch
equal(input, other)

True if both tensors have the same shape and the same values.

Tensor.erffunctionSame as PyTorch
erf(input)

The error function. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.erfcfunctionSame as PyTorch
erfc(input)

1 - erf(x), accurate in the upper tail. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.erfinvfunctionDifferent from PyTorch
erfinv(input, *, out=None)

Different from PyTorch: correctly rounded float32 values (computed in float64, rounded once); 1999 inputs in [0.9999, 1]: every value off, worst 127 ulp vs 0; MLX's GPU erfinv is up to 3 ulp off there

PyTorch
float32 kernels in float32 precision: values off by several ulp
Riptorch
computed in float64, rounded once to float32 (correctly rounded)
Measured
float32: 1999 inputs in [0.9999, 1]: every value off, worst 127 ulp vs 0
Stock behaviour
not reproduced: PyTorch's values come from its own float32 polynomial kernels, which Riptorch does not copy (compat keeps Riptorch's correctly rounded values)
Tensor.expfunctionSame as PyTorch
exp(input)

Elementwise e^x. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.exp2functionSame as PyTorch
exp2(input)

Elementwise 2^x. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.expm1functionSame as PyTorch
expm1(input)

Taylor series below ln 2 / 2, e^x - 1 above: no cancellation near 0.

Tensor.fixfunctionSame as PyTorch
fix(input)

Rounds toward zero (fix too). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.flattenfunctionSame as PyTorch
flatten(Tensor self, int start_dim=0, int end_dim=-1) -> Tensor

A reshape (the dims from start_dim to end_dim become one).

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.flipfunctionSame as PyTorch
flip(*a, **k)

torch.flip(self, dims): dims as a sequence or as separate ints.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.fliplrfunctionSame as PyTorch
fliplr(input)

input reversed along dim 1 (left / right).

Tensor.flipudfunctionSame as PyTorch
flipud(input)

input reversed along dim 0 (up / down).

Tensor.float_powerfunctionSame as PyTorch
float_power(self, exponent)

torch.float_power(self, exponent): in float64.

Tensor.floorfunctionSame as PyTorch
floor(input)

Rounds down to an integer value (the dtype is kept). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.floor_dividefunctionSame as PyTorch
floor_divide(input, other, *, out=None)

Division rounded down (torch.div with rounding_mode='floor'); integers stay integers.

Tensor.fmaxfunctionSame as PyTorch
fmax(input, other, *, out=None)

Elementwise maximum ignoring NaN: where one side is NaN the other is returned (NaN only when both are).

Tensor.fminfunctionSame as PyTorch
fmin(input, other, *, out=None)

Elementwise minimum ignoring NaN: where one side is NaN the other is returned (NaN only when both are).

Tensor.fmodfunctionSame as PyTorch
fmod(input, other, *, out=None)

C's fmod, the dividend's sign.

Tensor.fracfunctionSame as PyTorch
frac(input)

x - trunc(x), keeping the sign. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.frexpfunctionSame as PyTorch
frexp(input, *, out=None)

(mantissa, exponent) with input = mantissa * 2**exponent and 0.5 <= |mantissa| < 1 (0 for 0).

mantissa keeps input's dtype, exponent is int32. Read back from the values: not differentiable.

Tensor.gatherfunctionSame as PyTorch
gather(Tensor self, int dim, Tensor index, *, bool sparse_grad=False) -> Tensor

out[i][j][k] = input[index[i][j][k]][j][k] along dim (any dtype). A float32 input that records gradients gathers through gather_positions, so gradients flow.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.gcdfunctionSame as PyTorch
gcd(input, other, *, out=None)

Elementwise greatest common divisor of integer tensors, exact (Python integers), in the first input's dtype.

Tensor.gefunctionSame as PyTorch
ge(input, other)

Elementwise >=, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.

Tensor.gelufunctionRiptorch extra
gelu(input, approximate='none', *, maths=None)

approximate="tanh": 0.5 x (1 + tanh(sqrt(2/pi) (x + 0.044715 x^3))).

Riptorch extra: not in stock PyTorch.

Tensor.geqrffunctionSame as PyTorch
geqrf(A, *, out=None)

Same as PyTorch’s torch.Tensor.geqrf.

Tensor.gerfunctionSame as PyTorch
ger(input, vec2, *, out=None)

torch.ger(self, *args, **kwargs).

The outer product of two vectors (ger too).

Tensor.get_devicefunctionSame as PyTorch
get_device(self)

-1, PyTorch's answer for a CPU tensor (Riptorch's memory is unified).

Tensor.greaterfunctionSame as PyTorch
greater(input, other)

torch.greater(self, *args, **kwargs).

Tensor.greater_equalfunctionSame as PyTorch
greater_equal(input, other)

Alias of Tensor.ge.

Elementwise >=, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.

Tensor.gtfunctionSame as PyTorch
gt(input, other)

Elementwise >, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.

Tensor.hardshrinkfunctionSame as PyTorch
hardshrink(input, lambd=0.5)

x where |x| > lambd, else 0. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.hash_tensorfunctionSame as PyTorch
hash_tensor(input, dim=(), *, keepdim=False, mode=0)

XOR of the elements' bit patterns (floats as float64 bits, integers as int64), over dim (all when empty). PyTorch returns uint64; the core has no uint64 tensors, so the same 64 bits come back as int64.

Tensor.heavisidefunctionSame as PyTorch
heaviside(input, values, *, out=None)

The step function: 0 where input < 0, 1 where input > 0, values where input == 0; input's dtype.

Tensor.histcfunctionSame as PyTorch
histc(input, bins=100, min=0, max=0, *, out=None)

Counts in bins equal-width bins over [min, max] (the data's range when min == max); values outside and nan are skipped. Integer inputs give float32 counts (PyTorch raises for them).

Tensor.histogramfunctionSame as PyTorch
histogram(input, bins=100, *, range=None, weight=None, density=False, out=None)

torch.histogram(self, *args, **kwargs).

(hist, bin_edges): counts (or weight sums) in bins equal bins over range (default the data's range) or over the given edges tensor; density=True normalises to a density.

Tensor.hsplitfunctionSame as PyTorch
hsplit(input, sections)

tensor_split along dim 1 (dim 0 for a 1-d input).

Tensor.hspmmfunctionRiptorch extra
hspmm(self, mat2)

torch.hspmm(self, mat2): sparse self @ dense mat2 as a hybrid COO tensor.

Riptorch extra: not in stock PyTorch.

Tensor.hypotfunctionSame as PyTorch
hypot(input, other)

sqrt(a^2 + b^2) elementwise. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.i0functionDifferent from PyTorch
i0(input, *, out=None)

Different from PyTorch: correctly rounded float32 values (computed in float64, rounded once); 1500 inputs in [0, 75]: worst 3 ulp vs 0; MLX has no i0

PyTorch
float32 kernels in float32 precision: values off by several ulp
Riptorch
computed in float64, rounded once to float32 (correctly rounded)
Measured
float32: 1500 inputs in [0, 75]: worst 3 ulp vs 0
Stock behaviour
not reproduced: PyTorch's values come from its own float32 polynomial kernels, which Riptorch does not copy (compat keeps Riptorch's correctly rounded values)
Tensor.igammafunctionSame as PyTorch
igamma(input, other, *, out=None)

The regularized lower incomplete gamma function P(a, x) (input a, other x), in float64 and rounded once.

Tensor.igammacfunctionSame as PyTorch
igammac(input, other, *, out=None)

The regularized upper incomplete gamma function Q(a, x) = 1 - P(a, x), in float64 and rounded once.

Tensor.indexfunctionDifferent from PyTorch
index(self, positions, dims)

Binds dims to first-class Dim objects (functorch.dim) in PyTorch; not supported: NotImplementedError.

Different from PyTorch: Binds dims to first-class Dim objects (functorch.dim) in PyTorch; not supported: NotImplementedError.

Tensor.index_addfunctionDifferent from PyTorch
index_add(input, dim, index, source, *, alpha=1)

Different from PyTorch: repeated indices summed in float64 and rounded once: [1e8, 1, -1e8] at one index gives 1.0, PyTorch's float32 sum gives 0.0

PyTorch
adds source's slices one after another in the input's dtype (float32: 1e8 + 1 - 1e8 = 0)
Riptorch
without gradients, one CPU pass summing in float64, rounded once (any n x k); with gradients, the float32 one-hot product in blocks
Measured
[1e8, 1, -1e8] added at index 0 of zeros(2): PyTorch 0.0, Riptorch 1.0 (the exact sum)
Stock behaviour
torch.set_compat("pytorch")
Tensor.index_copyfunctionSame as PyTorch
index_copy(input, dim, index, source)

A copy of input with source's slices written at index along dim.

Tensor.index_fillfunctionSame as PyTorch
index_fill(input, dim, index, value)

A copy of input with value written into the slices at index along dim.

Tensor.index_putfunctionDifferent from PyTorch
index_put(input, indices, values, accumulate=False)

Different from PyTorch: accumulate=True sums repeated positions in float64 and rounds once: [1e8, 1, -1e8] at one position gives 1.0, PyTorch gives 0.0

PyTorch
accumulate=True adds the values one after another in the input's dtype
Riptorch
accumulate=True: index_add's float64 sum, rounded once
Measured
[1e8, 1, -1e8] put at position 0 of zeros(2) with accumulate=True: PyTorch 0.0, Riptorch 1.0; run to run, index_put_(accumulate=True) gives one result in 20 runs where PyTorch CPU and MPS give 20 different ones
Stock behaviour
torch.set_compat("pytorch")
Tensor.index_reducefunctionSame as PyTorch
index_reduce(self, dim, index, source, reduce, *, include_self=True)

A copy of self where row index[j] of dim is reduced with source's row j: reduce "prod", "mean", "amax" or "amin"; include_self=False leaves self's own value out of rows that receive any. Integer mean floors.

Tensor.index_selectfunctionSame as PyTorch
index_select(*a, **k)

The slices of input along dim at index (1-d, int); differentiable.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.indicesfunctionSame as PyTorch
indices(self, *a, **k)

Raises RuntimeError as PyTorch on a dense tensor: indices needs a sparse coordinate tensor.

Tensor.innerfunctionSame as PyTorch
inner(input, other, *, out=None)

Inner product over the last dims (a scalar input multiplies).

Tensor.int_reprfunctionSame as PyTorch
int_repr(input)

The stored integers of a quantized tensor (raises for a float tensor, as PyTorch).

Tensor.inversefunctionSame as PyTorch
inverse(self)

linalg.inv(self) (integer tensors give the exact inverse as a FractionTensor).

Tensor.ipufunctionSame as PyTorch
ipu(self, device=None, non_blocking=False, memory_format=None)

Raises RuntimeError: no IPU support (PyTorch's message).

Tensor.is_coalescedfunctionSame as PyTorch
is_coalesced(self, *a, **k)

Raises RuntimeError as PyTorch on a dense tensor: is_coalesced needs a sparse coordinate tensor.

Tensor.is_complexfunctionSame as PyTorch
is_complex(self)

Whether this is a complex tensor.

Tensor.is_conjfunctionSame as PyTorch
is_conj(self)

False: Riptorch never keeps a lazy conjugate bit.

Tensor.is_distributedfunctionSame as PyTorch
is_distributed(self)

False (no distributed tensors).

Tensor.is_floating_pointfunctionSame as PyTorch
is_floating_point(input)

Same as PyTorch’s torch.Tensor.is_floating_point.

Tensor.is_inferencefunctionSame as PyTorch
is_inference(self)

False: Riptorch makes no inference tensors.

Tensor.is_negfunctionSame as PyTorch
is_neg(self)

False: Riptorch never keeps a lazy negation bit.

Tensor.is_nonzerofunctionSame as PyTorch
is_nonzero(self)

The truth value of a one-element tensor; more elements raise RuntimeError as PyTorch.

Tensor.is_pinnedfunctionSame as PyTorch
is_pinned(self, *a)

False: unified memory, nothing is pinned.

Tensor.is_same_sizefunctionSame as PyTorch
is_same_size(self, other)

Whether other has self's shape.

Tensor.is_set_tofunctionSame as PyTorch
is_set_to(self, t)

Whether t is this very tensor (Riptorch tensors never share storage).

Tensor.is_sharedfunctionSame as PyTorch
is_shared(self)

False: Riptorch tensors are not in shared memory (they cross processes by copy).

Tensor.is_signedfunctionSame as PyTorch
is_signed(self)

Whether the dtype holds negative values (floats and signed integers).

Tensor.isclosefunctionSame as PyTorch
isclose(input, other, rtol=1e-05, atol=1e-08, equal_nan=False)

|input - other| <= atol + rtol * |other| elementwise (equal_nan=True counts NaN == NaN); returns bool.

Tensor.isfinitefunctionSame as PyTorch
isfinite(input)

True where the element is neither inf nor NaN (always True for integer and bool tensors).

Tensor.isinfunctionRiptorch extra
isin(elements, test_elements, *, assume_unique=False, invert=False)

torch.isin(self, *args, **kwargs).

Riptorch extra: not in stock PyTorch.

Tensor.isinffunctionSame as PyTorch
isinf(input)

True where the element is +inf or -inf (always False for integer and bool tensors).

Tensor.isnanfunctionSame as PyTorch
isnan(input)

Tensor.isnan / torch.isnan: True where the element is NaN (x != x); always False for integer and bool tensors.

Tensor.isneginffunctionSame as PyTorch
isneginf(x)

torch.isneginf(self, *args, **kwargs).

True where the element is -inf.

Tensor.isposinffunctionSame as PyTorch
isposinf(x)

torch.isposinf(self, *args, **kwargs).

True where the element is +inf.

Tensor.isrealfunctionSame as PyTorch
isreal(self)

Elementwise: True where the imaginary part is zero (all True for real tensors).

Tensor.istftfunctionSame as PyTorch
istft(input, n_fft, hop_length=None, win_length=None, window=None, center=True, normalized=False, onesided=None, length=None, return_complex=False)

Inverse of stft: the inverse FFT of each frame, windowed, overlap-added and divided by the summed squared window. center=True removes the n_fft // 2 padding; length= trims or sets the output length.

Tensor.kronfunctionSame as PyTorch
kron(input, other, *, out=None)

torch.kron(a, b): the Kronecker product (dims aligned from the right), differentiable.

Tensor.kthvaluefunctionSame as PyTorch
kthvalue(Tensor self, int k, int dim=-1, bool keepdim=False) -> (Tensor values, Tensor indices)

The k-th smallest (1-based); among equal values the one the stable order puts k-th.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.lcmfunctionSame as PyTorch
lcm(input, other, *, out=None)

Elementwise least common multiple of integer tensors (0 where either is 0), in the first input's dtype.

Tensor.ldexpfunctionSame as PyTorch
ldexp(input, other, *, out=None)

input * 2**other, elementwise, as a float tensor.

Tensor.lefunctionSame as PyTorch
le(input, other)

Elementwise <=, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.

Tensor.lerpfunctionSame as PyTorch
lerp(input, end, weight)

input + weight * (end - input).

Tensor.lessfunctionSame as PyTorch
less(input, other)

torch.less(self, *args, **kwargs).

Tensor.less_equalfunctionSame as PyTorch
less_equal(input, other)

Alias of Tensor.le.

Elementwise <=, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.

Tensor.lgammafunctionSame as PyTorch
lgamma(input, *, out=None)

log|Gamma(x)|, per element: computed in float64 and rounded once to the input's float dtype (integer inputs give float32); differentiable.

Tensor.logfunctionSame as PyTorch
log(input)

Elementwise natural log (-inf at 0, NaN below 0). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.log10functionSame as PyTorch
log10(input)

Elementwise log base 10. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.log1pfunctionSame as PyTorch
log1p(input)

2 atanh(x / (2 + x)) below 1/4, log(1 + x) with the rounding of 1 + x put back above.

Tensor.log2functionSame as PyTorch
log2(input)

Elementwise log base 2. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.log_softmaxfunctionSame as PyTorch
log_softmax(Tensor input, int? dim=None, *, dtype? dtype=None) -> Tensor

log(softmax(x)) along dim, computed stably (x - logsumexp); dtype= casts the input first. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.logaddexpfunctionSame as PyTorch
logaddexp(input, other)

log(exp(a) + exp(b)) computed stably. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.logaddexp2functionSame as PyTorch
logaddexp2(input, other, *, out=None)

log2(2^input + 2^other) without overflow: max + log2(1 + 2^-|input - other|).

Tensor.logcumsumexpfunctionSame as PyTorch
logcumsumexp(*a, **k)

log(cumsum(exp(input))) along dim, shifted by the maximum so large values don't overflow; integer inputs give float32 (PyTorch raises for them).

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.logdetfunctionSame as PyTorch
logdet(A)

torch.logdet(A): log det A (nan for a negative determinant, -inf for zero).

Tensor.logical_andfunctionSame as PyTorch
logical_and(input, other, *, out=None)

Elementwise AND of the inputs' truth values (nonzero is True); bool.

Tensor.logical_notfunctionSame as PyTorch
logical_not(*args, **kw)

logical_not: the inputs as bool, then bitwise_not (a bool result, as PyTorch's logical ops).

Tensor.logical_orfunctionSame as PyTorch
logical_or(input, other, *, out=None)

Elementwise OR of the inputs' truth values (nonzero is True); bool.

Tensor.logical_xorfunctionSame as PyTorch
logical_xor(input, other, *, out=None)

Elementwise XOR of the inputs' truth values (nonzero is True); bool.

Tensor.logitfunctionSame as PyTorch
logit(input)

log(x / (1 - x)). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.logsumexpfunctionDifferent from PyTorch
logsumexp(input, dim=None, keepdim=False, *, out=None)

log(sum(exp(x))) over dim with the largest value taken out first; out= written. dim=[] reduces every dim, as sum(dim=[]) (set_compat("pytorch"): PyTorch's RuntimeError).

Different from PyTorch: dim=[] reduces every dim, as sum(dim=[]) does; PyTorch CPU and MPS raise RuntimeError

PyTorch
logsumexp(x, dim=[]) raises RuntimeError (output with shape [] doesn't match the broadcast shape)
Riptorch
dim=[] reduces every dim (the empty dim list means all, as for sum)
Measured
logsumexp([[1., 2.]], dim=[]): Riptorch 2.3132615, PyTorch CPU and MPS RuntimeError
Stock behaviour
torch.set_compat("pytorch")
Tensor.lstsqfunctionSame as PyTorch
lstsq(*a, _m='torch.lstsq is deprecated in favor of torch.linalg.lstsq and will be removed in a future PyTorch release.', **k)

Removed from PyTorch: raises RuntimeError as PyTorch does (torch.lstsq is deprecated in favor of torch.linalg.lstsq and will be removed in a future PyTorch release.)

Tensor.ltfunctionSame as PyTorch
lt(input, other)

Elementwise <, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.

Tensor.lufunctionSame as PyTorch
lu(self, pivot=True, get_infos=False)

(LU, pivots) from linalg.lu_factor, plus zero infos with get_infos=True (deprecated in PyTorch).

Tensor.lu_solvefunctionSame as PyTorch
lu_solve(b, LU_data, LU_pivots, *, out=None)

torch.lu_solve(b, LU_data, LU_pivots) (deprecated in PyTorch): linalg.lu_solve with the arguments in the old order.

Tensor.masked_fillfunctionSame as PyTorch
masked_fill(input, mask, value)

value where mask is true, else the input; the result keeps the input's dtype.

Tensor.masked_scatterfunctionSame as PyTorch
masked_scatter(input, mask, source)

A copy of input whose True positions of mask (broadcast), in row-major order, take source's leading elements.

Tensor.masked_selectfunctionSame as PyTorch
masked_select(input, mask, *, out=None)

The elements of input where mask (broadcast with it) is True, as a 1-d tensor in row-major order.

Tensor.matmulfunctionDifferent from PyTorch
matmul(input, other)

Different from PyTorch: exact integer products (int8 -> int32, int16/int32 -> int64) and int8 @ uint8; PyTorch wraps 200 of 200 entries of a 10x64 @ 64x20 int8 product (and its CPU float16 matmul is 249x slower), MLX has no integer matmul; fastest exact path at 4096 (quiet Mac, November 24, 2026): int8 x uint8 2.7 ms vs 136 ms PyTorch and 217 ms MLX, int16 10.2 vs 260 and 217; int8 @ int8 2.4 vs 3.2 ms (PyTorch MPS _int_mm, alternating runs)

PyTorch
integer matmul keeps the input dtype and wraps modulo 2^bits silently (int8, int16, int32, uint8: 200 of 200 entries wrong on 10x64 @ 64x20); int8 @ uint8 raises; float16 / bfloat16 on the CPU run 213x-836x slower than float32
Riptorch
exact: int8 / uint8 -> int32, int16 / int32 -> int64 (CPU matrix unit, GPU int8 hardware); int8 @ uint8 exact int32; 16-bit floats on the matrix unit (0.30 ms vs 74.7 ms at 512)
Measured
200/200 wrong (PyTorch) vs 0 (Riptorch) per dtype; fp16 512x512 74.7 ms vs 0.30 ms
Stock behaviour
torch.set_compat("pytorch")
Tensor.matrix_expfunctionSame as PyTorch
matrix_exp(A)

linalg.matrix_exp(A): Pade-13 scaling and squaring (Higham 2005). Gradient: the exponential of the block matrix [[A^T, G], [0, A^T]] (its top-right block).

Tensor.matrix_powerfunctionSame as PyTorch
matrix_power(A, n, *, out=None)

linalg.matrix_power(A, n): repeated squaring (n < 0: of the inverse); n = 0 gives the identity.

Tensor.maxfunctionSame as PyTorch
max(*a, **k)

max(Tensor self, dim=None, bool keepdim=False)

max(x) is the largest value; max(x, dim) is (values, indices); max(x, y) is the elementwise maximum.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.maximumfunctionSame as PyTorch
maximum(input, other)

Elementwise maximum of two tensors; a NaN in either input gives NaN, as in PyTorch. Every dtype; autograd for the floating-point types.

Tensor.meanfunctionSame as PyTorch
mean(Tensor self, int[]? dim=None, bool keepdim=False, *, dtype? dtype=None) -> Tensor

Mean over all elements or along dim; dtype= casts first. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.medianfunctionSame as PyTorch
median(input, dim=None, keepdim=False, *, out=None)

The lower median (PyTorch's: not the mean of the two middle values), and with dim its index; NaN propagates.

Tensor.minfunctionSame as PyTorch
min(*a, **k)

min(Tensor self, dim=None, bool keepdim=False)

min(x): the smallest element; min(x, dim): (values, indices); min(x, y): the elementwise minimum.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.minimumfunctionSame as PyTorch
minimum(input, other)

Elementwise minimum of two tensors; a NaN in either input gives NaN, as in PyTorch. Every dtype; autograd for the floating-point types.

Tensor.mmfunctionDifferent from PyTorch
mm(input, mat2, *, out=None)

Matrix product of two 2-d tensors; a sparse operand goes to the sparse product (dense result for sparse @ dense, as PyTorch).

Different from PyTorch: exact integer products like torch.matmul; PyTorch keeps the input dtype and wraps (200 of 200 int8 entries wrong on 10x64 @ 64x20)

PyTorch
integer mm keeps the input dtype and wraps modulo 2^bits
Riptorch
exact (as torch.matmul)
Measured
as torch.matmul
Stock behaviour
torch.set_compat("pytorch")
Tensor.modefunctionSame as PyTorch
mode(input, dim=-1, keepdim=False, *, out=None)

The most frequent value along dim (the smallest on ties) and an index of it (its last occurrence, as PyTorch's CPU).

Tensor.module_loadfunctionSame as PyTorch
module_load(self, other, assign=False)

What load_state_dict copies into this parameter: other (detached when assign=True).

Tensor.moveaxisfunctionSame as PyTorch
moveaxis(input, source, destination)

input with the dims at source moved to destination (ints or sequences), the others in order; a view.

Tensor.movedimfunctionSame as PyTorch
movedim(*a, **k)

input with the dims at source moved to destination (ints or sequences), the others in order; a view.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.msortfunctionSame as PyTorch
msort(input)

Sorts along dim 0 (ascending).

Tensor.mtiafunctionSame as PyTorch
mtia(self, device=None, non_blocking=False, memory_format=None)

Raises AssertionError: no MTIA (as PyTorch does on a Mac).

Tensor.mulfunctionSame as PyTorch
mul(input, other)

Elementwise product, with broadcasting and PyTorch type promotion. Every dtype; autograd for the floating-point types.

Tensor.multinomialfunctionSame as PyTorch
multinomial(self, num_samples, replacement=False, *, generator=None)

Tensor.multinomial: torch.multinomial(self, num_samples, replacement).

Tensor.multiplyfunctionSame as PyTorch
multiply(input, other)

torch.multiply(self, *args, **kwargs).

Tensor.mvfunctionSame as PyTorch
mv(input, vec, *, out=None)

Matrix-vector product (2-d @ 1-d); other ranks raise as PyTorch.

Tensor.mvlgammafunctionSame as PyTorch
mvlgamma(input, p, *, out=None)

The multivariate log-gamma function of dimension p: p(p-1)/4 log(pi) + sum_j lgamma(x - j/2).

Tensor.nan_to_numfunctionSame as PyTorch
nan_to_num(input, nan=0.0, posinf=None, neginf=None)

NaN, +inf and -inf replaced by nan, posinf and neginf (default: 0 and the dtype's largest / smallest finite values).

Tensor.nanmeanfunctionSame as PyTorch
nanmean(input, dim=None, keepdim=False, *, dtype=None, out=None)

Mean of the non-NaN elements, over dim or over all elements (NaN where every element is NaN). dtype= is accepted and ignored.

Tensor.nanmedianfunctionSame as PyTorch
nanmedian(input, dim=None, keepdim=False, *, out=None)

The lower median of the non-NaN elements (NaN only when all are NaN); with dim, (values, indices).

Computed from the values read back: not differentiable.

Tensor.nanquantilefunctionSame as PyTorch
nanquantile(input, q, dim=None, keepdim=False, *, interpolation='linear', out=None)

quantile ignoring NaN: NaN only where a row has no other values.

Tensor.nansumfunctionSame as PyTorch
nansum(input, dim=None, keepdim=False, *, dtype=None)

Sum with NaN counted as zero, over dim or over all elements. dtype= is accepted and ignored.

Tensor.narrowfunctionSame as PyTorch
narrow(Tensor self, int dim, int start, int length) -> Tensor

The slice [start, start + length) along dim. Dtypes: every dtype (autograd for the floating-point types).

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.narrow_copyfunctionSame as PyTorch
narrow_copy(self, dim, start, length)

narrow(dim, start, length) as a new tensor.

Tensor.ndimensionfunctionSame as PyTorch
ndimension(self)

The number of dimensions (ndimension too).

Tensor.nefunctionSame as PyTorch
ne(input, other)

Elementwise !=, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.

Tensor.negfunctionSame as PyTorch
neg(input)

-x. Every dtype; autograd for the floating-point types.

Tensor.negativefunctionSame as PyTorch
negative(input)

-x (alias of neg). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.newfunctionSame as PyTorch
new(self, *args)

Legacy constructor in self's dtype: new(data_list) builds from data, new(*size) a zero-filled tensor.

Tensor.new_empty_stridedfunctionSame as PyTorch
new_empty_strided(self, size, stride, *, dtype=None, **kw)

A zero-filled tensor of size in self's dtype; stride is ignored (contiguous layout).

Tensor.nextafterfunctionSame as PyTorch
nextafter(input, other, *, out=None)

The next representable value after input in the direction of other, in input's float type (one float32 ulp for float32, one float64 ulp for float64); NaN if either is NaN.

Tensor.nonzerofunctionSame as PyTorch
nonzero(self, *, as_tuple=False)

torch.nonzero(self, as_tuple=as_tuple).

Tensor.nonzero_staticfunctionSame as PyTorch
nonzero_static(input, *, size, fill_value=-1)

nonzero cut or padded to exactly size rows (padding rows filled with fill_value), int64 (n, input.dim).

Tensor.normfunctionSame as PyTorch
norm(self, p: float | str | None = 'fro', dim=None, keepdim=False, dtype=None)

torch.norm / Tensor.norm (deprecated in PyTorch): 'nuc' and 'fro' over two dims are matrix norms; everything else is the vector norm it always was.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.not_equalfunctionSame as PyTorch
not_equal(input, other)

Alias of Tensor.ne.

Elementwise !=, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.

Tensor.orgqrfunctionSame as PyTorch
orgqr(A, tau, *, out=None)

linalg.householder_product(A, tau): the first n columns of H_1... H_k (LAPACK orgqr).

Tensor.ormqrfunctionSame as PyTorch
ormqr(input, tau, other, left=True, transpose=False, *, out=None)

torch.ormqr(a, tau, C, left=True, transpose=False): C multiplied by Q from geqrf's reflectors.

Tensor.outerfunctionSame as PyTorch
outer(input, vec2, *, out=None)

The outer product of two vectors (ger too).

Tensor.permutefunctionSame as PyTorch
permute(input, *dims)

Reorders the dimensions. Dtypes: every dtype (autograd for the floating-point types).

Tensor.pin_memoryfunctionSame as PyTorch
pin_memory(self, *args, **kwargs)

Tensor.cpu / cuda / mps / pin_memory: the tensor itself (one unified memory and one layout).

Tensor.pinversefunctionSame as PyTorch
pinverse(input, rcond=1e-15)

torch.pinverse: linalg.pinv with rtol=rcond.

Tensor.polygammafunctionSame as PyTorch
polygamma(self, n)

torch.polygamma(n, self): the n-th derivative of digamma.

Tensor.positivefunctionSame as PyTorch
positive(input)

x unchanged. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.powfunctionSame as PyTorch
pow(self, exponent)

torch.pow(self, exponent).

Tensor.prelufunctionSame as PyTorch
prelu(self, weight)

nn.functional.prelu(self, weight).

Tensor.prodfunctionSame as PyTorch
prod(input, dim=None, keepdim=False, *, dtype=None)

Product of the elements, over dim or over all of them; dtype= casts first.

Floats go through cumprod (differentiable). Integers and bool are multiplied exactly in Python integers and returned as int64.

Tensor.putfunctionSame as PyTorch
put(input, index, source, accumulate=False)

A copy of input with the flat positions index set to source's values (accumulate=True: added instead).

Tensor.q_per_channel_axisfunctionSame as PyTorch
q_per_channel_axis(input)

The per-channel axis of a quantized tensor (raises for a float tensor, as PyTorch).

Tensor.q_per_channel_scalesfunctionSame as PyTorch
q_per_channel_scales(input)

The per-channel scales of a quantized tensor (raises for a float tensor, as PyTorch).

Tensor.q_per_channel_zero_pointsfunctionSame as PyTorch
q_per_channel_zero_points(input)

The per-channel zero points of a quantized tensor (raises for a float tensor).

Tensor.q_scalefunctionSame as PyTorch
q_scale(input)

The scale of a per-tensor quantized tensor (raises for a float tensor, as PyTorch).

Tensor.q_zero_pointfunctionSame as PyTorch
q_zero_point(input)

The zero point of a per-tensor quantized tensor (raises for a float tensor, as PyTorch).

Tensor.qrfunctionSame as PyTorch
qr(A, some=True, *, out=None)

torch.qr (deprecated in PyTorch): linalg.qr with mode 'reduced' (some=True) or 'complete'.

Tensor.qschemefunctionSame as PyTorch
qscheme(name)

The quantization scheme of a quantized tensor (raises for a float tensor, as PyTorch).

Tensor.quantilefunctionSame as PyTorch
quantile(input, q, dim=None, keepdim=False, *, interpolation='linear', out=None, _nan=False)

The q-th quantiles (q a float or a 1-d tensor, each in [0, 1]) over dim or over all elements.

interpolation: 'linear' (default), 'lower', 'higher', 'nearest' or 'midpoint'. A NaN in a row gives NaN. With a tensor q the quantiles stack along a new leading dim. Computed from the sorted values read back: not differentiable.

Tensor.rad2degfunctionSame as PyTorch
rad2deg(input)

Radians to degrees. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.ravelfunctionSame as PyTorch
ravel(input)

input flattened to 1-d.

Tensor.reciprocalfunctionSame as PyTorch
reciprocal(input)

1 / x. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.record_streamfunctionSame as PyTorch
record_stream(self, stream)

Nothing to do: Riptorch has no device streams to track.

register_post_accumulate_grad_hook(self, hook)

Same as PyTorch’s torch.Tensor.register_post_accumulate_grad_hook.

Tensor.reinforcefunctionSame as PyTorch
reinforce(self, reward)

Removed in PyTorch: raises its RuntimeError (use torch.distributions).

Tensor.relufunctionSame as PyTorch
relu(input, inplace=False)

max(x, 0). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.remainderfunctionDifferent from PyTorch
remainder(input, other, *, out=None)

Different from PyTorch: float32 remainder is one rounding of the exact x - floor(x / y) y for every input: 0 of 20000 random pairs wrong where PyTorch MPS gets 10511 wrong (and remainder(7, -inf) is nan there)

PyTorch
CPU: correctly rounded too; MPS: 10511 of 20000 random pairs wrong, remainder(7, -inf) = nan
Riptorch
the exact remainder rounded once (one rounding, the divisor's sign), on every device
Measured
20000 random float32 pairs, x up to 1e12, y down to 1e-6: Riptorch 0 wrong, PyTorch CPU 0, PyTorch MPS 10511 (8293 in the rules doc's sample)
Stock behaviour
none: PyTorch's CPU kernel already gives these values; MPS's errors are not reproduced
Tensor.renormfunctionSame as PyTorch
renorm(input, p, dim, maxnorm)

input with each slice along dim (taken over all other dims) scaled down so its p-norm is at most maxnorm (scale maxnorm / (norm + 1e-7), as PyTorch).

Tensor.repeatfunctionSame as PyTorch
repeat(input, *repeats)

Tensor.repeat: the tensor tiled repeats[i] times along each dim (leading new dims allowed); lazy, gradients summed back.

Tensor.repeat_interleavefunctionSame as PyTorch
repeat_interleave(self, repeats=None, dim=None, *, output_size=None)

torch.repeat_interleave(self, repeats, dim).

Tensor.resizefunctionSame as PyTorch
resize(self, *size)

A tensor of the given size from self's elements in row-major order, cut short or extended with zeros (deprecated in PyTorch; a new tensor here).

Tensor.resize_asfunctionSame as PyTorch
resize_as(self, other)

resize to other's shape.

Tensor.resolve_conjfunctionSame as PyTorch
resolve_conj(self)

self: there is never a lazy conjugate or negation to resolve.

Tensor.resolve_negfunctionSame as PyTorch
resolve_neg(self)

self: there is never a lazy conjugate or negation to resolve.

Tensor.rollfunctionSame as PyTorch
roll(Tensor input, int[] shifts, int[] dims=()) -> Tensor

Each dim rotated by its shift: two narrows joined by cat. No dims: the flattened tensor, as PyTorch.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.rot90functionSame as PyTorch
rot90(input, k=1, dims=(0, 1))

input rotated by 90 degrees k times in the plane of dims, from the first dim towards the second.

Tensor.roundfunctionSame as PyTorch
round(self, decimals=0)

torch.round(self, decimals=decimals).

Tensor.row_indicesfunctionSame as PyTorch
row_indices(self, *a, **k)

Raises RuntimeError as PyTorch on a dense tensor: row_indices needs a sparse column compressed tensor.

Tensor.rsqrtfunctionSame as PyTorch
rsqrt(input)

Classic only: as an elementwise op it has no rational form (the rational RMSNorm is a module-level row).

Tensor.scatterfunctionSame as PyTorch
scatter(input, dim, index, src=None, *, value=None, reduce=None)

A copy of input with src (or the scalar value) written at index along dim; reduce='add' / 'sum' adds and 'multiply' / 'prod' multiplies into the existing values instead of overwriting.

Tensor.scatter_addfunctionSame as PyTorch
scatter_add(input, dim, index, src)

scatter with reduce='add': repeated indices accumulate.

Tensor.scatter_reducefunctionSame as PyTorch
scatter_reduce(input, dim, index, src, reduce, *, include_self=True)

A copy of input with src reduced into it at index along dim: reduce is 'sum', 'prod', 'mean', 'amax' or 'amin'; include_self=False leaves input's values out of the reduction. Integer 'mean' rounds down. Computed on the values (not differentiable).

Tensor.selectfunctionSame as PyTorch
select(*a, **k)

The slice at index along dim, with dim removed; negative indices count from the end; IndexError outside.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.select_scatterfunctionSame as PyTorch
select_scatter(input, src, dim, index)

A copy of input with input.select(dim, index) replaced by src.

Tensor.sgnfunctionSame as PyTorch
sgn(input)

-1, 0 or 1 by sign (sgn too). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.sigmoidfunctionSame as PyTorch
sigmoid(input, *, maths=None)

1 / (1 + exp(-x)). Under maths="rational": (1 + softsign(x)) / 2, order 2 (a different function in the same role). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.signfunctionSame as PyTorch
sign(self)

torch.sign(self): +-1, 0 for 0 and NaN (as PyTorch).

Tensor.signbitfunctionSame as PyTorch
signbit(input, *, out=None)

True where the sign bit is set: negative values and -0.0 (integers: x < 0).

Tensor.sinfunctionDifferent from PyTorch
sin(input)

Different from PyTorch: float32 sin within 1 ulp on [-100, 100]: worst 0.64 ulps of the exact value where PyTorch's CPU kernel has 1.71 (CPU and MPS: 2 ulps after rounding)

PyTorch
float32 sin up to 2 ulps off
Riptorch
argument reduction by pi/2 in parts and a polynomial in float32 (Riptide sin node)
Measured
1500 points of [-100, 100]: Riptorch 0.64, PyTorch CPU 1.71 ulps of the exact value max 1 vs 2 ulps
Stock behaviour
none: an accuracy gain, PyTorch's rounding is not reproduced
Tensor.sincfunctionSame as PyTorch
sinc(input, *, out=None)

Same as PyTorch’s torch.Tensor.sinc.

Tensor.sinhfunctionSame as PyTorch
sinh(input)

Hyperbolic sine. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.slice_inversefunctionSame as PyTorch
slice_inverse(input, src, dim=0, start=None, end=None, step=1)

The base a slice was taken from (for functionalization): src, viewed as itself.

Tensor.slice_scatterfunctionSame as PyTorch
slice_scatter(input, src, dim=0, start=None, end=None, step=1)

A copy of input with the slice start:end:step of dim replaced by src.

Tensor.slogdetfunctionSame as PyTorch
slogdet(A, *, out=None, maths=None)

Same as PyTorch’s torch.Tensor.slogdet.

Tensor.smmfunctionSame as PyTorch
smm(self, mat2)

torch.smm(self, mat2): sparse self @ dense mat2, returned sparse (a dense self raises).

Tensor.softmaxfunctionSame as PyTorch
softmax(Tensor input, int? dim=None, *, dtype? dtype=None) -> Tensor

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.solvefunctionSame as PyTorch
solve(*a, _m='torch.solve is deprecated in favor of torch.linalg.solve and will be removed in a future PyTorch release.', **k)

Removed from PyTorch: raises RuntimeError as PyTorch does (torch.solve is deprecated in favor of torch.linalg.solve and will be removed in a future PyTorch release.)

Tensor.sortfunctionSame as PyTorch
sort(Tensor self, int dim=-1, bool descending=False, *, bool? stable=False) -> (Tensor values, Tensor indices)

Always stable (equal values keep their order), so stable=False gives the stable order too.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.sparse_dimfunctionSame as PyTorch
sparse_dim(self)

0: a dense tensor has no sparse dims.

Tensor.sparse_maskfunctionSame as PyTorch
sparse_mask(d, mask)

dense.sparse_mask(mask): mask's pattern with d's values there.

Tensor.splitfunctionSame as PyTorch
split(Tensor self, split_size_or_sections, int dim=0) -> Tensor[]

Pieces are narrows: lazy views with gradients on float32 tensors.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.split_with_sizesfunctionSame as PyTorch
split_with_sizes(input, split_sizes, dim=0)

Consecutive pieces of input along dim with the given sizes, as a tuple.

Tensor.sqrtfunctionSame as PyTorch
sqrt(input)

Elementwise square root (NaN below 0). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.squarefunctionSame as PyTorch
square(input)

x * x. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.squeezefunctionSame as PyTorch
squeeze(Tensor self, dim=None) -> Tensor

Removes size-1 dimensions (all, or the given dim / dims when they have size 1).

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.sspaddmmfunctionSame as PyTorch
sspaddmm(self, mat1, mat2, *, beta=1, alpha=1)

torch.sspaddmm(self, mat1, mat2): beta * self + alpha * (mat1 @ mat2), sparse.

Tensor.stdfunctionSame as PyTorch
std(input, dim=None, unbiased=None, keepdim=False, *, correction=None, out=None)

Standard deviation over dim (all elements when dim is None): the square root of torch.var.

correction= (or unbiased=True / False for 1 / 0); PyTorch's positional std(x, dim) spelling is accepted.

Tensor.stftfunctionSame as PyTorch
stft(input, n_fft, hop_length=None, win_length=None, window=None, center=True, pad_mode='reflect', normalized=False, onesided=None, return_complex=None, align_to_window=None)

Short-time Fourier transform of a 1-d signal or a batch of them, through torch.fft.

Frames of n_fft samples every hop_length (default n_fft // 4), multiplied by window (centered and zero-padded when shorter than n_fft; ones by default); center=True pads n_fft // 2 on both sides with pad_mode. Output (freq, frames), onesided by default. return_complex must be given for real input, as PyTorch.

Tensor.storage_offsetfunctionSame as PyTorch
storage_offset(self)

0: a Riptorch tensor always starts at the beginning of its own storage.

Tensor.storage_typefunctionSame as PyTorch
storage_type(self)

The legacy storage class of this tensor's dtype (torch.FloatStorage for float32,...).

Tensor.subfunctionSame as PyTorch
sub(input, other, *, alpha=1)

self - alpha * other, with broadcasting and PyTorch type promotion. Every dtype; autograd for the floating-point types.

Tensor.subtractfunctionSame as PyTorch
subtract(input, other, *, alpha=1)

torch.subtract(self, *args, **kwargs).

Tensor.sumfunctionDifferent from PyTorch
sum(*a, **k)

Different from PyTorch: float64 sums compensated: the sum of 1e5 normal values is 3.39e-15 off the exact sum where PyTorch's is 5.35e-14 (1e6 values: 3.05e-14 vs 7.13e-13)

PyTorch
float64 sum by pairwise blocks in float64
Riptorch
float64 CPU programs sum with compensation (an error term carried with the running sum)
Measured
2026-11-24: 1e5 normal values 3.39e-15 vs 5.35e-14 absolute error; 1e6: 3.05e-14 vs 7.13e-13
Stock behaviour
none: an accuracy gain, PyTorch's rounding is not reproduced
Tensor.sum_to_sizefunctionSame as PyTorch
sum_to_size(input, *size)

input summed down to size: leading extra dims summed away, dims that are 1 in size summed with keepdim (the reverse of broadcasting).

Tensor.svdfunctionSame as PyTorch
svd(A, some=True, compute_uv=True, *, out=None)

torch.svd (deprecated in PyTorch): (U, S, V) with V not transposed; some=False gives the full U and V; compute_uv=False gives zero U and V, as PyTorch.

Tensor.swapaxesfunctionSame as PyTorch
swapaxes(Tensor self, int dim0, int dim1) -> Tensor

Swaps two dimensions (swapaxes too). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.swapdimsfunctionSame as PyTorch
swapdims(Tensor self, int dim0, int dim1) -> Tensor

Alias of Tensor.transpose.

Swaps two dimensions (swapaxes too). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.symeigfunctionSame as PyTorch
symeig(*a, _m='This function was deprecated since version 1.9 and is now removed. Please use the `torch.linalg.eigh` function instead.', **k)

Removed from PyTorch: raises RuntimeError as PyTorch does (This function was deprecated since version 1.9 and is now removed. Please use the torch.linalg.eigh function instead.)

Tensor.tfunctionSame as PyTorch
t(self)

The transpose of a 2-d tensor; 0-d and 1-d tensors are returned as they are; more dims raise.

Tensor.takefunctionSame as PyTorch
take(input, index)

input's elements at the given flat indices (input read as 1-d), shaped like index.

Tensor.take_along_dimfunctionSame as PyTorch
take_along_dim(*a, **k)

input's values at indices along dim, input and indices broadcast on the other dims; dim=None takes from the flattened input.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.tanfunctionSame as PyTorch
tan(input)

Elementwise tangent. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.tanhfunctionSame as PyTorch
tanh(input, *, maths=None)

Same as PyTorch’s torch.Tensor.tanh.

Tensor.tensor_splitfunctionSame as PyTorch
tensor_split(input, indices_or_sections, dim=0)

input cut along dim into a tuple of pieces: an int k gives k pieces of near-equal size (the first n % k one longer); a list or tensor of indices cuts before each of them.

Tensor.tilefunctionSame as PyTorch
tile(input, dims)

input repeated dims[i] times along each dimension; a dims shorter than input's rank is padded with leading 1s.

Tensor.to_densefunctionDifferent from PyTorch
to_dense(self, dtype=None, *, masked_grad=None)

Different from PyTorch: duplicate entries summed in float64 and rounded once: duplicates [1e8, 1, -1e8] give 1.0, PyTorch gives 0.0

PyTorch
a sparse tensor's duplicate entries summed in the values' dtype, in order
Riptorch
duplicates summed in float64, rounded once (coalesced entries placed as they are)
Measured
duplicates [1e8, 1, -1e8] at one position: PyTorch 0.0, Riptorch 1.0
Stock behaviour
torch.set_compat("pytorch")
Tensor.to_mkldnnfunctionSame as PyTorch
to_mkldnn(self, dtype=None)

Raises RuntimeError("MKL-DNN build is disabled"), as PyTorch does on a Mac.

Tensor.to_padded_tensorfunctionSame as PyTorch
to_padded_tensor(self, padding, output_size=None)

torch.nested.to_padded_tensor(self, padding, output_size) (a dense self raises as PyTorch).

Tensor.to_sparsefunctionSame as PyTorch
to_sparse(self, *args, layout=None, blocksize=None, dense_dim=None)

This dense tensor as a sparse one: COO by default (args[0] = sparse_dim: the leading dims that become sparse), or layout= (blocksize= for BSR / BSC). Zeros are not stored.

Tensor.to_sparse_bscfunctionSame as PyTorch
to_sparse_bsc(self, blocksize, dense_dim=None)

This dense tensor in the BSC sparse layout (zeros not stored; blocksize = (rows, cols)).

Tensor.to_sparse_bsrfunctionSame as PyTorch
to_sparse_bsr(self, blocksize, dense_dim=None)

This dense tensor in the BSR sparse layout (zeros not stored; blocksize = (rows, cols)).

Tensor.to_sparse_coofunctionSame as PyTorch
to_sparse_coo(self)

This dense tensor in the COO sparse layout (zeros not stored).

Tensor.to_sparse_cscfunctionSame as PyTorch
to_sparse_csc(self, dense_dim=None)

This dense tensor in the CSC sparse layout (zeros not stored).

Tensor.to_sparse_csrfunctionSame as PyTorch
to_sparse_csr(self, dense_dim=None)

This dense tensor in the CSR sparse layout (zeros not stored).

Tensor.topkfunctionSame as PyTorch
topk(Tensor self, int k, int dim=-1, bool largest=True, bool sorted=True) -> (Tensor values, Tensor indices)

Partial selection on every core (no full sort for small k) or the GPU; values keep gradients. Results are always sorted (sorted=False is allowed and returns them sorted). Top-k of a score matrix made as an outer product (cosine_similarity(Q[:, None], X[None]), q @ X.T) runs the fused search: the scores are never all computed.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.tracefunctionSame as PyTorch
trace(input)

The sum of the main diagonal.

Tensor.transposefunctionSame as PyTorch
transpose(Tensor self, int dim0, int dim1) -> Tensor

Swaps two dimensions (swapaxes too). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.triangular_solvefunctionSame as PyTorch
triangular_solve(b, A, upper=True, transpose=False, unitriangular=False, *, out=None)

torch.triangular_solve(b, A, upper=True, transpose=False, unitriangular=False) (deprecated in PyTorch).

Tensor.trilfunctionSame as PyTorch
tril(self, diagonal=0)

torch.tril(self, diagonal).

Tensor.triufunctionSame as PyTorch
triu(self, diagonal=0)

torch.triu(self, diagonal).

Tensor.true_dividefunctionSame as PyTorch
true_divide(input, other, *, rounding_mode=None)

Division, true by default; rounding_mode="trunc" or "floor" rounds the quotient. Integer inputs give float32, as PyTorch. Every dtype; autograd for the floating-point types.

Tensor.truncfunctionSame as PyTorch
trunc(input)

Rounds toward zero (fix too). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.unbindfunctionSame as PyTorch
unbind(*a, **k)

A tuple of the slices along dim, each without dim.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.unflattenfunctionSame as PyTorch
unflatten(input, dim, sizes)

input with dim replaced by the given sizes (one of them may be -1).

Tensor.unfoldfunctionSame as PyTorch
unfold(input, dimension, size, step)

Tensor.unfold: every window of size along dimension, step apart, as a new last dim.

Tensor.uniquefunctionSame as PyTorch
unique(input, sorted=True, return_inverse=False, return_counts=False, dim=None)

The distinct values (or distinct slices along dim), sorted; optionally the inverse indices and the counts. sorted=False returns sorted values too (as PyTorch on the CPU for dim=None).

Tensor.unique_consecutivefunctionDifferent from PyTorch
unique_consecutive(input, return_inverse=False, return_counts=False, dim=None)

input with runs of equal consecutive values collapsed to one; optionally the inverse indices and run lengths. dim= raises NotImplementedError.

Different from PyTorch: input with runs of equal consecutive values collapsed to one; optionally the inverse indices and run lengths. dim= raises NotImplementedError.

Tensor.unsafe_chunkfunctionSame as PyTorch
unsafe_chunk(self, chunks, dim=0)

chunk (the same pieces; nothing is unsafe here).

Tensor.unsafe_splitfunctionSame as PyTorch
unsafe_split(self, split_size, dim=0)

split (the same pieces; nothing is unsafe here).

Tensor.unsafe_split_with_sizesfunctionSame as PyTorch
unsafe_split_with_sizes(self, sizes, dim=0)

split_with_sizes (the same pieces; nothing is unsafe here).

Tensor.unsqueezefunctionSame as PyTorch
unsqueeze(Tensor self, int dim) -> Tensor

Inserts a size-1 dimension at dim (negative dims count from the end of the result). Dtypes: every dtype (autograd for the floating-point types).

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.valuesfunctionSame as PyTorch
values(self)

Raises RuntimeError as PyTorch on a dense tensor: values needs a sparse tensor.

Tensor.varfunctionSame as PyTorch
var(Tensor self, int[]? dim=None, *, float correction=1, bool keepdim=False, bool? unbiased=None) -> Tensor

Variance over all elements or along dim with Bessel's correction (correction=, or unbiased=). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.

Tensor.vdotfunctionSame as PyTorch
vdot(input, other, *, out=None)

Dot product of the flattened inputs: sum(input * other). Complex input is not conjugated (PyTorch conjugates the first argument).

Tensor.vsplitfunctionSame as PyTorch
vsplit(input, sections)

tensor_split along dim 0.

Tensor.wherefunctionSame as PyTorch
where(self, condition, other)

Tensor.where(condition, other): self where condition holds, else other.

Tensor.xlogyfunctionSame as PyTorch
xlogy(input, other)

x * log(y), 0 where x is 0. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Tensor.xpufunctionSame as PyTorch
xpu(self, device=None, non_blocking=False, memory_format=None)

Raises AssertionError: no XPU (as PyTorch does on a Mac).

In-place methods

Tensor.abs_functionSame as PyTorch
abs_(input)

In-place form: the out-of-place result written into self. Raises on a leaf that requires grad while grad mode is on, as PyTorch.

Tensor.absolute_functionSame as PyTorch
absolute_(input)

absolute in place: self takes the result of absolute(self,...); returns self.

Tensor.acos_functionSame as PyTorch
acos_(input, *, out=None)

acos in place: self takes the result of acos(self,...); returns self.

Tensor.acosh_functionSame as PyTorch
acosh_(input)

acosh in place: self takes the result of acosh(self,...); returns self.

Tensor.add_functionSame as PyTorch
add_(input, other, *, alpha=1)

In-place form: the out-of-place result written into self. Raises on a leaf that requires grad while grad mode is on, as PyTorch.

Tensor.addbmm_functionSame as PyTorch
addbmm_(self, b1, b2, *, beta=1, alpha=1)

addbmm in place on self; returns self.

Tensor.addcdiv_functionSame as PyTorch
addcdiv_(input, tensor1, tensor2, *, value=1)

In-place form: the out-of-place result written into self. Raises on a leaf that requires grad while grad mode is on, as PyTorch.

Tensor.addcmul_functionSame as PyTorch
addcmul_(input, tensor1, tensor2, *, value=1)

In-place form: the out-of-place result written into self. Raises on a leaf that requires grad while grad mode is on, as PyTorch.

Tensor.addmm_functionSame as PyTorch
addmm_(input, mat1, mat2, *, beta=1, alpha=1)

addmm in place: self takes the result of addmm(self,...); returns self.

Tensor.addmv_functionSame as PyTorch
addmv_(input, mat, vec, *, beta=1, alpha=1, out=None)

addmv in place: self takes the result of addmv(self,...); returns self.

Tensor.addr_functionSame as PyTorch
addr_(input, vec1, vec2, *, beta=1, alpha=1, out=None)

addr in place: self takes the result of addr(self,...); returns self.

Tensor.apply_functionSame as PyTorch
apply_(self, fn)

In place: each element x becomes fn(x) (a Python callable, run on the values read back).

Tensor.arccos_functionSame as PyTorch
arccos_(input, *, out=None)

arccos in place: self takes the result of arccos(self,...); returns self.

Tensor.arccosh_functionSame as PyTorch
arccosh_(input)

arccosh in place: self takes the result of arccosh(self,...); returns self.

Tensor.arcsin_functionSame as PyTorch
arcsin_(input, *, out=None)

arcsin in place: self takes the result of arcsin(self,...); returns self.

Tensor.arcsinh_functionSame as PyTorch
arcsinh_(input)

arcsinh in place: self takes the result of arcsinh(self,...); returns self.

Tensor.arctan2_functionSame as PyTorch
arctan2_(input, other, *, out=None)

arctan2 in place: self takes the result of arctan2(self,...); returns self.

Tensor.arctan_functionSame as PyTorch
arctan_(input, *, out=None)

arctan in place: self takes the result of arctan(self,...); returns self.

Tensor.arctanh_functionSame as PyTorch
arctanh_(input)

arctanh in place: self takes the result of arctanh(self,...); returns self.

Tensor.as_strided_functionSame as PyTorch
as_strided_(input, size, stride, storage_offset=None)

In-place as_strided: the tensor becomes the strided view's values (Riptorch copies; no shared storage).

Tensor.asin_functionSame as PyTorch
asin_(input, *, out=None)

asin in place: self takes the result of asin(self,...); returns self.

Tensor.asinh_functionSame as PyTorch
asinh_(input)

asinh in place: self takes the result of asinh(self,...); returns self.

Tensor.atan2_functionSame as PyTorch
atan2_(input, other, *, out=None)

In-place Tensor.atan2: the result written into self (self's dtype kept).

Tensor.atan_functionSame as PyTorch
atan_(input, *, out=None)

In-place Tensor.atan: the result written into self (self's dtype kept).

Tensor.atanh_functionSame as PyTorch
atanh_(input)

atanh in place: self takes the result of atanh(self,...); returns self.

Tensor.baddbmm_functionSame as PyTorch
baddbmm_(input, batch1, batch2, *, beta=1, alpha=1, out=None)

baddbmm in place: self takes the result of baddbmm(self,...); returns self.

Tensor.bernoulli_functionSame as PyTorch
bernoulli_(self, p=0.5, *, generator=None)

Tensor.bernoulli_(p=0.5): fills with 1 with probability p (a float or a tensor broadcast to self), else 0. In place; the dtype is kept.

Tensor.bitwise_and_functionSame as PyTorch
bitwise_and_(input, other)

bitwise_and in place: self takes the result of bitwise_and(self,...); returns self.

Tensor.bitwise_left_shift_functionSame as PyTorch
bitwise_left_shift_(self, other)

bitwise_left_shift in place; returns self.

Tensor.bitwise_not_functionSame as PyTorch
bitwise_not_(input)

bitwise_not in place: self takes the result of bitwise_not(self,...); returns self.

Tensor.bitwise_or_functionSame as PyTorch
bitwise_or_(input, other)

bitwise_or in place: self takes the result of bitwise_or(self,...); returns self.

Tensor.bitwise_right_shift_functionSame as PyTorch
bitwise_right_shift_(self, other)

bitwise_right_shift in place; returns self.

Tensor.bitwise_xor_functionSame as PyTorch
bitwise_xor_(input, other)

bitwise_xor in place: self takes the result of bitwise_xor(self,...); returns self.

Tensor.cauchy_functionSame as PyTorch
cauchy_(self, median=0.0, sigma=1.0, *, generator=None)

Tensor.cauchy_(median=0, sigma=1): fills with Cauchy draws, median + sigma tan(pi (U - 1/2)). In place.

Tensor.ceil_functionSame as PyTorch
ceil_(input)

ceil in place: self takes the result of ceil(self,...); returns self.

Tensor.clamp_functionSame as PyTorch
clamp_(input, min=None, max=None)

In-place form: the out-of-place result written into self. Raises on a leaf that requires grad while grad mode is on, as PyTorch.

Tensor.clamp_max_functionSame as PyTorch
clamp_max_(input, max)

clamp_max in place: self takes the result of clamp_max(self,...); returns self.

Tensor.clamp_min_functionSame as PyTorch
clamp_min_(input, min)

In-place form: the out-of-place result written into self. Raises on a leaf that requires grad while grad mode is on, as PyTorch.

Tensor.clip_functionSame as PyTorch
clip_(input, min=None, max=None)

clip in place: self takes the result of clip(self,...); returns self.

Tensor.conj_physical_functionSame as PyTorch
conj_physical_(input)

In-place conjugate; real tensors are returned unchanged.

Tensor.copy_functionSame as PyTorch
copy_(self, src, non_blocking=False)

Writes src (broadcast, converted to this dtype) into this tensor in place; a view writes through.

Tensor.copysign_functionSame as PyTorch
copysign_(input, other, *, out=None)

copysign in place: self takes the result of copysign(self,...); returns self.

Tensor.cos_functionDifferent from PyTorch
cos_(input)

cos in place: self takes the result of cos(self,...); returns self.

Different from PyTorch: float32 cos within 1 ulp of the correctly rounded value: worst 1.08 ulps of the exact value on [-100, 100] where PyTorch's CPU kernel has 1.57 (CPU and MPS: 2 ulps after rounding)

PyTorch
float32 cos up to 2 ulps off
Riptorch
float32: sin(x + pi/2) with the roundings of x + pi/2 and of pi/2 put back; float64: Cody-Waite reduction by pi/2 in three parts
Measured
1500 points of [-100, 100]: Riptorch 1.08, PyTorch CPU 1.57 ulps of the exact value max 1 vs 2 ulps on [-1e-3, 1e-3], [1.5, 1.65], [-100, 100]
Stock behaviour
none: an accuracy gain, PyTorch's rounding is not reproduced
Tensor.cosh_functionSame as PyTorch
cosh_(input)

cosh in place: self takes the result of cosh(self,...); returns self.

Tensor.cumprod_functionSame as PyTorch
cumprod_(self, *a, **k)

In-place Tensor.cumprod: the result written into self (self's dtype kept).

Tensor.cumsum_functionSame as PyTorch
cumsum_(self, dim, *, dtype=None)

In-place torch.cumsum(self, dim, dtype=dtype); the dtype is kept.

Tensor.deg2rad_functionSame as PyTorch
deg2rad_(input)

deg2rad in place: self takes the result of deg2rad(self,...); returns self.

Tensor.digamma_functionDifferent from PyTorch
digamma_(self)

In-place torch.digamma: the result written into self (self's dtype kept).

Different from PyTorch: correctly rounded float32 values (computed in float64, rounded once); 1499 inputs in [-4.9, 5.7]: worst 125285 ulp (PyTorch) vs 0; MLX has no digamma

PyTorch
float32 kernels in float32 precision: values off by several ulp
Riptorch
computed in float64, rounded once to float32 (correctly rounded)
Measured
float32: 1499 inputs in [-4.9, 5.7]: worst 125285 ulp (PyTorch) vs 0
Stock behaviour
not reproduced: PyTorch's values come from its own float32 polynomial kernels, which Riptorch does not copy (compat keeps Riptorch's correctly rounded values)
Tensor.div_functionSame as PyTorch
div_(input, other, *, rounding_mode=None)

In-place form: the out-of-place result written into self. Raises on a leaf that requires grad while grad mode is on, as PyTorch.

Tensor.divide_functionSame as PyTorch
divide_(input, other, *, rounding_mode=None)

divide in place: self takes the result of divide(self,...); returns self.

Tensor.eq_functionSame as PyTorch
eq_(input, other)

eq in place: self takes the result of eq(self,...); returns self.

Tensor.erf_functionSame as PyTorch
erf_(input)

erf in place: self takes the result of erf(self,...); returns self.

Tensor.erfc_functionSame as PyTorch
erfc_(input)

erfc in place: self takes the result of erfc(self,...); returns self.

Tensor.erfinv_functionDifferent from PyTorch
erfinv_(self)

In-place torch.erfinv: the result written into self (self's dtype kept).

Different from PyTorch: correctly rounded float32 values (computed in float64, rounded once); 1999 inputs in [0.9999, 1]: every value off, worst 127 ulp vs 0; MLX's GPU erfinv is up to 3 ulp off there

PyTorch
float32 kernels in float32 precision: values off by several ulp
Riptorch
computed in float64, rounded once to float32 (correctly rounded)
Measured
float32: 1999 inputs in [0.9999, 1]: every value off, worst 127 ulp vs 0
Stock behaviour
not reproduced: PyTorch's values come from its own float32 polynomial kernels, which Riptorch does not copy (compat keeps Riptorch's correctly rounded values)
Tensor.exp2_functionSame as PyTorch
exp2_(input)

exp2 in place: self takes the result of exp2(self,...); returns self.

Tensor.exp_functionSame as PyTorch
exp_(input)

In-place form: the out-of-place result written into self. Raises on a leaf that requires grad while grad mode is on, as PyTorch.

Tensor.expm1_functionSame as PyTorch
expm1_(input)

expm1 in place: self takes the result of expm1(self,...); returns self.

Tensor.exponential_functionSame as PyTorch
exponential_(self, lambd=1.0, *, generator=None)

Tensor.exponential_(lambd=1): fills with Exponential(rate lambd) draws, -log1p(-U) / lambd. In place.

Tensor.fill_functionSame as PyTorch
fill_(tensor, val)

Fills the tensor in place with val (Tensor.fill_ too). Every dtype.

Tensor.fill_diagonal_functionSame as PyTorch
fill_diagonal_(self, fill_value, wrap=False)

In place: the main diagonal (all indices equal) set to fill_value; wrap=True continues a tall 2-d matrix's diagonal every ncols + 1 rows, as PyTorch. Returns self.

Tensor.fix_functionSame as PyTorch
fix_(input)

fix in place: self takes the result of fix(self,...); returns self.

Tensor.float_power_functionSame as PyTorch
float_power_(input, exponent)

float_power in place: self takes the result of float_power(self,...); returns self.

Tensor.floor_functionSame as PyTorch
floor_(input)

floor in place: self takes the result of floor(self,...); returns self.

Tensor.floor_divide_functionSame as PyTorch
floor_divide_(input, other, *, out=None)

In-place Tensor.floor_divide: the result written into self (self's dtype kept).

Tensor.fmod_functionSame as PyTorch
fmod_(input, other, *, out=None)

In-place Tensor.fmod: the result written into self (self's dtype kept).

Tensor.frac_functionSame as PyTorch
frac_(input)

In-place Tensor.frac: the result written into self (self's dtype kept).

Tensor.gcd_functionSame as PyTorch
gcd_(input, other, *, out=None)

gcd in place: self takes the result of gcd(self,...); returns self.

Tensor.ge_functionSame as PyTorch
ge_(input, other)

ge in place: self takes the result of ge(self,...); returns self.

Tensor.geometric_functionSame as PyTorch
geometric_(self, p, *, generator=None)

Tensor.geometric_(p): fills with Geometric(p) draws (trials to the first success, from 1). In place.

Tensor.greater_functionSame as PyTorch
greater_(input, other)

greater in place: self takes the result of greater(self,...); returns self.

Tensor.greater_equal_functionSame as PyTorch
greater_equal_(input, other)

greater_equal in place: self takes the result of greater_equal(self,...); returns self.

Tensor.gt_functionSame as PyTorch
gt_(input, other)

gt in place: self takes the result of gt(self,...); returns self.

Tensor.heaviside_functionSame as PyTorch
heaviside_(input, values, *, out=None)

heaviside in place: self takes the result of heaviside(self,...); returns self.

Tensor.hypot_functionSame as PyTorch
hypot_(input, other)

hypot in place: self takes the result of hypot(self,...); returns self.

Tensor.i0_functionDifferent from PyTorch
i0_(self)

In-place torch.i0: the result written into self (self's dtype kept).

Different from PyTorch: correctly rounded float32 values (computed in float64, rounded once); 1500 inputs in [0, 75]: worst 3 ulp vs 0; MLX has no i0

PyTorch
float32 kernels in float32 precision: values off by several ulp
Riptorch
computed in float64, rounded once to float32 (correctly rounded)
Measured
float32: 1500 inputs in [0, 75]: worst 3 ulp vs 0
Stock behaviour
not reproduced: PyTorch's values come from its own float32 polynomial kernels, which Riptorch does not copy (compat keeps Riptorch's correctly rounded values)
Tensor.igamma_functionSame as PyTorch
igamma_(input, other, *, out=None)

igamma in place: self takes the result of igamma(self,...); returns self.

Tensor.igammac_functionSame as PyTorch
igammac_(input, other, *, out=None)

igammac in place: self takes the result of igammac(self,...); returns self.

Tensor.index_add_functionDifferent from PyTorch
index_add_(input, dim, index, source, *, alpha=1)

In-place Tensor.index_add: the result written into self (self's dtype kept).

Different from PyTorch: repeated indices summed in float64 and rounded once: [1e8, 1, -1e8] at one index gives 1.0, PyTorch's float32 sum gives 0.0

PyTorch
adds source's slices one after another in the input's dtype (float32: 1e8 + 1 - 1e8 = 0)
Riptorch
without gradients, one CPU pass summing in float64, rounded once (any n x k); with gradients, the float32 one-hot product in blocks
Measured
[1e8, 1, -1e8] added at index 0 of zeros(2): PyTorch 0.0, Riptorch 1.0 (the exact sum)
Stock behaviour
torch.set_compat("pytorch")
Tensor.index_copy_functionSame as PyTorch
index_copy_(input, dim, index, source)

In-place Tensor.index_copy: the result written into self (self's dtype kept).

Tensor.index_fill_functionSame as PyTorch
index_fill_(input, dim, index, value)

In-place Tensor.index_fill: the result written into self (self's dtype kept).

Tensor.index_put_functionDifferent from PyTorch
index_put_(input, indices, values, accumulate=False)

index_put in place: self takes the result of index_put(self,...); returns self.

Different from PyTorch: accumulate=True sums repeated positions in float64 and rounds once: [1e8, 1, -1e8] at one position gives 1.0, PyTorch gives 0.0

PyTorch
accumulate=True adds the values one after another in the input's dtype
Riptorch
accumulate=True: index_add's float64 sum, rounded once
Measured
[1e8, 1, -1e8] put at position 0 of zeros(2) with accumulate=True: PyTorch 0.0, Riptorch 1.0; run to run, index_put_(accumulate=True) gives one result in 20 runs where PyTorch CPU and MPS give 20 different ones
Stock behaviour
torch.set_compat("pytorch")
Tensor.index_reduce_functionSame as PyTorch
index_reduce_(self, dim, index, source, reduce, *, include_self=True)

index_reduce in place; returns self.

Tensor.lcm_functionSame as PyTorch
lcm_(input, other, *, out=None)

lcm in place: self takes the result of lcm(self,...); returns self.

Tensor.ldexp_functionSame as PyTorch
ldexp_(input, other, *, out=None)

ldexp in place: self takes the result of ldexp(self,...); returns self.

Tensor.le_functionSame as PyTorch
le_(input, other)

le in place: self takes the result of le(self,...); returns self.

Tensor.lerp_functionSame as PyTorch
lerp_(input, end, weight)

In-place form: the out-of-place result written into self. Raises on a leaf that requires grad while grad mode is on, as PyTorch.

Tensor.less_functionSame as PyTorch
less_(input, other)

less in place: self takes the result of less(self,...); returns self.

Tensor.less_equal_functionSame as PyTorch
less_equal_(input, other)

less_equal in place: self takes the result of less_equal(self,...); returns self.

Tensor.lgamma_functionSame as PyTorch
lgamma_(self)

In-place torch.lgamma: the result written into self (self's dtype kept).

Tensor.log10_functionSame as PyTorch
log10_(input)

log10 in place: self takes the result of log10(self,...); returns self.

Tensor.log1p_functionSame as PyTorch
log1p_(input)

log1p in place: self takes the result of log1p(self,...); returns self.

Tensor.log2_functionSame as PyTorch
log2_(input)

log2 in place: self takes the result of log2(self,...); returns self.

Tensor.log_functionSame as PyTorch
log_(input)

log in place: self takes the result of log(self,...); returns self.

Tensor.log_normal_functionSame as PyTorch
log_normal_(self, mean=1.0, std=2.0, *, generator=None)

Tensor.log_normal_(mean=1, std=2): fills with exp(N(mean, std)) draws. In place.

Tensor.logical_and_functionSame as PyTorch
logical_and_(self, *a, **k)

logical_and in place: self takes the result of logical_and(self,...); returns self.

Tensor.logical_not_functionSame as PyTorch
logical_not_(self, *a, **k)

logical_not in place: self takes the result of logical_not(self,...); returns self.

Tensor.logical_or_functionSame as PyTorch
logical_or_(self, *a, **k)

logical_or in place: self takes the result of logical_or(self,...); returns self.

Tensor.logical_xor_functionSame as PyTorch
logical_xor_(input, other, *, out=None)

logical_xor in place: self takes the result of logical_xor(self,...); returns self.

Tensor.logit_functionSame as PyTorch
logit_(input)

logit in place: self takes the result of logit(self,...); returns self.

Tensor.lt_functionSame as PyTorch
lt_(input, other)

lt in place: self takes the result of lt(self,...); returns self.

Tensor.map2_functionSame as PyTorch
map2_(self, x, y, fn)

In place: each element a becomes fn(a, b, c), b and c the matching elements of x and y broadcast to self.

Tensor.map_functionSame as PyTorch
map_(self, other, fn)

In place: each element x becomes fn(x, y), y the matching element of other broadcast to self.

Tensor.masked_fill_functionSame as PyTorch
masked_fill_(input, mask, value)

masked_fill in place.

Tensor.masked_scatter_functionSame as PyTorch
masked_scatter_(input, mask, source)

masked_scatter in place: self takes the result of masked_scatter(self,...); returns self.

Tensor.mul_functionSame as PyTorch
mul_(input, other)

In-place form: the out-of-place result written into self. Raises on a leaf that requires grad while grad mode is on, as PyTorch.

Tensor.multiply_functionSame as PyTorch
multiply_(input, other)

multiply in place: self takes the result of multiply(self,...); returns self.

Tensor.mvlgamma_functionSame as PyTorch
mvlgamma_(input, p, *, out=None)

mvlgamma in place: self takes the result of mvlgamma(self,...); returns self.

Tensor.nan_to_num_functionSame as PyTorch
nan_to_num_(input, nan=0.0, posinf=None, neginf=None)

nan_to_num in place: self takes the result of nan_to_num(self,...); returns self.

Tensor.ne_functionSame as PyTorch
ne_(input, other)

ne in place: self takes the result of ne(self,...); returns self.

Tensor.neg_functionSame as PyTorch
neg_(input)

In-place form: the out-of-place result written into self. Raises on a leaf that requires grad while grad mode is on, as PyTorch.

Tensor.negative_functionSame as PyTorch
negative_(input)

negative in place: self takes the result of negative(self,...); returns self.

Tensor.nextafter_functionSame as PyTorch
nextafter_(input, other, *, out=None)

nextafter in place: self takes the result of nextafter(self,...); returns self.

Tensor.normal_functionSame as PyTorch
normal_(tensor, mean=0.0, std=1.0, generator=None)

Fills the tensor in place with normal draws N(mean, std). Dtypes: float32.

Tensor.not_equal_functionSame as PyTorch
not_equal_(input, other)

not_equal in place: self takes the result of not_equal(self,...); returns self.

Tensor.polygamma_functionSame as PyTorch
polygamma_(n, input, *, out=None)

polygamma in place: self takes the result of polygamma(self,...); returns self.

Tensor.pow_functionSame as PyTorch
pow_(input, exponent)

In-place form: the out-of-place result written into self. Raises on a leaf that requires grad while grad mode is on, as PyTorch.

Tensor.put_functionSame as PyTorch
put_(input, index, source, accumulate=False)

put in place: self takes the result of put(self,...); returns self.

Tensor.rad2deg_functionSame as PyTorch
rad2deg_(input)

rad2deg in place: self takes the result of rad2deg(self,...); returns self.

Tensor.random_functionSame as PyTorch
random_(self, from_=0, to=None, *, generator=None)

Tensor.random_([from_,] to): fills with integers drawn uniformly from [from_, to); without to, from [0, the largest integer the dtype holds exactly + 1) as PyTorch (2^24 + 1 for float32, 2^63 for int64). In place.

Tensor.reciprocal_functionSame as PyTorch
reciprocal_(input)

reciprocal in place: self takes the result of reciprocal(self,...); returns self.

Tensor.relu_functionSame as PyTorch
relu_(Tensor self, bool inplace=False) -> Tensor

In-place form: the out-of-place result written into self. Raises on a leaf that requires grad while grad mode is on, as PyTorch.

Tensor.remainder_functionDifferent from PyTorch
remainder_(input, other, *, out=None)

In-place Tensor.remainder: the result written into self (self's dtype kept).

Different from PyTorch: float32 remainder is one rounding of the exact x - floor(x / y) y for every input: 0 of 20000 random pairs wrong where PyTorch MPS gets 10511 wrong (and remainder(7, -inf) is nan there)

PyTorch
CPU: correctly rounded too; MPS: 10511 of 20000 random pairs wrong, remainder(7, -inf) = nan
Riptorch
the exact remainder rounded once (one rounding, the divisor's sign), on every device
Measured
20000 random float32 pairs, x up to 1e12, y down to 1e-6: Riptorch 0 wrong, PyTorch CPU 0, PyTorch MPS 10511 (8293 in the rules doc's sample)
Stock behaviour
none: PyTorch's CPU kernel already gives these values; MPS's errors are not reproduced
Tensor.renorm_functionSame as PyTorch
renorm_(input, p, dim, maxnorm)

renorm in place: self takes the result of renorm(self,...); returns self.

Tensor.resize_functionSame as PyTorch
resize_(self, *size)

In place: self takes the given size, keeping its elements in row-major order (cut short, or extended with zeros where PyTorch leaves memory uninitialized); returns self.

Tensor.resize_as_functionSame as PyTorch
resize_as_(self, other)

resize_ to other's shape.

Tensor.resize_as_sparse_functionSame as PyTorch
resize_as_sparse_(self, the_template)

torch.resize_as_sparse_(self, the_template) (both sparse COO).

Tensor.round_functionSame as PyTorch
round_(input)

round in place: self takes the result of round(self,...); returns self.

Tensor.rsqrt_functionSame as PyTorch
rsqrt_(input)

rsqrt in place: self takes the result of rsqrt(self,...); returns self.

Tensor.scatter_functionSame as PyTorch
scatter_(input, dim, index, src=None, *, value=None, reduce=None)

In-place Tensor.scatter: the result written into self (self's dtype kept).

Tensor.scatter_add_functionSame as PyTorch
scatter_add_(input, dim, index, src)

In-place Tensor.scatter_add: the result written into self (self's dtype kept).

Tensor.scatter_reduce_functionSame as PyTorch
scatter_reduce_(input, dim, index, src, reduce, *, include_self=True)

In-place Tensor.scatter_reduce: the result written into self (self's dtype kept).

Tensor.set_functionSame as PyTorch
set_(self, source=None, storage_offset=0, size=None, stride=None)

self takes source's data (a tensor or a storage; with size / stride: that view of it). Riptorch tensors own their memory: the data is copied, not shared.

Tensor.sgn_functionSame as PyTorch
sgn_(input)

sgn in place: self takes the result of sgn(self,...); returns self.

Tensor.share_memory_functionSame as PyTorch
share_memory_(self)

self, unchanged: Riptorch tensors cross processes by copy, not shared memory.

Tensor.sigmoid_functionSame as PyTorch
sigmoid_(input, *, maths=None)

In-place form: the out-of-place result written into self. Raises on a leaf that requires grad while grad mode is on, as PyTorch.

Tensor.sign_functionSame as PyTorch
sign_(input)

sign in place: self takes the result of sign(self,...); returns self.

Tensor.sin_functionDifferent from PyTorch
sin_(input)

sin in place: self takes the result of sin(self,...); returns self.

Different from PyTorch: float32 sin within 1 ulp on [-100, 100]: worst 0.64 ulps of the exact value where PyTorch's CPU kernel has 1.71 (CPU and MPS: 2 ulps after rounding)

PyTorch
float32 sin up to 2 ulps off
Riptorch
argument reduction by pi/2 in parts and a polynomial in float32 (Riptide sin node)
Measured
1500 points of [-100, 100]: Riptorch 0.64, PyTorch CPU 1.71 ulps of the exact value max 1 vs 2 ulps
Stock behaviour
none: an accuracy gain, PyTorch's rounding is not reproduced
Tensor.sinc_functionSame as PyTorch
sinc_(self)

In-place torch.sinc: the result written into self (self's dtype kept).

Tensor.sinh_functionSame as PyTorch
sinh_(input)

sinh in place: self takes the result of sinh(self,...); returns self.

Tensor.sparse_resize_functionSame as PyTorch
sparse_resize_(self, *a, **k)

Raises RuntimeError as PyTorch on a dense tensor: sparse_resize_ needs a sparse coordinate tensor.

Tensor.sparse_resize_and_clear_functionSame as PyTorch
sparse_resize_and_clear_(self, *a, **k)

Raises RuntimeError as PyTorch on a dense tensor: sparse_resize_and_clear_ needs a sparse coordinate tensor.

Tensor.sqrt_functionSame as PyTorch
sqrt_(input)

In-place form: the out-of-place result written into self. Raises on a leaf that requires grad while grad mode is on, as PyTorch.

Tensor.square_functionSame as PyTorch
square_(input)

square in place: self takes the result of square(self,...); returns self.

Tensor.squeeze_functionSame as PyTorch
squeeze_(self, *dim)

squeeze in place; returns self.

Tensor.sub_functionSame as PyTorch
sub_(input, other, *, alpha=1)

In-place form: the out-of-place result written into self. Raises on a leaf that requires grad while grad mode is on, as PyTorch.

Tensor.subtract_functionSame as PyTorch
subtract_(input, other, *, alpha=1)

subtract in place: self takes the result of subtract(self,...); returns self.

Tensor.swapaxes_functionSame as PyTorch
swapaxes_(self, a, b)

transpose(a, b) in place; returns self.

Tensor.swapdims_functionSame as PyTorch
swapdims_(self, a, b)

transpose(a, b) in place; returns self.

Tensor.t_functionSame as PyTorch
t_(self)

t in place; returns self.

Tensor.tan_functionSame as PyTorch
tan_(input)

tan in place: self takes the result of tan(self,...); returns self.

Tensor.tanh_functionSame as PyTorch
tanh_(input, *, maths=None)

In-place form: the out-of-place result written into self. Raises on a leaf that requires grad while grad mode is on, as PyTorch.

Tensor.transpose_functionSame as PyTorch
transpose_(self, a, b)

transpose(a, b) in place; returns self.

Tensor.tril_functionSame as PyTorch
tril_(self, diagonal=0)

In-place torch.tril(self, diagonal).

Tensor.triu_functionSame as PyTorch
triu_(self, diagonal=0)

In-place torch.triu(self, diagonal).

Tensor.true_divide_functionSame as PyTorch
true_divide_(input, other, *, rounding_mode=None)

true_divide in place: self takes the result of true_divide(self,...); returns self.

Tensor.trunc_functionSame as PyTorch
trunc_(input)

trunc in place: self takes the result of trunc(self,...); returns self.

Tensor.uniform_functionSame as PyTorch
uniform_(tensor, a=0.0, b=1.0, generator=None)

Fills the tensor in place with uniform draws in [a, b). Dtypes: float32.

Tensor.unsqueeze_functionSame as PyTorch
unsqueeze_(self, dim)

unsqueeze in place; returns self.

Tensor.xlogy_functionSame as PyTorch
xlogy_(input, other)

xlogy in place: self takes the result of xlogy(self,...); returns self.

Tensor.zero_functionSame as PyTorch
zero_(tensor)

Fills the tensor in place with zeros (Tensor.zero_ too). Every dtype.