RiptideRiptide
Download Riptide SDKInstall Riptorch
Menu
Riptorch docs · Reference

torch

Tensor creation, maths, reductions, comparisons, linear algebra, random sampling, serialization and utilities: everything under torch.*. 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 torch.

import riptorch as torch
904 same as PyTorch22 different96 Riptorch extras

Tensors

torch.get_default_devicefunctionSame as PyTorch
get_default_device()

torch.get_default_device: what set_default_device recorded, else device('cpu').

torch.get_default_dtypefunctionSame as PyTorch
get_default_dtype()

torch.get_default_dtype: the dtype of new floating tensors (float32 unless set_default_dtype changed it).

torch.is_complexfunctionSame as PyTorch
is_complex(input)

Whether the tensor's dtype is complex.

torch.is_conjfunctionSame as PyTorch
is_conj(x)

False: Riptorch never keeps lazy conjugate or negation bits.

torch.is_floating_pointfunctionSame as PyTorch
is_floating_point(input)

Same as PyTorch’s torch.is_floating_point.

torch.is_negfunctionSame as PyTorch
is_neg(x)

False: Riptorch never keeps lazy conjugate or negation bits.

torch.is_nonzerofunctionSame as PyTorch
is_nonzero(x)

The truth value of a one-element tensor (more elements raise).

torch.is_storagefunctionSame as PyTorch
is_storage(obj)

False: Riptorch tensors expose no separate storage objects here.

torch.is_tensorfunctionSame as PyTorch
is_tensor(obj)

Whether obj is a Riptorch tensor.

torch.numelfunctionSame as PyTorch
numel(input)

The number of elements of the tensor.

torch.set_default_devicefunctionSame as PyTorch
set_default_device(device)

torch.set_default_device: recorded (get_default_device returns it); every Riptorch tensor is in unified memory.

torch.set_default_dtypefunctionSame as PyTorch
set_default_dtype(d)

torch.set_default_dtype: the dtype of new floating tensors (float32 by default). Riptorch's gradients are float32, so float64 / float16 / bfloat16 defaults make tensors without gradients.

torch.set_default_tensor_typefunctionSame as PyTorch
set_default_tensor_type(t)

torch.set_default_tensor_type (deprecated): sets the default dtype from a tensor type's name (DoubleTensor, FloatTensor, HalfTensor, BFloat16Tensor; anything else gives float32).

torch.set_flush_denormalfunctionSame as PyTorch
set_flush_denormal(mode)

Returns True and changes nothing (denormals are kept).

torch.set_printoptionsfunctionSame as PyTorch
set_printoptions(precision=None, threshold=None, edgeitems=None, linewidth=None, profile=None, sci_mode=None)

Sets how tensors print, as PyTorch: precision (digits after the point, default 4), threshold (more elements than this are summarized, default 1000), edgeitems (items kept at each end of a summarized dim, default 3), linewidth (characters per line, default 80), profile ("default", "short": precision 2 and edgeitems 2, "full": never summarize; the other arguments override it) and sci_mode (True / False forces scientific notation on / off; None, the default, chooses per tensor). sci_mode is reset on every call, as PyTorch.

Creation ops

torch.arangefunctionSame as PyTorch
arange(start, end=None, step=1, *, dtype=None, device=None, requires_grad=False)

int64 when start, end and step are all integers, else float32 (PyTorch's rule); [start, end) by step.

Also accepts layout=, pin_memory=, memory_format=, names= (one unified memory; strided layout only).

torch.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).

torch.as_tensorfunctionSame as PyTorch
as_tensor(data, dtype=None, device=None)

data as a tensor: a tensor as it is (cast when dtype differs), a NumPy array through from_numpy, anything else through torch.tensor. The result never shares memory with a NumPy array (PyTorch's does).

Also accepts layout=, pin_memory=, memory_format=, names= (one unified memory; strided layout only).

torch.asarrayfunctionSame as PyTorch
asarray(obj, *, dtype=None, device=None, copy=None, requires_grad=False)

as_tensor(obj, dtype), requiring grad when asked; copy= and device= are accepted and ignored (the result never shares memory with obj).

torch.complexfunctionSame as PyTorch
complex(real, imag)

torch.complex(real, imag): float32 parts give complex64, float64 parts complex128.

torch.dequantizefunctionDifferent from PyTorch
dequantize(input)

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")
torch.emptyfunctionSame as PyTorch
empty(*size, dtype=None, device=None, requires_grad=False)

empty is zeros here (PyTorch leaves the values unspecified).

Also accepts layout=, pin_memory=, memory_format=, names= (one unified memory; strided layout only).

layout=torch.sparse_coo gives an empty sparse COO tensor of that size.

torch.empty_likefunctionSame as PyTorch
empty_like(input, *, dtype=None, device=None, requires_grad=False, memory_format=None)

empty_like / full_like / new_ones / new_zeros / new_full / new_empty / new_tensor

empty_like (zeros), full_like and the Tensor.new_* constructors: the input's dtype unless dtype= is given.

Also accepts layout=, pin_memory=, names= (one unified memory; strided layout only).

torch.empty_stridedfunctionSame as PyTorch
empty_strided(size, stride, *, dtype=None, **kw)

A zero-filled tensor of size; stride is ignored (contiguous layout).

torch.eyefunctionSame as PyTorch
eye(n, m=None, *, dtype=None, layout=None, device=None, requires_grad=False, out=None)

torch.eye(n, m=None).

Also accepts pin_memory=, memory_format=, names= (one unified memory; strided layout only).

torch.from_dlpackfunctionSame as PyTorch
from_dlpack(ext_tensor)

A Riptorch tensor with the data of an object implementing the DLPack protocol (__dlpack__, e.g. a NumPy array or a PyTorch tensor) or of a DLPack capsule. Riptorch tensors own their memory, so the data is copied (PyTorch shares it).

torch.from_filefunctionSame as PyTorch
from_file(filename, shared=None, size=0, *, dtype=None, layout=None, device=None, pin_memory=False)

A 1-d tensor of size elements read from a binary file (read into memory; shared= is accepted, the file is not mapped, so writes to the tensor don't reach it).

torch.from_numpyfunctionSame as PyTorch
from_numpy(ndarray)

A tensor with the array's values, dtype and shape. A copy: later changes to the array don't show in the tensor (PyTorch shares the memory).

torch.frombufferfunctionSame as PyTorch
frombuffer(buffer, dtype=None, count=-1, offset=0)

torch.frombuffer: a 1-d tensor over the buffer's values (copied).

Also accepts layout=, pin_memory=, memory_format=, device=, names= (one unified memory; strided layout only).

torch.fullfunctionSame as PyTorch
full(size, fill_value, *, dtype=None, device=None, requires_grad=False)

The dtype follows the fill value when none is given (bool, int64, float32), as in PyTorch.

Also accepts layout=, pin_memory=, memory_format=, names= (one unified memory; strided layout only).

torch.full_likefunctionSame as PyTorch
full_like(input, fill_value, *, dtype=None, device=None, requires_grad=False, memory_format=None)

Also accepts layout=, pin_memory=, names= (one unified memory; strided layout only).

torch.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.

torch.linspacefunctionSame as PyTorch
linspace(start, end, steps, *, out=None, dtype=None, layout=None, device=None, requires_grad=False)

steps values from start to end inclusive, evenly spaced.

Filled from both ends in float64 (PyTorch's symmetric fill), then cast to dtype (the default dtype when none). layout= and device= are accepted and ignored.

Also accepts pin_memory=, memory_format=, names= (one unified memory; strided layout only).

torch.logspacefunctionSame as PyTorch
logspace(start, end, steps, base=10.0, *, out=None, dtype=None, layout=None, device=None, requires_grad=False)

base ** linspace(start, end, steps), computed in float64 and cast to dtype (the default dtype when none).

Also accepts pin_memory=, memory_format=, names= (one unified memory; strided layout only).

torch.onesfunctionSame as PyTorch
ones(*size, dtype=None, device=None, requires_grad=False)

Ones of the given size (float32 unless dtype=). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Also accepts layout=, pin_memory=, memory_format=, names= (one unified memory; strided layout only).

torch.ones_likefunctionSame as PyTorch
ones_like(input, *, dtype=None, device=None, requires_grad=False)

Ones with the input's shape (and dtype unless dtype= is given). Every dtype; autograd for the floating-point types.

Also accepts layout=, pin_memory=, memory_format=, names= (one unified memory; strided layout only).

torch.polarfunctionSame as PyTorch
polar(abs, angle)

torch.polar: abs (cos angle + i sin angle).

torch.quantize_per_channelfunctionSame as PyTorch
quantize_per_channel(input, scales, zero_points, axis, dtype)

Quantize along axis with one scale / zero point per channel.

torch.quantize_per_tensorfunctionDifferent from PyTorch
quantize_per_tensor(input, scale, zero_point, dtype)

Different from PyTorch: quantized integers are the exact quotient rounded half to even; PyTorch lands one step off on 5491 of 24000 values at the .5 boundaries

PyTorch
q = zero_point + rint(x * (1 / scale)) in float32: the reciprocal of the float32 scale, a second rounding
Riptorch
q = zero_point + round-half-even(x / scale) of the exact quotient
Measured
values on the .5 boundaries (k + 1/2) * scale, 200 scales in [0.001, 1], 400k values: PyTorch lands one step off on 62687 (15.7%); next to random normal values 0 of 400k differ
Stock behaviour
torch.set_compat("pytorch")
torch.rangefunctionSame as PyTorch
range(start=0, end=None, step=1, *, out=None, dtype=None, layout=None, device=None, requires_grad=False)

Deprecated torch.range: [start, end] inclusive, default dtype (float32) whatever the arguments.

torch.scalar_tensorfunctionSame as PyTorch
scalar_tensor(s, *, dtype=None, layout=None, device=None, pin_memory=False, requires_grad=False)

A 0-d tensor holding s, in dtype (the default dtype when none).

Also accepts memory_format=, names= (one unified memory; strided layout only).

torch.sparse_bsc_tensorfunctionSame as PyTorch
sparse_bsc_tensor(compressed_indices, plain_indices, values, size=None, *, dtype=None, device=None, pin_memory=False, requires_grad=False, check_invariants=None)

torch.sparse_bsc_tensor: a sparse_bsc tensor.

torch.sparse_bsr_tensorfunctionSame as PyTorch
sparse_bsr_tensor(compressed_indices, plain_indices, values, size=None, *, dtype=None, device=None, pin_memory=False, requires_grad=False, check_invariants=None)

torch.sparse_bsr_tensor: a sparse_bsr tensor.

torch.sparse_compressed_tensorfunctionSame as PyTorch
sparse_compressed_tensor(compressed_indices, plain_indices, values, size=None, *, dtype=None, layout=None, device=None, pin_memory=False, requires_grad=False, check_invariants=None)

torch.sparse_compressed_tensor: CSR / CSC / BSR / BSC from compressed indices, plain indices and values.

torch.sparse_coo_tensorfunctionSame as PyTorch
sparse_coo_tensor(indices, values, size=None, *, dtype=None, device=None, pin_memory=False, requires_grad=False, check_invariants=None, is_coalesced=None)

torch.sparse_coo_tensor: a COO tensor from indices [sparse_dim, nnz] and values [nnz, *dense_shape].

torch.sparse_csc_tensorfunctionSame as PyTorch
sparse_csc_tensor(compressed_indices, plain_indices, values, size=None, *, dtype=None, device=None, pin_memory=False, requires_grad=False, check_invariants=None)

torch.sparse_csc_tensor: a sparse_csc tensor.

torch.sparse_csr_tensorfunctionSame as PyTorch
sparse_csr_tensor(compressed_indices, plain_indices, values, size=None, *, dtype=None, device=None, pin_memory=False, requires_grad=False, check_invariants=None)

torch.sparse_csr_tensor: a sparse_csr tensor.

torch.tensorfunctionSame as PyTorch
tensor(data, requires_grad=False, dtype=None, device=None)

A tensor holding data (nested lists / tuples of numbers, a NumPy array, a scalar), copied; dtype inferred as PyTorch (bool, int64, the default float dtype) unless given.

Also accepts layout=, pin_memory=, memory_format=, names= (one unified memory; strided layout only).

torch.zerosfunctionSame as PyTorch
zeros(*size, dtype=None, device=None, requires_grad=False)

empty is zeros here (PyTorch leaves the values unspecified).

Also accepts layout=, pin_memory=, memory_format=, names= (one unified memory; strided layout only).

layout=torch.sparse_coo gives an empty sparse COO tensor of that size.

torch.zeros_likefunctionSame as PyTorch
zeros_like(input, *, dtype=None, device=None, requires_grad=False)

Zeros with the input's shape (and dtype unless dtype= is given). Every dtype; autograd for the floating-point types.

Also accepts layout=, pin_memory=, memory_format=, names= (one unified memory; strided layout only).

Indexing, slicing, joining and mutating

torch.adjointfunctionSame as PyTorch
adjoint(input)

Conjugate transpose of the last two dims (a plain transpose for real tensors).

torch.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.

torch.catfunctionSame as PyTorch
cat(Tensor[] tensors, int dim=0) -> Tensor

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch. A quantized input runs the quantized kernel (same parameters).

torch.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.

torch.column_stackfunctionSame as PyTorch
column_stack(tensors, *, out=None)

The tensors side by side as columns: 0-d and 1-d tensors become (n, 1), then all are concatenated along dim 1.

torch.concatfunctionSame as PyTorch
concat(Tensor[] tensors, int dim=0) -> Tensor

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch. A quantized input runs the quantized kernel (same parameters).

torch.concatenatefunctionSame as PyTorch
concatenate(Tensor[] tensors, int dim=0) -> Tensor

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch. A quantized input runs the quantized kernel (same parameters).

torch.conjfunctionSame as PyTorch
conj(x)

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

torch.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.

torch.dsplitfunctionSame as PyTorch
dsplit(input, sections)

tensor_split along dim 2.

torch.dstackfunctionSame as PyTorch
dstack(tensors, *, out=None)

The tensors concatenated along dim 2, after atleast_3d.

torch.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.

torch.hsplitfunctionSame as PyTorch
hsplit(input, sections)

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

torch.hstackfunctionSame as PyTorch
hstack(tensors, *, out=None)

The tensors concatenated along dim 1 (dim 0 when they are 1-d), after atleast_1d.

torch.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")
torch.index_copyfunctionSame as PyTorch
index_copy(input, dim, index, source)

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

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

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

torch.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")
torch.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.

torch.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.

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

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

torch.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.

torch.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.

torch.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.

torch.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.

torch.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.

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

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

torch.nonzerofunctionSame as PyTorch
nonzero(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.

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

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

torch.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).

torch.reshapefunctionSame as PyTorch
reshape(input, shape)

input.reshape(shape).

torch.row_stackfunctionSame as PyTorch
row_stack(tensors, *, out=None)

The tensors concatenated along dim 0, after atleast_2d (1-d tensors become rows).

torch.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.

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

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

torch.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).

torch.segment_reducefunctionSame as PyTorch
segment_reduce(data, reduce, *, lengths=None, indices=None, offsets=None, axis=0, unsafe=False, initial=None)

Reductions over consecutive segments of data along axis; lengths (or offsets) of shape (*lead, segments) with lead the dims of data before axis. initial joins every segment's reduction (and fills empty segments).

torch.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.

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

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

torch.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.

torch.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.

torch.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.

torch.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.

torch.stackfunctionSame as PyTorch
stack(Tensor[] tensors, int dim=0) -> Tensor

Joins tensors along a new dimension dim.

Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch. A quantized input runs the quantized kernel (same parameters).

torch.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.

torch.swapdimsfunctionSame as PyTorch
swapdims(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.

torch.tfunctionSame as PyTorch
t(input)

Transpose of a tensor of at most 2 dims (0-d and 1-d come back as they are).

torch.takefunctionSame as PyTorch
take(input, index)

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

torch.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.

torch.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.

torch.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.

torch.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.

torch.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.

torch.unravel_indexfunctionSame as PyTorch
unravel_index(indices, shape)

The coordinates of flat indices in an array of the given shape (row-major), as a tuple of int64 tensors.

torch.unsafe_chunkfunctionSame as PyTorch
unsafe_chunk(input, *a, **k)

input.unsafe_chunk(...).

torch.unsafe_splitfunctionSame as PyTorch
unsafe_split(input, *a, **k)

input.unsafe_split(...).

torch.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.

torch.vsplitfunctionSame as PyTorch
vsplit(input, sections)

tensor_split along dim 0.

torch.vstackfunctionSame as PyTorch
vstack(tensors, *, out=None)

The tensors concatenated along dim 0, after atleast_2d (1-d tensors become rows).

torch.wherefunctionSame as PyTorch
where(condition, input=None, other=None)

Same as PyTorch’s torch.where.

Random sampling

torch.bernoullifunctionSame as PyTorch
bernoulli(input, p=None, *, generator=None, out=None)

torch.bernoulli: 1 with probability input (or p), as input's dtype.

torch.binomialfunctionSame as PyTorch
binomial(count, prob, generator=None)

torch.binomial: a Binomial(count, prob) draw per element.

torch.default_generatorvalueSame as PyTorch
default_generator = <riptorch default generator>

Same as PyTorch’s torch.default_generator.

torch.GeneratorclassSame as PyTorch
Generator(device='cpu')

torch.Generator: its own random stream. Draws that pass generator= run on this stream (the global stream is swapped out and back). torch.default_generator is the global stream itself.

torch.get_rng_statefunctionSame as PyTorch
get_rng_state()

torch.get_rng_state: the generator's state as a uint8 tensor (Riptorch's: seed, draw count, and the state of the Python random module the nn layers' default initialisation draws from).

torch.initial_seedfunctionSame as PyTorch
initial_seed()

The seed of the default generator (the one manual_seed set).

torch.manual_seedfunctionSame as PyTorch
manual_seed(seed)

The numbers differ from PyTorch's for the same seed: PyTorch's generator sequence is not part of its API.

torch.multinomialfunctionSame as PyTorch
multinomial(input, num_samples, replacement=False, *, generator=None, out=None)

torch.multinomial: indices drawn by the (unnormalised, non-negative) weights in each row of input (1-d or 2-d); int64. Without replacement: the num_samples largest of log(u) / w (Efraimidis-Spirakis keys, one uniform per category).

torch.normalfunctionSame as PyTorch
normal(mean=0.0, std=1.0, size=None, *, generator=None, out=None, dtype=None, device=None, requires_grad=False)

torch.normal(mean, std[, size]): tensors broadcast, or floats with a size.

torch.poissonfunctionSame as PyTorch
poisson(input, generator=None)

torch.poisson: a Poisson draw per rate (input's dtype).

torch.randfunctionSame as PyTorch
rand(*size, generator=None, dtype=None, device=None, requires_grad=False)

Uniform draws in [0, 1) from the default generator (or generator=). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Also accepts layout=, pin_memory=, memory_format=, names= (one unified memory; strided layout only).

torch.rand_likefunctionSame as PyTorch
rand_like(input, *, dtype=None, layout=None, device=None, requires_grad=False, memory_format=None)

torch.rand_like: uniform [0, 1) draws with input's shape, in dtype (default input's dtype).

Also accepts pin_memory=, names= (one unified memory; strided layout only).

torch.randintfunctionSame as PyTorch
randint(low, high=None, size=(), dtype=None, device=None, generator=None)

torch.randint: integers in [low, high), int64 unless dtype says otherwise.

Also accepts layout=, pin_memory=, memory_format=, names= (one unified memory; strided layout only).

torch.randint_likefunctionSame as PyTorch
randint_like(input, low=0, high=None, *, dtype=None, layout=None, device=None, requires_grad=False, memory_format=None)

torch.randint_like(input, [low,] high): integers in [low, high) with input's shape, in dtype (default input's dtype).

Also accepts pin_memory=, names= (one unified memory; strided layout only).

torch.randnfunctionSame as PyTorch
randn(*size, generator=None, dtype=None, device=None, requires_grad=False)

Standard normal draws from the default generator (or generator=). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Also accepts layout=, pin_memory=, memory_format=, names= (one unified memory; strided layout only).

torch.randn_likefunctionSame as PyTorch
randn_like(input, *, dtype=None, device=None, requires_grad=False)

Standard normal draws with the input's shape. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

Also accepts layout=, pin_memory=, memory_format=, names= (one unified memory; strided layout only).

torch.randpermfunctionSame as PyTorch
randperm(n, *, generator=None, dtype=None, device=None, requires_grad=False)

Also accepts layout=, pin_memory=, memory_format=, names= (one unified memory; strided layout only).

torch.seedfunctionSame as PyTorch
seed()

torch.seed: seeds with a non-deterministic number and returns it.

torch.set_rng_statefunctionSame as PyTorch
set_rng_state(new_state)

torch.set_rng_state: restores a state from get_rng_state (Riptorch's stream and the Python random state).

Serialization

torch.loadfunctionSame as PyTorch
load(f, map_location=None, pickle_module=None, *, weights_only=None, mmap=None, **pickle_load_args)

torch.load: PyTorch's zip and legacy formats, and safetensors files. weights_only defaults to True (PyTorch 2.6+); RIPTORCH_FORCE_WEIGHTS_ONLY_LOAD / TORCH_FORCE_WEIGHTS_ONLY_LOAD=1 force it, TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD=1 turns the default off as PyTorch does.

torch.savefunctionSame as PyTorch
save(obj, f, pickle_module=<module 'pickle' from '/opt/homebrew/Cellar/python@3.12/3.12.16/Frameworks/Python.framework/Versions/3.12/lib/python3.12/pickle.py'>, pickle_protocol=2, _use_new_zipfile_serialization=True, _disable_byteorder_record=False)

torch.save: PyTorch's zip format (or the legacy format with _use_new_zipfile_serialization=False).

Parallelism

torch.get_num_interop_threadsfunctionSame as PyTorch
get_num_interop_threads()

torch.get_num_interop_threads: the recorded value, else os.cpu_count.

torch.get_num_threadsfunctionSame as PyTorch
get_num_threads()

torch.get_num_threads: the value set_num_threads recorded, else the performance-core count (hw.perflevel0.physicalcpu; os.cpu_count if unreadable).

torch.set_num_interop_threadsfunctionSame as PyTorch
set_num_interop_threads(n)

torch.set_num_interop_threads: recorded for get_num_interop_threads (Riptorch has no inter-op pool).

torch.set_num_threadsfunctionSame as PyTorch
set_num_threads(n)

Same as PyTorch’s torch.set_num_threads.

Gradient mode

torch.enable_gradclassSame as PyTorch
enable_grad(orig_func=None)

with torch.enable_grad: ops record gradients again inside no_grad (LBFGS closures). Also a decorator.

torch.inference_modeclassSame as PyTorch
inference_mode(mode=True)

torch.inference_mode(mode=True): no gradients recorded (as no_grad); a context manager and a decorator.

torch.is_grad_enabledfunctionSame as PyTorch
is_grad_enabled()

Whether gradient recording is on (no_grad / enable_grad / set_grad_enabled change it).

torch.is_inference_mode_enabledfunctionSame as PyTorch
is_inference_mode_enabled()

Whether an inference_mode block is active.

torch.no_gradclassSame as PyTorch
no_grad(orig_func=None)

with torch.no_grad: ops don't record gradients. Also a decorator: @torch.no_grad or @torch.no_grad.

torch.set_grad_enabledclassSame as PyTorch
set_grad_enabled(mode)

torch.set_grad_enabled(mode): turns gradient recording on or off now; used as a context manager (or a decorator) the previous setting comes back at the end, as PyTorch.

Pointwise maths

torch.absfunctionSame as PyTorch
abs(input)

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

torch.absolutefunctionSame as PyTorch
absolute(input)

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

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

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

torch.acoshfunctionSame as PyTorch
acosh(input)

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

torch.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.

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

input + value * tensor1 / tensor2.

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

input + value * tensor1 * tensor2.

torch.alpha_dropoutfunctionSame as PyTorch
alpha_dropout(input, p, train)

Alpha dropout (keeps SELU's mean and variance) when train is True; the input otherwise.

torch.anglefunctionSame as PyTorch
angle(x)

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

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

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

torch.arccoshfunctionSame as PyTorch
arccosh(input)

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

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

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

torch.arcsinhfunctionSame as PyTorch
arcsinh(input)

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

torch.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.

torch.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.

torch.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).

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

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

torch.asinhfunctionSame as PyTorch
asinh(input)

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

torch.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.

torch.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.

torch.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).

torch.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.

torch.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.

torch.bitwise_notfunctionSame as PyTorch
bitwise_not(input)

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

torch.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.

torch.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.

torch.bitwise_xorfunctionSame as PyTorch
bitwise_xor(input, other)

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

torch.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).

torch.celufunctionSame as PyTorch
celu(input, alpha=1.0, inplace=False)

max(0, x) + min(0, alpha * (exp(x / alpha) - 1)). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

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

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

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

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

torch.conj_physicalfunctionSame as PyTorch
conj_physical(x)

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

torch.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.

torch.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
torch.coshfunctionSame as PyTorch
cosh(input)

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

torch.deg2radfunctionSame as PyTorch
deg2rad(input)

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

torch.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)
torch.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.

torch.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.

torch.dropoutfunctionSame as PyTorch
dropout(input, p=0.5, training=True, inplace=False)

nn.Dropout passes training=self.training. The kept fraction and scale match PyTorch; the mask bits don't.

torch.erffunctionSame as PyTorch
erf(input)

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

torch.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).

torch.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)
torch.expfunctionSame as PyTorch
exp(input)

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

torch.exp2functionSame as PyTorch
exp2(input)

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

torch.expm1functionSame as PyTorch
expm1(input)

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

fake_quantize_per_channel_affine(input, scale, zero_point, axis, quant_min, quant_max)

Per-channel fake quantization along axis (straight-through gradients).

torch.fake_quantize_per_tensor_affinefunctionDifferent from PyTorch
fake_quantize_per_tensor_affine(input, scale, zero_point, quant_min, quant_max)

Different from PyTorch: exact quotient rounding and one-rounding dequantization; PyTorch differs on 1026 of 4000 boundary-heavy values

PyTorch
quantizes with the float32 reciprocal of the scale and dequantizes with the float32 scale (two extra roundings)
Riptorch
exact quotient rounded half to even, product rounded once; gradients straight through as PyTorch
Measured
same boundary inputs as quantize_per_tensor: PyTorch one step off on 15.7%
Stock behaviour
torch.set_compat("pytorch")
torch.feature_alpha_dropoutfunctionSame as PyTorch
feature_alpha_dropout(input, p, train)

Alpha dropout of whole channels (dim 1) when train is True; the input otherwise.

torch.feature_dropoutfunctionSame as PyTorch
feature_dropout(input, p, train)

Dropout of whole channels (dim 1, one draw per batch x channel), survivors scaled by 1 / (1 - p).

torch.fixfunctionSame as PyTorch
fix(input)

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

torch.float_powerfunctionSame as PyTorch
float_power(input, exponent)

A whole-number exponent multiplies (exact, any sign of the base; negative exponents take the reciprocal); otherwise base^e = 2^(e log2 base) (NaN for a negative base, as PyTorch).

torch.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).

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

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

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

C's fmod, the dividend's sign.

torch.fracfunctionSame as PyTorch
frac(input)

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

torch.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.

torch.gradientfunctionSame as PyTorch
gradient(input, *, spacing=1, dim=None, edge_order=1)

numpy.gradient: second-order central differences inside, first- or second-order one-sided at the edges; spacing a scalar, a list of scalars (one per dim) or a list of coordinate tensors.

torch.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).

torch.hypotfunctionSame as PyTorch
hypot(input, other)

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

torch.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)
torch.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.

torch.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.

torch.imagfunctionSame as PyTorch
imag(x)

The imaginary part of a complex tensor.

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

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

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

input + weight * (end - input).

torch.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.

torch.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).

torch.log10functionSame as PyTorch
log10(input)

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

torch.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.

torch.log2functionSame as PyTorch
log2(input)

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

torch.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.

torch.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).

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

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

torch.logical_andfunctionSame as PyTorch
logical_and(*args, **kw)

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

torch.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).

torch.logical_orfunctionSame as PyTorch
logical_or(*args, **kw)

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

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

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

torch.logitfunctionSame as PyTorch
logit(input)

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

torch.mulfunctionSame as PyTorch
mul(input, other)

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

torch.multiplyfunctionSame as PyTorch
multiply(input, other)

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

torch.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).

torch.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).

torch.negfunctionSame as PyTorch
neg(input)

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

torch.negativefunctionSame as PyTorch
negative(input)

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

torch.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.

torch.polygammafunctionSame as PyTorch
polygamma(n, input, *, out=None)

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

torch.positivefunctionSame as PyTorch
positive(input)

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

torch.powfunctionSame as PyTorch
pow(input, exponent)

A whole-number exponent multiplies (exact, any sign of the base; negative exponents take the reciprocal); otherwise base^e = 2^(e log2 base) (NaN for a negative base, as PyTorch).

torch.prelufunctionSame as PyTorch
prelu(input, weight)

weight has 1 or C (= input.shape[1]) entries, broadcast over dim 1.

torch.quantized_batch_normfunctionSame as PyTorch
quantized_batch_norm(input, weight, bias, mean, var, eps, output_scale, output_zero_point)

Batch norm (inference) of a quantized NC* tensor, requantized to (output_scale, output_zero_point).

torch.quantized_max_pool1dfunctionSame as PyTorch
quantized_max_pool1d(input, kernel_size, stride=(), padding=0, dilation=1, ceil_mode=False)

1-d max pooling of a quantized tensor, on its integers (exact; the same parameters).

torch.quantized_max_pool2dfunctionSame as PyTorch
quantized_max_pool2d(input, kernel_size, stride=(), padding=0, dilation=1, ceil_mode=False)

2-d max pooling of a quantized tensor, on its integers (exact; the same parameters).

torch.rad2degfunctionSame as PyTorch
rad2deg(input)

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

torch.realfunctionSame as PyTorch
real(x)

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

torch.reciprocalfunctionSame as PyTorch
reciprocal(input)

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

torch.relufunctionSame as PyTorch
relu(Tensor self, bool inplace=False) -> Tensor

max(x, 0). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types). A quantized input runs the quantized kernel (same parameters).

torch.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
torch.roundfunctionSame as PyTorch
round(input)

Halves to even, as PyTorch.

torch.rrelufunctionSame as PyTorch
rrelu(input, lower=0.125, upper=0.3333333333333333, training=False, generator=None)

Randomized leaky ReLU: slope drawn from U(lower, upper) per element when training, (lower + upper) / 2 otherwise. generator= is accepted and ignored (the global generator draws).

torch.rsqrtfunctionSame as PyTorch
rsqrt(input)

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

torch.selufunctionSame as PyTorch
selu(input, inplace=False)

scale * elu(x, alpha) with the SELU constants. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

torch.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).

torch.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).

torch.signfunctionSame as PyTorch
sign(input)

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

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

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

torch.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
torch.sincfunctionSame as PyTorch
sinc(input, *, out=None)

Same as PyTorch’s torch.sinc.

torch.sinhfunctionSame as PyTorch
sinh(input)

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

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

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

torch.sqrtfunctionSame as PyTorch
sqrt(input)

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

torch.squarefunctionSame as PyTorch
square(input)

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

torch.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.

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

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

torch.tanfunctionSame as PyTorch
tan(input)

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

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

Same as PyTorch’s torch.tanh.

torch.thresholdfunctionSame as PyTorch
threshold(input, threshold, value, inplace=False)

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

torch.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.

torch.truncfunctionSame as PyTorch
trunc(input)

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

torch.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).

Reductions

torch.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.

torch.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.

torch.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.

torch.aminmaxfunctionSame as PyTorch
aminmax(input, *, dim=None, keepdim=False)

(min, max) over dim, or over all elements when dim is None.

The pair's fields are.values (the min) and.indices (the max); PyTorch names them.min and.max.

torch.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.

torch.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.

torch.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.

torch.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.

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

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

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

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")
torch.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.

torch.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.

torch.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.

torch.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.

torch.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).

torch.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.

torch.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.

torch.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.

torch.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.

torch.normfunctionSame as PyTorch
norm(input, p: float | str | None = 'fro', dim=None, keepdim=False, out=None, 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.

torch.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.

torch.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.

torch.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.

torch.std_meanfunctionSame as PyTorch
std_mean(input, dim=None, *, correction=1, keepdim=False, out=None)

(std, mean) over dim (all elements when dim is None), std with correction (default 1).

torch.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
torch.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).

torch.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.

torch.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.

torch.var_meanfunctionSame as PyTorch
var_mean(input, dim=None, *, correction=1, keepdim=False, out=None)

(var, mean) over dim (all elements when dim is None), var with correction (default 1).

Comparison

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

Whether isclose holds everywhere; a Python bool.

torch.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.

torch.eqfunctionSame as PyTorch
eq(input, other)

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

torch.equalfunctionSame as PyTorch
equal(*a, **k)

True if both tensors have the same shape and the same values. A quantized input runs the quantized kernel (same parameters).

torch.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).

torch.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).

torch.gefunctionSame as PyTorch
ge(input, other)

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

torch.greaterfunctionSame as PyTorch
greater(input, other)

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

torch.greater_equalfunctionSame as PyTorch
greater_equal(input, other)

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

torch.gtfunctionSame as PyTorch
gt(input, other)

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

torch.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.

torch.isfinitefunctionSame as PyTorch
isfinite(input)

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

torch.isinfunctionSame as PyTorch
isin(elements, test_elements, *, assume_unique=False, invert=False)

Whether each element occurs in test_elements (invert=True negates); returns bool.

torch.isinffunctionSame as PyTorch
isinf(input)

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

torch.isnanfunctionSame as PyTorch
isnan(input)

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

torch.isneginffunctionSame as PyTorch
isneginf(x)

True where the element is -inf.

torch.isposinffunctionSame as PyTorch
isposinf(x)

True where the element is +inf.

torch.isrealfunctionSame as PyTorch
isreal(x)

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

torch.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.

torch.lefunctionSame as PyTorch
le(input, other)

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

torch.lessfunctionSame as PyTorch
less(input, other)

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

torch.less_equalfunctionSame as PyTorch
less_equal(input, other)

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

torch.ltfunctionSame as PyTorch
lt(input, other)

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

torch.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.

torch.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.

torch.msortfunctionSame as PyTorch
msort(input)

Sorts along dim 0 (ascending).

torch.nefunctionSame as PyTorch
ne(input, other)

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

torch.not_equalfunctionSame as PyTorch
not_equal(input, other)

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

torch.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.

torch.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.

Spectral and windows

torch.bartlett_windowfunctionSame as PyTorch
bartlett_window(window_length, periodic=True, **kw)

Bartlett (triangular) window 1 - |2 i / (N - 1) - 1| of window_length samples.

periodic=True (default): the first window_length samples of a window_length + 1 window. Computed in float64, returned in dtype.

torch.blackman_windowfunctionSame as PyTorch
blackman_window(window_length, periodic=True, **kw)

Blackman window 0.42 - 0.5 cos(2 pi i / (N - 1)) + 0.08 cos(4 pi i / (N - 1)) of window_length samples.

periodic=True (default): the first window_length samples of a window_length + 1 window. Computed in float64, returned in dtype.

torch.hamming_windowfunctionSame as PyTorch
hamming_window(window_length, periodic=True, alpha=0.54, beta=0.46, **kw)

Hamming window alpha - beta cos(2 pi i / (N - 1)) (alpha 0.54, beta 0.46) of window_length samples.

periodic=True (default): the first window_length samples of a window_length + 1 window. Computed in float64, returned in dtype.

torch.hann_windowfunctionSame as PyTorch
hann_window(window_length, periodic=True, **kw)

Hann window 0.5 - 0.5 cos(2 pi i / (N - 1)) of window_length samples.

periodic=True (default) gives the first window_length samples of a window_length + 1 window (for spectra). Computed in float64, returned in dtype (the default dtype when none).

torch.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.

torch.kaiser_windowfunctionSame as PyTorch
kaiser_window(window_length, periodic=True, beta=12.0, **kw)

Kaiser window I0(beta sqrt(1 - (2 i / (N - 1) - 1)^2)) / I0(beta) (beta 12 by default) of window_length samples.

periodic=True (default): the first window_length samples of a window_length + 1 window. Computed in float64, returned in dtype.

torch.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.

Other operations

torch.atleast_1dfunctionSame as PyTorch
atleast_1d(*tensors)

Each tensor with at least one dim (0-d becomes shape (1,)); one tensor in gives one out, several a tuple.

torch.atleast_2dfunctionSame as PyTorch
atleast_2d(*tensors)

Each tensor with at least two dims (0-d becomes (1, 1), 1-d (n,) becomes (1, n)); one in gives one out.

torch.atleast_3dfunctionSame as PyTorch
atleast_3d(*tensors)

Each tensor with at least three dims (0-d becomes (1, 1, 1), (n,) becomes (1, n, 1), (m, n) becomes (m, n, 1)).

torch.avg_pool1dfunctionSame as PyTorch
avg_pool1d(input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True)

F.avg_pool1d: the mean over windows along the last dim (a 2-d pool of height 1).

torch.batch_normfunctionSame as PyTorch
batch_norm(input, weight, bias, running_mean, running_var, training, momentum, eps, cudnn_enabled=True)

The aten argument order of F.batch_norm; cudnn_enabled is ignored.

torch.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.

torch.block_diagfunctionSame as PyTorch
block_diag(*tensors)

A block-diagonal matrix from the tensors (0-d and 1-d become one row), in the first tensor's dtype.

torch.broadcast_shapesfunctionSame as PyTorch
broadcast_shapes(*shapes)

The shape the given shapes broadcast to; RuntimeError when they don't, as PyTorch.

torch.broadcast_tensorsfunctionSame as PyTorch
broadcast_tensors(*tensors)

The tensors expanded to their common broadcast shape; also broadcast_shapes and broadcast_to.

torch.broadcast_tofunctionSame as PyTorch
broadcast_to(input, size)

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

torch.bucketizefunctionSame as PyTorch
bucketize(input, boundaries, *, out_int32=False, right=False, out=None)

The bucket of each value among the sorted 1-d boundaries (searchsorted with the arguments swapped); int64, or int32 with out_int32=True.

torch.cartesian_prodfunctionSame as PyTorch
cartesian_prod(*tensors)

Every combination of the 1-d tensors' entries as rows (one tensor: returned as it is).

torch.cdistfunctionSame as PyTorch
cdist(x1, x2, p=2.0, compute_mode=None, *, maths=None)

All pairwise p-distances between the rows of x1 [.., P, M] and x2 [.., R, M] -> [.., P, R].

torch.channel_shufflefunctionSame as PyTorch
channel_shuffle(input, groups)

Shuffles the channels (dim 1) across groups: (N, g*k,...) read as (N, g, k,...) and transposed.

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

Same as PyTorch’s torch.clone.

torch.combinationsfunctionSame as PyTorch
combinations(input, r=2, with_replacement=False)

The r-length combinations of the 1-d input's entries as rows, in itertools order.

torch.conv1dfunctionSame as PyTorch
conv1d(input, weight, bias=None, stride=(1,), padding=(0,), dilation=(1,), groups=1)

Same as PyTorch’s torch.conv1d.

torch.conv2dfunctionSame as PyTorch
conv2d(input, weight, bias=None, stride=(1,), padding=(0,), dilation=(1,), groups=1)

Stride, padding and dilation per dim (or padding "same" / "valid"; "same" pads the extra row / column after, as PyTorch), groups.

torch.conv3dfunctionSame as PyTorch
conv3d(input, weight, bias=None, stride=(1,), padding=(0,), dilation=(1,), groups=1)

Same as PyTorch’s torch.conv3d.

torch.conv_transpose1dfunctionSame as PyTorch
conv_transpose1d(input, weight, bias=None, stride=(1,), padding=(0,), output_padding=(0,), groups=1, dilation=(1,))

Same as PyTorch’s torch.conv_transpose1d.

torch.conv_transpose2dfunctionSame as PyTorch
conv_transpose2d(input, weight, bias=None, stride=(1,), padding=(0,), output_padding=(0,), groups=1, dilation=(1,))

Same as PyTorch’s torch.conv_transpose2d.

torch.conv_transpose3dfunctionSame as PyTorch
conv_transpose3d(input, weight, bias=None, stride=(1,), padding=(0,), output_padding=(0,), groups=1, dilation=(1,))

Same as PyTorch’s torch.conv_transpose3d.

torch.corrcoeffunctionSame as PyTorch
corrcoef(input)

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

torch.cosine_similarityfunctionSame as PyTorch
cosine_similarity(x1, x2, dim=1, eps=1e-08, *, maths=None)

Same as PyTorch’s torch.cosine_similarity.

torch.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.

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

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

torch.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.

torch.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.

torch.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.

torch.cumsumfunctionSame as PyTorch
cumsum(*a, **k)

The cumulative sum along dim, in dtype if given (integer inputs sum exactly); 0-d and 1-d inputs too.

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

torch.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.

torch.diag_embedfunctionDifferent from PyTorch
diag_embed(input, offset=0, dim1=-2, dim2=-1)

A matrix (per leading index) with input on diagonal offset; dim1=-2, dim2=-1 only (others raise NotImplementedError).

Different from PyTorch: A matrix (per leading index) with input on diagonal offset; dim1=-2, dim2=-1 only (others raise NotImplementedError).

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

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

torch.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).

torch.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.

torch.einsumfunctionSame as PyTorch
einsum(equation, *operands)

Einstein summation: the operands contracted as the equation says (the core's einsum; gradients flow).

torch.embeddingfunctionSame as PyTorch
embedding(weight, indices, padding_idx=-1, scale_grad_by_freq=False, sparse=False)

The aten argument order of F.embedding: rows of weight at indices (padding_idx -1 means none).

torch.embedding_bagfunctionSame as PyTorch
embedding_bag(weight, indices, offsets, scale_grad_by_freq=False, mode=0, sparse=False, per_sample_weights=None, include_last_offset=False, padding_idx=None)

(output, offset2bag, bag_size, max_indices), as PyTorch's CPU kernel fills them: offset2bag and bag_size are empty / zeros for mode sum, max_indices only for mode max.

torch.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. A quantized input runs the quantized kernel (same parameters).

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

input reversed along each of dims (an int or a sequence); a copy, as PyTorch.

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

torch.fliplrfunctionSame as PyTorch
fliplr(input)

input reversed along dim 1 (left / right).

torch.flipudfunctionSame as PyTorch
flipud(input)

input reversed along dim 0 (up / down).

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

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

torch.group_normfunctionSame as PyTorch
group_norm(input, num_groups, weight=None, bias=None, eps=1e-05)

Normalises each group of channels over its channels and spatial dims, then applies weight and bias per channel. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

torch.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).

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

(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.

torch.histogramddfunctionSame as PyTorch
histogramdd(input, bins, *, range=None, weight=None, density=False, out=None)

Multi-dimensional histogram of the points input[...,:D] (counts in float64 sums, returned in input's dtype): bins an int, a list of ints, or a list of edge tensors; the last bin of each dim includes its edge.

torch.instance_normfunctionSame as PyTorch
instance_norm(input, running_mean=None, running_var=None, weight=None, bias=None, use_input_stats=True, momentum=0.1, eps=1e-05, *, maths=None)

Each (sample, channel) normalised over its spatial dims (or by running statistics with use_input_stats=False). The running statistics are updated by the module (InstanceNorm*d).

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

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

torch.layer_normfunctionSame as PyTorch
layer_norm(input, normalized_shape, weight=None, bias=None, eps=1e-05, *, maths=None)

Over the last len(normalized_shape) dims; weight / bias of that shape (or none).

torch.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.

torch.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.

torch.max_pool1dfunctionSame as PyTorch
max_pool1d(*a, **k)

1-d max pooling (aten form: stride= means kernel_size). A quantized input runs the quantized kernel (same parameters).

torch.max_pool2dfunctionDifferent from PyTorch
max_pool2d(Tensor input, int[] kernel_size, int[] stride=(), int[] padding=(0,), int[] dilation=(1,), bool ceil_mode=False, bool return_indices=False) -> Tensor

Any window, stride and padding (padding counts as -inf): the max over the kh x kw shifted strided slices. ceil_mode / return_indices / dilation != 1 raise NotImplementedError. A quantized input runs the quantized kernel (same parameters).

Different from PyTorch: max_pool2d(Tensor input, int[] kernel_size, int[] stride=(), int[] padding=(0,), int[] dilation=(1,), bool ceil_mode=False, bool return_indices=False) -> Tensor Any window, stride and padding (padding counts as -inf): the max over the kh x kw shifted strided slices. ceil_mode / return_indices / dila

torch.max_pool3dfunctionSame as PyTorch
max_pool3d(*a, **k)

3-d max pooling (aten form: stride= means kernel_size). A quantized input runs the quantized kernel (same parameters).

torch.meshgridfunctionSame as PyTorch
meshgrid(*tensors, indexing=None)

Coordinate grids from 1-d tensors: indexing 'ij' (the default; PyTorch warns when it is not given and Riptorch does not) or 'xy' (the first two dims swapped). The grids are expanded views.

torch.pairwise_distancefunctionSame as PyTorch
pairwise_distance(x1, x2, p=2.0, eps=1e-06, keepdim=False, *, maths=None)

||x1 - x2 + eps||_p along the last dim (PyTorch adds eps to the difference).

torch.pdistfunctionSame as PyTorch
pdist(input, p=2)

Pairwise p-norm distances between the rows of a 2-d tensor (the upper triangle, row by row).

torch.pixel_shufflefunctionSame as PyTorch
pixel_shuffle(input, upscale_factor)

Rearranges (C r^2, H, W) to (C, H r, W r). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

torch.pixel_unshufflefunctionSame as PyTorch
pixel_unshuffle(input, downscale_factor)

Rearranges (C, H r, W r) to (C r^2, H, W). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).

torch.ravelfunctionSame as PyTorch
ravel(input)

input flattened to 1-d.

torch.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).

torch.repeat_interleavefunctionSame as PyTorch
repeat_interleave(Tensor self, int repeats, int? dim=None) -> Tensor

Repeats each element repeats times along dim (flattened when dim is None); per-element repeat counts raise NotImplementedError.

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

torch.resolve_conjfunctionSame as PyTorch
resolve_conj(x)

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

torch.resolve_negfunctionSame as PyTorch
resolve_neg(x)

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

torch.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.

torch.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.

torch.searchsortedfunctionSame as PyTorch
searchsorted(sorted_sequence, input, *, out_int32=False, right=False, side=None, sorter=None, out=None)

For each value, how many entries of the (last-dim) sorted sequence are < it (or <= it with right=True).

torch.tensordotfunctionSame as PyTorch
tensordot(a, b, dims=2, out=None)

The sum of products over dims: an int (a's last dims with b's first) or two lists of dims; one matmul.

torch.tracefunctionSame as PyTorch
trace(input)

The sum of the main diagonal.

torch.trilfunctionSame as PyTorch
tril(input, diagonal=0, *, out=None)

The upper triangle of the last two dims (on and above the diagonal-th diagonal), the rest zeros. Infinities are kept (selected, not multiplied by a mask), so the causal-mask idiom triu(full((n, n), -inf), 1) gives no nan.

torch.tril_indicesfunctionSame as PyTorch
tril_indices(row, col, offset=0, *, dtype=None, device=None, layout=None)

A 2 x K int64 tensor of the (row, col) positions of the lower triangle (col - row <= offset), row by row.

Also accepts pin_memory=, memory_format=, names= (one unified memory; strided layout only).

torch.triufunctionSame as PyTorch
triu(input, diagonal=0, *, out=None)

The upper triangle of the last two dims (on and above the diagonal-th diagonal), the rest zeros. Infinities are kept (selected, not multiplied by a mask), so the causal-mask idiom triu(full((n, n), -inf), 1) gives no nan.

torch.triu_indicesfunctionSame as PyTorch
triu_indices(row, col, offset=0, *, dtype=None, device=None, layout=None)

A 2 x K int64 tensor of the (row, col) positions of the upper triangle (col - row >= offset), row by row.

Also accepts pin_memory=, memory_format=, names= (one unified memory; strided layout only).

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

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

torch.vanderfunctionSame as PyTorch
vander(x, N=None, increasing=False)

torch.vander(x, N=None, increasing=False): decreasing powers by default (unlike linalg.vander).

torch.view_as_complexfunctionSame as PyTorch
view_as_complex(x)

A complex tensor over a float32 / float64 tensor whose last dim is 2 (real, imaginary), without a copy.

torch.view_as_realfunctionSame as PyTorch
view_as_real(x)

The [..., 2] float view (real, imaginary) of a complex tensor, without a copy; RuntimeError for real tensors.

BLAS and LAPACK

torch.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].

torch.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).

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

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

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

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

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

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

torch.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).

torch.chain_matmulfunctionSame as PyTorch
chain_matmul(*matrices, out=None)

torch.chain_matmul (deprecated in PyTorch): linalg.multi_dot of the matrices.

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

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

torch.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).

torch.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).

torch.cumulative_trapezoidfunctionSame as PyTorch
cumulative_trapezoid(y, x=None, *, dx=None, dim=-1)

The running trapezoid-rule integral of y along dim (one fewer entry), with sample points x or spacing dx.

torch.detfunctionSame as PyTorch
det(A, *, out=None, maths=None, exact=False)

Same as PyTorch’s torch.det.

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

The dot product of two 1-d tensors.

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

Same as PyTorch’s torch.geqrf.

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

The outer product of two vectors (ger too).

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

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

torch.inversefunctionSame as PyTorch
inverse(A, *, out=None)

torch.inverse: linalg.inv(A) (integer A gives the exact inverse as a FractionTensor).

torch.lobpcgfunctionDifferent from PyTorch
lobpcg(A, k=None, B=None, X=None, n=None, iK=None, niter=None, tol=None, largest=None, method=None, tracker=None, ortho_iparams=None, ortho_fparams=None, ortho_bparams=None)

Different from PyTorch: exact eigenpairs, identical on every call; PyTorch's random-start iteration was off by up to 3.7e-6 (relative) and varied by up to 5.8e-4 between calls on the same matrix

PyTorch
LOBPCG iteration from a random start: approximate (float32 relative eigenvalue error up to 3.7e-6) and different from call to call
Riptorch
the dense generalized eigenproblem solved directly (Cholesky of B, eigh): the converged answer the iteration approaches, the same on every call; X, niter, tol, method only shape the call
Measured
20 random 30x30 SPD float32 matrices, k=3 largest: PyTorch worst relative eigenvalue error 3.7e-6, spread between three calls on the same matrix up to 5.8e-4 absolute; Riptorch 5.4e-8 and identical across calls
Stock behaviour
the same direct solver (PyTorch's random starting block can't be reproduced, so its iterates can't be matched value for value)
torch.logdetfunctionSame as PyTorch
logdet(A)

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

torch.lufunctionSame as PyTorch
lu(A, pivot=True, get_infos=False, out=None)

Deprecated in PyTorch (with its warning): linalg.lu_factor, or linalg.lu_factor_ex with get_infos=True.

torch.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.

torch.lu_unpackfunctionSame as PyTorch
lu_unpack(LU_data, LU_pivots, unpack_data=True, unpack_pivots=True, *, out=None)

Same as PyTorch’s torch.lu_unpack.

torch.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")
torch.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).

torch.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.

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

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")
torch.mvfunctionSame as PyTorch
mv(input, vec, *, out=None)

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

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

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

torch.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.

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

The outer product of two vectors (ger too).

torch.pca_lowrankfunctionSame as PyTorch
pca_lowrank(A, q=None, center=True, niter=2)

Randomized PCA: (U, S, V) of A centered over its rows (center=True), rank q (default min(6, m, n)).

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

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

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

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

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

Same as PyTorch’s torch.slogdet.

torch.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.

torch.svd_lowrankfunctionSame as PyTorch
svd_lowrank(A, q=6, niter=2, M=None)

Randomized SVD (Halko, Martinsson & Tropp, 2009): U, S, V with A ~ U diag(S) V^T, rank q.

torch.trapezoidfunctionSame as PyTorch
trapezoid(y, x=None, *, dx=None, dim=-1)

The trapezoid-rule integral of y along dim, with sample points x or spacing dx (default 1).

torch.trapzfunctionSame as PyTorch
trapz(y, x=None, *, dx=None, dim=-1)

The trapezoid-rule integral of y along dim, with sample points x or spacing dx (default 1).

torch.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).

torch.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).

Utilities

are_deterministic_algorithms_enabled()

The flag use_deterministic_algorithms recorded.

torch.can_castfunctionSame as PyTorch
can_cast(from_, to)

Whether a cast from from_ to to is allowed under PyTorch's casting rule: never to a lower category (complex > float > integer > bool).

torch.compilefunctionDifferent from PyTorch
compile(model=None, *, fullgraph=False, dynamic=None, backend="inductor", mode=None, options=None, disable=False)

Accepts torch.compile's arguments. A function is recorded once and replayed on later calls; a module comes back wrapped and runs eagerly (its _orig_mod is the module); disable=True returns the input unchanged. Riptorch builds and caches its own programs for every graph, compiled or not, so eager code is already compiled underneath.

Different from PyTorch: records a function once and replays it; a module runs eagerly (Riptorch compiles every graph anyway).

torch.compiled_with_cxx11_abifunctionSame as PyTorch
compiled_with_cxx11_abi()

True, as PyTorch's macOS builds report.

torch.condfunctionSame as PyTorch
cond(pred, true_fn, false_fn, operands=())

true_fn(*operands) if pred else false_fn(*operands), run eagerly (pred read as a bool).

torch.get_autocast_dtypefunctionSame as PyTorch
get_autocast_dtype(device_type='cpu')

The dtype autocast uses on device_type (set_autocast_dtype's, else bfloat16 for cpu / xla, float16 elsewhere; while an autocast region is active, its dtype).

torch.get_deterministic_debug_modefunctionSame as PyTorch
get_deterministic_debug_mode()

0 ('default').

torch.get_device_modulefunctionSame as PyTorch
get_device_module(device=None)

The torch.<device type> module for a device ('cpu' when none is given).

torch.get_float32_matmul_precisionfunctionSame as PyTorch
get_float32_matmul_precision()

The precision set_float32_matmul_precision recorded ('highest' by default; Riptorch's matmul precision is set with torch.set_matmul).

torch.is_autocast_enabledfunctionSame as PyTorch
is_autocast_enabled(device_type=None)

Whether autocast is on for device_type (no argument: cuda, PyTorch's deprecated form).

is_deterministic_algorithms_warn_only_enabled()

The warn_only flag use_deterministic_algorithms recorded.

torch.is_warn_always_enabledfunctionSame as PyTorch
is_warn_always_enabled()

False.

torch.promote_typesfunctionSame as PyTorch
promote_types(type1, type2)

The dtype both types promote to: float beats integer, the wider type beats the narrower; uint8 with int8 gives int16 and float16 with bfloat16 gives float32.

torch.result_typefunctionSame as PyTorch
result_type(tensor1, tensor2)

The dtype an operation on the two arguments returns: the higher category wins (bool < integer < float), then a tensor with dims beats a 0-d tensor beats a Python number, then promote_types.

torch.set_autocast_enabledfunctionSame as PyTorch
set_autocast_enabled(*args)

set_autocast_enabled([device_type,] enabled): turns autocast on or off (device_type defaults to cuda).

torch.set_deterministic_debug_modefunctionSame as PyTorch
set_deterministic_debug_mode(mode)

Does nothing: Riptorch's ops are deterministic.

torch.set_float32_matmul_precisionfunctionSame as PyTorch
set_float32_matmul_precision(p)

Records 'highest', 'high' or 'medium' (RuntimeError otherwise); use torch.set_matmul to change Riptorch's matmul precision.

torch.set_warn_alwaysfunctionSame as PyTorch
set_warn_always(b)

Does nothing (Riptorch's warnings follow Python's warnings filters).

torch.typenamefunctionSame as PyTorch
typename(obj)

The name of obj's type: the legacy tensor type name for tensors (torch.FloatTensor, torch.LongTensor,...), module.qualname otherwise.

torch.use_deterministic_algorithmsfunctionSame as PyTorch
use_deterministic_algorithms(mode, *, warn_only=False)

Records the flag (Riptorch's ops are deterministic either way).

torch.vmapfunctionSame as PyTorch
vmap(func, in_dims=0, out_dims=0, randomness='error', *, chunk_size=None)

torch.vmap: func applied to each slice along in_dims, the results stacked along out_dims (run slice by slice; gradients flow).

torch.while_loopfunctionSame as PyTorch
while_loop(cond_fn, body_fn, carried_inputs)

Runs carried = body_fn(*carried) while cond_fn(*carried) is true, eagerly; returns the final tuple.

Classes

torch.AcceleratorErrorclassSame as PyTorch
AcceleratorError

An accelerator failed (a RuntimeError, as PyTorch).

torch.AggregationTypeclassSame as PyTorch
AggregationType(*values)

Same as PyTorch’s torch.AggregationType.

torch.AliasDbclassSame as PyTorch
AliasDb(*a, **k)

Same as PyTorch’s torch.AliasDb.

torch.AnyTypeclassSame as PyTorch
AnyType(*a, **k)

Same as PyTorch’s torch.AnyType.

torch.ArgumentclassSame as PyTorch
Argument(*args)

One argument (or return) of an operator schema.

torch.ArgumentSpecclassSame as PyTorch
ArgumentSpec(*a, **k)

Same as PyTorch’s torch.ArgumentSpec.

torch.autocastclassSame as PyTorch
autocast(device_type='cpu', dtype=None, enabled=True, cache_enabled=None)

torch.autocast: a context manager / decorator for mixed precision as PyTorch's CPU autocast (matmul, linear, conv, attention in the autocast dtype; losses in float32).

torch.AwaitTypeclassSame as PyTorch
AwaitType(*args)

Same as PyTorch’s torch.AwaitType.

torch.BenchmarkConfigclassSame as PyTorch
BenchmarkConfig()

ThroughputBenchmark settings: num_calling_threads, num_worker_threads, num_warmup_iters, num_iters, profiler_output_path.

torch.BenchmarkExecutionStatsclassSame as PyTorch
BenchmarkExecutionStats(*a, **k)

Raw ThroughputBenchmark results: latency_avg_ms and num_iters (not constructible, as PyTorch).

torch.BFloat16StorageclassSame as PyTorch
BFloat16Storage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.bfloat16)

Same as PyTorch’s torch.BFloat16Storage.

torch.BFloat16TensorclassSame as PyTorch
BFloat16Tensor(*data)

torch.BFloat16Tensor: the legacy constructor of bfloat16 tensors: BFloat16Tensor(sizes...) gives zeros, BFloat16Tensor([data]) a tensor of the data; isinstance(x, BFloat16Tensor) checks the dtype.

torch.BlockclassSame as PyTorch
Block(*a, **k)

A list of nodes with its own inputs (param node) and outputs (return node).

torch.BoolStorageclassSame as PyTorch
BoolStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.bool)

Same as PyTorch’s torch.BoolStorage.

torch.BoolTensorclassSame as PyTorch
BoolTensor(*data)

torch.BoolTensor: the legacy constructor of bool tensors: BoolTensor(sizes...) gives zeros, BoolTensor([data]) a tensor of the data; isinstance(x, BoolTensor) checks the dtype.

torch.BoolTypeclassSame as PyTorch
BoolType(*a, **k)

Same as PyTorch’s torch.BoolType.

torch.BufferDictclassSame as PyTorch
BufferDict(*args)

The buffers of a C++ ScriptModule, by name.

torch.ByteStorageclassSame as PyTorch
ByteStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.uint8)

Same as PyTorch’s torch.ByteStorage.

torch.ByteTensorclassSame as PyTorch
ByteTensor(*data)

torch.ByteTensor: the legacy constructor of uint8 tensors: ByteTensor(sizes...) gives zeros, ByteTensor([data]) a tensor of the data; isinstance(x, ByteTensor) checks the dtype.

torch.CallStackclassSame as PyTorch
CallStack(*args)

A TorchScript call-stack entry: name and source range.

torch.CapsuleclassSame as PyTorch
Capsule(*a, **k)

Same as PyTorch’s torch.Capsule.

torch.CharStorageclassSame as PyTorch
CharStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.int8)

Same as PyTorch’s torch.CharStorage.

torch.CharTensorclassSame as PyTorch
CharTensor(*data)

torch.CharTensor: the legacy constructor of int8 tensors: CharTensor(sizes...) gives zeros, CharTensor([data]) a tensor of the data; isinstance(x, CharTensor) checks the dtype.

torch.ClassTypeclassSame as PyTorch
ClassType(*args)

A TorchScript class type, by qualified name (ClassType("__torch__.M")). PyTorch raises when constructed from Python; Riptorch builds it.

torch.CodeclassSame as PyTorch
Code(*a, **k)

Same as PyTorch’s torch.Code.

torch.CompilationUnitclassSame as PyTorch
CompilationUnit(lang=None, _frames_up=0)

Same as PyTorch’s torch.CompilationUnit.

torch.CompleteArgumentSpecclassSame as PyTorch
CompleteArgumentSpec(*a, **k)

Same as PyTorch’s torch.CompleteArgumentSpec.

torch.ComplexDoubleStorageclassSame as PyTorch
ComplexDoubleStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.complex128)

Same as PyTorch’s torch.ComplexDoubleStorage.

torch.ComplexFloatStorageclassSame as PyTorch
ComplexFloatStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.complex64)

Same as PyTorch’s torch.ComplexFloatStorage.

torch.ComplexTensorclassRiptorch extra
ComplexTensor(rv)

A complex tensor: _rv is its real view [..., 2].

Riptorch extra: not in stock PyTorch.

torch.ComplexTypeclassSame as PyTorch
ComplexType(*a, **k)

Same as PyTorch’s torch.ComplexType.

torch.ConcreteModuleTypeclassSame as PyTorch
ConcreteModuleType(*a, **k)

Same as PyTorch’s torch.ConcreteModuleType.

ConcreteModuleTypeBuilder(*args)

Collects what a module type has (attributes, modules, constants,...) before it is built.

torch.DeepCopyMemoTableclassSame as PyTorch
DeepCopyMemoTable(*a, **k)

Same as PyTorch’s torch.DeepCopyMemoTable.

DeserializationStorageContext()

Storages by key while an archive is loaded.

torch.deviceclassSame as PyTorch
device(type, index=None)

torch.device: a device type and index. Riptorch's tensors are in unified memory: every tensor reports cpu.

torch.DeviceObjTypeclassSame as PyTorch
DeviceObjType(*a, **k)

Same as PyTorch’s torch.DeviceObjType.

torch.DictTypeclassSame as PyTorch
DictType(*args)

Same as PyTorch’s torch.DictType.

torch.DisableTorchFunctionclassSame as PyTorch
DisableTorchFunction()

Context manager: no __torch_function__ is called inside (Riptorch has none).

DisableTorchFunctionSubclass()

Context manager: __torch_function__ of tensor subclasses is not called inside (Riptorch has none).

torch.DispatchKeyclassSame as PyTorch
DispatchKey(*values)

Same as PyTorch’s torch.DispatchKey.

torch.DispatchKeySetclassSame as PyTorch
DispatchKeySet(*args)

A set of dispatch keys (| & -, has, add, remove, highestPriorityTypeId, raw_repr).

torch.DoubleStorageclassSame as PyTorch
DoubleStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.float64)

Same as PyTorch’s torch.DoubleStorage.

torch.DoubleTensorclassSame as PyTorch
DoubleTensor(*data)

torch.DoubleTensor: the legacy constructor of float64 tensors: DoubleTensor(sizes...) gives zeros, DoubleTensor([data]) a tensor of the data; isinstance(x, DoubleTensor) checks the dtype.

torch.dtypeclassSame as PyTorch
dtype(name, code, size, ctype, floating, signed=True, fmt=None)

A dtype. It is also its name (a str), so code that compared dtype strings keeps working.

torch.EnumTypeclassSame as PyTorch
EnumType(*args)

A TorchScript enum type: EnumType(qualified_name, value_type, values).

torch.ErrorReportclassSame as PyTorch
ErrorReport(*args)

A TorchScript compile error at a source range (an Exception).

torch.EventclassSame as PyTorch
Event(device=None, *, enable_timing=False, blocking=False, interprocess=False)

torch.Event: a marker recorded on a stream. query is True (Riptorch's work is ordered and finishes before a value is read); elapsed_time is the wall-clock time between the two records, in milliseconds.

torch.ExcludeDispatchKeyGuardclassSame as PyTorch
ExcludeDispatchKeyGuard(*args)

Excludes dispatch keys while alive (Riptorch dispatches without keys: a guard with nothing to exclude).

torch.ExecutionPlanclassSame as PyTorch
ExecutionPlan(*a, **k)

Same as PyTorch’s torch.ExecutionPlan.

torch.FatalErrorclassSame as PyTorch
FatalError

An unrecoverable error (PyTorch's torch.FatalError).

torch.FileCheckclassSame as PyTorch
FileCheck()

Checks a string (or a Graph's text) against a sequence of patterns, as LLVM FileCheck: check, check_next, check_same, check_not, check_count, check_dag, check_regex; run raises RuntimeError on the first failure.

torch.finfoclassSame as PyTorch
finfo(type=None)

The floating-point limits of a dtype (IEEE 754 and the OCP 8-bit formats), as PyTorch reports them.

torch.FloatStorageclassSame as PyTorch
FloatStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.float32)

Same as PyTorch’s torch.FloatStorage.

torch.FloatTensorclassSame as PyTorch
FloatTensor(*data)

torch.FloatTensor: the legacy constructor of float32 tensors: FloatTensor(sizes...) gives zeros, FloatTensor([data]) a tensor of the data; isinstance(x, FloatTensor) checks the dtype.

torch.FloatTypeclassSame as PyTorch
FloatType(*a, **k)

Same as PyTorch’s torch.FloatType.

torch.FractionTensorclassRiptorch extra
FractionTensor(values, shape)

Exact results: a tensor of reduced fractions (Python ints of any size, no rounding).

.numerator /.denominator -> int64 tensors (OverflowError when an entry does not fit);.fractions /.tolist -> nested lists of fractions.Fraction;.to(dtype) /.double /.float -> each entry correctly rounded once;.shape,.dim,.numel, [i] (a FractionTensor or a Fraction), ==, @ (exact matrix product). Build one from a tensor or nested lists of ints / Fractions with FractionTensor.of(x).

Riptorch extra: not in stock PyTorch.

torch.FunctionSchemaclassSame as PyTorch
FunctionSchema(*args)

An operator schema: name, overload_name, arguments, returns (parse_schema reads the text form).

torch.FutureclassSame as PyTorch
Future(*, devices=None)

A value that becomes available later: set_result / set_exception once; wait, value, done, then, add_done_callback (callbacks run when it completes, or at once if it already has).

torch.FutureTypeclassSame as PyTorch
FutureType(*args)

Same as PyTorch’s torch.FutureType.

torch.GradientclassSame as PyTorch
Gradient(*a, **k)

Same as PyTorch’s torch.Gradient.

torch.GradScalerclassSame as PyTorch
GradScaler(device='cuda', init_scale=65536.0, growth_factor=2.0, backoff_factor=0.5, growth_interval=2000, enabled=True)

torch.amp.GradScaler: dynamic loss scaling for float16 training (scale the loss, unscale and check gradients, skip steps with inf / nan, grow or back off the scale).

torch.GraphclassSame as PyTorch
Graph()

A TorchScript-style graph: graph inputs, nodes in order, outputs; printed in TorchScript's IR text form.

torch.GraphExecutorStateclassSame as PyTorch
GraphExecutorState(*a, **k)

Same as PyTorch’s torch.GraphExecutorState.

torch.HalfStorageclassSame as PyTorch
HalfStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.float16)

Same as PyTorch’s torch.HalfStorage.

torch.HalfTensorclassSame as PyTorch
HalfTensor(*data)

torch.HalfTensor: the legacy constructor of float16 tensors: HalfTensor(sizes...) gives zeros, HalfTensor([data]) a tensor of the data; isinstance(x, HalfTensor) checks the dtype.

torch.iinfoclassSame as PyTorch
iinfo(type)

Bits, min and max of an integer dtype; bool and float dtypes raise TypeError, as PyTorch.

torch.InferredTypeclassSame as PyTorch
InferredType(*args)

The result of inferring a value's type: success and type, or reason.

torch.InterfaceTypeclassSame as PyTorch
InterfaceType(*args)

A TorchScript interface type, by qualified name.

torch.IntStorageclassSame as PyTorch
IntStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.int32)

Same as PyTorch’s torch.IntStorage.

torch.IntTensorclassSame as PyTorch
IntTensor(*data)

torch.IntTensor: the legacy constructor of int32 tensors: IntTensor(sizes...) gives zeros, IntTensor([data]) a tensor of the data; isinstance(x, IntTensor) checks the dtype.

torch.IntTypeclassSame as PyTorch
IntType(*a, **k)

Same as PyTorch’s torch.IntType.

torch.IODescriptorclassSame as PyTorch
IODescriptor(*a, **k)

Same as PyTorch’s torch.IODescriptor.

torch.JITExceptionclassSame as PyTorch
JITException

Unspecified run-time error.

torch.layoutclassSame as PyTorch
layout(name)

torch.layout: strided, sparse_coo, sparse_csr, sparse_csc, sparse_bsr, sparse_bsc, jagged, _mkldnn.

torch.ListTypeclassSame as PyTorch
ListType(*args)

Same as PyTorch’s torch.ListType.

torch.LiteScriptModuleclassSame as PyTorch
LiteScriptModule(*args)

A module of the TorchScript mobile runtime; construction raises as PyTorch does from Python.

torch.LockingLoggerclassSame as PyTorch
LockingLogger()

Counters by key, summed or averaged (set_aggregation_type).

torch.LoggerBaseclassSame as PyTorch
LoggerBase(*a, **k)

Base of the TorchScript stat loggers (not constructible, as PyTorch).

torch.LongStorageclassSame as PyTorch
LongStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.int64)

Same as PyTorch’s torch.LongStorage.

torch.LongTensorclassSame as PyTorch
LongTensor(*data)

torch.LongTensor: the legacy constructor of int64 tensors: LongTensor(sizes...) gives zeros, LongTensor([data]) a tensor of the data; isinstance(x, LongTensor) checks the dtype.

torch.memory_formatclassSame as PyTorch
memory_format(name)

torch.memory_format: a name (contiguous_format, channels_last,...); Riptorch tensors have one layout.

torch.ModuleDictclassSame as PyTorch
ModuleDict(modules=None)

torch.nn.ModuleDict: modules by name, registered as submodules in insertion order.

torch.NestedTensorclassRiptorch extra
NestedTensor(ts, lay=None, ragged=None, lengths=None, offsets=None)

A nested tensor: _ts (the components), _lay (strided or jagged), _ragged (the RaggedInt of a jagged tensor's ragged dim).

Riptorch extra: not in stock PyTorch.

torch.NodeclassSame as PyTorch
Node(*a, **k)

One operation of the IR: kind ("aten::add"), inputs, outputs, attributes, blocks.

torch.NoneTypeclassSame as PyTorch
NoneType(*a, **k)

Same as PyTorch’s torch.NoneType.

torch.NoopLoggerclassSame as PyTorch
NoopLogger()

A stat logger that records nothing.

torch.NumberTypeclassSame as PyTorch
NumberType(*a, **k)

Same as PyTorch’s torch.NumberType.

torch.OperatorInfoclassSame as PyTorch
OperatorInfo(*a, **k)

Same as PyTorch’s torch.OperatorInfo.

torch.OptionalTypeclassSame as PyTorch
OptionalType(*args)

Same as PyTorch’s torch.OptionalType.

torch.OutOfMemoryErrorclassSame as PyTorch
OutOfMemoryError

Out of memory (a RuntimeError, as PyTorch).

torch.ParameterDictclassSame as PyTorch
ParameterDict(parameters=None)

Parameters by key, registered under the keys; plain tensors become parameters.

torch.PyObjectTypeclassSame as PyTorch
PyObjectType(*a, **k)

Same as PyTorch’s torch.PyObjectType.

torch.PyTorchFileReaderclassSame as PyTorch
PyTorchFileReader(f)

Reads a torch.save zip archive: records by name (without the archive's directory).

torch.PyTorchFileWriterclassSame as PyTorch
PyTorchFileWriter(file_name, compute_crc32=True, storage_alignment=64)

Writes the zip archive torch.save uses: records under <archive>/, plus version / byteorder /.data/serialization_id at the end.

torch.QInt32StorageclassSame as PyTorch
QInt32Storage(*args, wrap_storage=None, dtype=None, device=None, _internal=False)

A storage of quantized values (torch.<Name>Storage): its raw integers.

torch.QInt8StorageclassSame as PyTorch
QInt8Storage(*args, wrap_storage=None, dtype=None, device=None, _internal=False)

A storage of quantized values (torch.<Name>Storage): its raw integers.

torch.qschemeclassSame as PyTorch
qscheme(name)

torch.qscheme: how a quantized tensor maps its integers to reals.

torch.QTensorclassRiptorch extra
QTensor(qr, qd, qs, scale=None, zp=None, scales=None, zps=None, axis=None)

A quantized tensor: _qr its integers (int_repr, unpacked), _qd its dtype, _qs its qscheme, and the quantization parameters (_scale, _zp per tensor; _scales, _zps, _axis per channel).

Riptorch extra: not in stock PyTorch.

torch.QUInt2x4StorageclassSame as PyTorch
QUInt2x4Storage(*args, wrap_storage=None, dtype=None, device=None, _internal=False)

A storage of quantized values (torch.<Name>Storage): its raw integers.

torch.QUInt4x2StorageclassSame as PyTorch
QUInt4x2Storage(*args, wrap_storage=None, dtype=None, device=None, _internal=False)

A storage of quantized values (torch.<Name>Storage): its raw integers.

torch.QUInt8StorageclassSame as PyTorch
QUInt8Storage(*args, wrap_storage=None, dtype=None, device=None, _internal=False)

A storage of quantized values (torch.<Name>Storage): its raw integers.

torch.RRefTypeclassSame as PyTorch
RRefType(*args)

Same as PyTorch’s torch.RRefType.

torch.ScriptClassclassSame as PyTorch
ScriptClass(*a, **k)

Same as PyTorch’s torch.ScriptClass.

torch.ScriptClassFunctionclassSame as PyTorch
ScriptClassFunction(*a, **k)

Same as PyTorch’s torch.ScriptClassFunction.

torch.ScriptDictclassSame as PyTorch
ScriptDict(*args)

A dict usable from TorchScript (a dict here).

torch.ScriptDictIteratorclassSame as PyTorch
ScriptDictIterator(*a, **k)

Same as PyTorch’s torch.ScriptDictIterator.

torch.ScriptDictKeyIteratorclassSame as PyTorch
ScriptDictKeyIterator(*a, **k)

Same as PyTorch’s torch.ScriptDictKeyIterator.

torch.ScriptFunctionclassSame as PyTorch
ScriptFunction(*a, **k)

Same as PyTorch’s torch.ScriptFunction.

torch.ScriptListclassSame as PyTorch
ScriptList(*args)

A list usable from TorchScript (a list here).

torch.ScriptListIteratorclassSame as PyTorch
ScriptListIterator(*a, **k)

Same as PyTorch’s torch.ScriptListIterator.

torch.ScriptMethodclassSame as PyTorch
ScriptMethod(*a, **k)

Same as PyTorch’s torch.ScriptMethod.

torch.ScriptModuleclassSame as PyTorch
ScriptModule(*args)

torch.ScriptModule (C++ side): built from (name, CompilationUnit, shared); Riptorch scripted modules are nn.Modules, so this holds the name and unit only.

torch.ScriptModuleSerializerclassSame as PyTorch
ScriptModuleSerializer(*args)

Writes a ScriptModule archive; serialize raises (TorchScript serialization needs TorchScript).

torch.ScriptObjectclassSame as PyTorch
ScriptObject(*a, **k)

Same as PyTorch’s torch.ScriptObject.

torch.ScriptObjectPropertyclassSame as PyTorch
ScriptObjectProperty(*a, **k)

Same as PyTorch’s torch.ScriptObjectProperty.

SerializationStorageContext(*a, **k)

Same as PyTorch’s torch.SerializationStorageContext.

torch.ShortStorageclassSame as PyTorch
ShortStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.int16)

Same as PyTorch’s torch.ShortStorage.

torch.ShortTensorclassSame as PyTorch
ShortTensor(*data)

torch.ShortTensor: the legacy constructor of int16 tensors: ShortTensor(sizes...) gives zeros, ShortTensor([data]) a tensor of the data; isinstance(x, ShortTensor) checks the dtype.

torch.SimilarityIndexclassRiptorch extra
SimilarityIndex(keys, metric="cosine", exact=False, eps=1e-08)

Stored vectors ([N, D]) prepared once for repeated searches. index.search(queries, k) returns (values, indices) exactly as similarity_topk does.

With exact=False the keys are kept as float32 rows on the device that searches them, together with each key's norm. With exact=True the keys must be whole numbers (int8 or int16) and each key's quadrance Q(x) = x·x is stored exactly, so every search is exact.

SimilarityIndex(keys, metric="cross", exact=True) is the recommended exact retrieval index; len(index) is the number of stored vectors.

torch.SizeclassSame as PyTorch
Size(sizes=())

torch.Size: a tuple of ints (numel, and a tuple's operations).

torch.SparseTensorclassRiptorch extra
SparseTensor(lay, size, vals, idx=None, cidx=None, pidx=None, blocksize=None, coalesced=False)

A sparse tensor of any sparse layout (see the module docstring).

Riptorch extra: not in stock PyTorch.

torch.StaticModuleclassSame as PyTorch
StaticModule(*a, **k)

Same as PyTorch’s torch.StaticModule.

torch.StorageclassSame as PyTorch
Storage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.float32)

Same as PyTorch’s torch.Storage.

torch.StorageBaseclassSame as PyTorch
StorageBase(*args, device=None)

torch.UntypedStorage: bytes.

torch.StreamclassSame as PyTorch
Stream(device=None, *, priority=0, **kwargs)

torch.Stream: a device stream. Riptorch orders all work itself (one queue per process), so a stream is an identity: mps streams get increasing ids (the current stream is 0), cpu streams are stream 0 of device -1. As PyTorch on a Mac: mps streams can't be queried or synchronized directly, cpu streams can't record events.

torch.StreamObjTypeclassSame as PyTorch
StreamObjType(*a, **k)

Same as PyTorch’s torch.StreamObjType.

torch.StringTypeclassSame as PyTorch
StringType(*a, **k)

Same as PyTorch’s torch.StringType.

torch.SymBoolclassSame as PyTorch
SymBool(node)

Same as PyTorch’s torch.SymBool.

torch.SymBoolTypeclassSame as PyTorch
SymBoolType()

Same as PyTorch’s torch.SymBoolType.

torch.SymFloatclassSame as PyTorch
SymFloat(node)

Same as PyTorch’s torch.SymFloat.

torch.SymIntclassSame as PyTorch
SymInt(node)

Same as PyTorch’s torch.SymInt.

torch.SymIntTypeclassSame as PyTorch
SymIntType()

Same as PyTorch’s torch.SymIntType.

torch.TagclassSame as PyTorch
Tag(*values)

Same as PyTorch’s torch.Tag.

torch.TensorclassSame as PyTorch
Tensor(handle)

A tensor: values of one dtype in a shape, held by Riptorch's Raya core. Every tensor lives in one unified memory, so device arguments are accepted and change nothing. Created by torch.tensor, the factories (zeros, rand,...) and operations.

torch.TensorTypeclassSame as PyTorch
TensorType(*a, **k)

The TorchScript tensor type: TensorType.get (any tensor) or the dtype, sizes and requires_grad of one tensor (create_from_tensor).

torch.ThroughputBenchmarkclassSame as PyTorch
ThroughputBenchmark(module)

Runs a module (or function) on recorded inputs from several threads and measures latency / throughput.

torch.TracingStateclassSame as PyTorch
TracingState(*a, **k)

Same as PyTorch’s torch.TracingState.

torch.TupleTypeclassSame as PyTorch
TupleType(*args)

Same as PyTorch’s torch.TupleType.

torch.TypeclassSame as PyTorch
Type(*a, **k)

A TorchScript type: str, kind, isSubtypeOf, containedTypes; tensor queries on TensorType.

torch.TypedStorageclassSame as PyTorch
TypedStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False)

torch.TypedStorage (deprecated in PyTorch, with its warning): a flat, typed sequence. From a tensor (Tensor.storage), reads and writes go to that tensor's elements.

torch.UnionTypeclassSame as PyTorch
UnionType(*args)

Same as PyTorch’s torch.UnionType.

torch.UntypedStorageclassSame as PyTorch
UntypedStorage(*args, device=None)

torch.UntypedStorage: bytes.

torch.UseclassSame as PyTorch
Use(*a, **k)

One use of a Value: the node using it (user) and the input position (offset).

torch.ValueclassSame as PyTorch
Value(*a, **k)

A value of the IR: one node's output or a graph / block input.

Data types and constants

torch.bfloat16valueSame as PyTorch
bfloat16 = riptorch.bfloat16

Same as PyTorch’s torch.bfloat16.

torch.boolvalueSame as PyTorch
bool = riptorch.bool

Same as PyTorch’s torch.bool.

torch.cdoublevalueSame as PyTorch
cdouble = riptorch.complex128

Same as PyTorch’s torch.cdouble.

torch.cfloatvalueSame as PyTorch
cfloat = riptorch.complex64

Same as PyTorch’s torch.cfloat.

torch.channels_lastvalueSame as PyTorch
channels_last = riptorch.channels_last

Same as PyTorch’s torch.channels_last.

torch.channels_last_3dvalueSame as PyTorch
channels_last_3d = riptorch.channels_last_3d

Same as PyTorch’s torch.channels_last_3d.

torch.complex128valueSame as PyTorch
complex128 = riptorch.complex128

Same as PyTorch’s torch.complex128.

torch.complex64valueSame as PyTorch
complex64 = riptorch.complex64

Same as PyTorch’s torch.complex64.

torch.contiguous_formatvalueSame as PyTorch
contiguous_format = riptorch.contiguous_format

Same as PyTorch’s torch.contiguous_format.

torch.doublevalueSame as PyTorch
double = riptorch.float64

Same as PyTorch’s torch.double.

torch.evalueSame as PyTorch
e = 2.718281828459045

Same as PyTorch’s torch.e.

torch.floatvalueSame as PyTorch
float = riptorch.float32

Same as PyTorch’s torch.float.

torch.float16valueSame as PyTorch
float16 = riptorch.float16

Same as PyTorch’s torch.float16.

torch.float32valueSame as PyTorch
float32 = riptorch.float32

Same as PyTorch’s torch.float32.

torch.float64valueSame as PyTorch
float64 = riptorch.float64

Same as PyTorch’s torch.float64.

torch.float8_e4m3fnvalueSame as PyTorch
float8_e4m3fn = riptorch.float8_e4m3fn

Same as PyTorch’s torch.float8_e4m3fn.

torch.float8_e4m3fnuzvalueSame as PyTorch
float8_e4m3fnuz = riptorch.float8_e4m3fnuz

Same as PyTorch’s torch.float8_e4m3fnuz.

torch.float8_e5m2valueSame as PyTorch
float8_e5m2 = riptorch.float8_e5m2

Same as PyTorch’s torch.float8_e5m2.

torch.float8_e5m2fnuzvalueSame as PyTorch
float8_e5m2fnuz = riptorch.float8_e5m2fnuz

Same as PyTorch’s torch.float8_e5m2fnuz.

torch.float8_e8m0fnuvalueSame as PyTorch
float8_e8m0fnu = riptorch.float8_e8m0fnu

Same as PyTorch’s torch.float8_e8m0fnu.

torch.halfvalueSame as PyTorch
half = riptorch.float16

Same as PyTorch’s torch.half.

torch.infvalueSame as PyTorch
inf = inf

Same as PyTorch’s torch.inf.

torch.intvalueSame as PyTorch
int = riptorch.int32

Same as PyTorch’s torch.int.

torch.int16valueSame as PyTorch
int16 = riptorch.int16

Same as PyTorch’s torch.int16.

torch.int32valueSame as PyTorch
int32 = riptorch.int32

Same as PyTorch’s torch.int32.

torch.int64valueSame as PyTorch
int64 = riptorch.int64

Same as PyTorch’s torch.int64.

torch.int8valueSame as PyTorch
int8 = riptorch.int8

Same as PyTorch’s torch.int8.

torch.jaggedvalueSame as PyTorch
jagged = torch.jagged

Same as PyTorch’s torch.jagged.

torch.longvalueSame as PyTorch
long = riptorch.int64

Same as PyTorch’s torch.long.

torch.LOSSESvalueRiptorch extra
LOSSES = ('cross_entropy', 'brier', 'spherical')

Riptorch extra: not in stock PyTorch.

torch.nanvalueSame as PyTorch
nan = nan

Same as PyTorch’s torch.nan.

torch.per_channel_affinevalueSame as PyTorch
per_channel_affine = riptorch.per_channel_affine

Same as PyTorch’s torch.per_channel_affine.

per_channel_affine_float_qparams = riptorch.per_channel_affine_float_qparams

Same as PyTorch’s torch.per_channel_affine_float_qparams.

torch.per_channel_symmetricvalueSame as PyTorch
per_channel_symmetric = riptorch.per_channel_symmetric

Same as PyTorch’s torch.per_channel_symmetric.

torch.per_tensor_affinevalueSame as PyTorch
per_tensor_affine = riptorch.per_tensor_affine

Same as PyTorch’s torch.per_tensor_affine.

torch.per_tensor_symmetricvalueSame as PyTorch
per_tensor_symmetric = riptorch.per_tensor_symmetric

Same as PyTorch’s torch.per_tensor_symmetric.

torch.pivalueSame as PyTorch
pi = 3.141592653589793

Same as PyTorch’s torch.pi.

torch.preserve_formatvalueSame as PyTorch
preserve_format = riptorch.preserve_format

Same as PyTorch’s torch.preserve_format.

torch.qint32valueSame as PyTorch
qint32 = riptorch.qint32

Same as PyTorch’s torch.qint32.

torch.qint8valueSame as PyTorch
qint8 = riptorch.qint8

Same as PyTorch’s torch.qint8.

torch.quint2x4valueSame as PyTorch
quint2x4 = riptorch.quint2x4

Same as PyTorch’s torch.quint2x4.

torch.quint4x2valueSame as PyTorch
quint4x2 = riptorch.quint4x2

Same as PyTorch’s torch.quint4x2.

torch.quint8valueSame as PyTorch
quint8 = riptorch.quint8

Same as PyTorch’s torch.quint8.

torch.shortvalueSame as PyTorch
short = riptorch.int16

Same as PyTorch’s torch.short.

torch.sparse_bscvalueSame as PyTorch
sparse_bsc = torch.sparse_bsc

Same as PyTorch’s torch.sparse_bsc.

torch.sparse_bsrvalueSame as PyTorch
sparse_bsr = torch.sparse_bsr

Same as PyTorch’s torch.sparse_bsr.

torch.sparse_coovalueSame as PyTorch
sparse_coo = torch.sparse_coo

Same as PyTorch’s torch.sparse_coo.

torch.sparse_cscvalueSame as PyTorch
sparse_csc = torch.sparse_csc

Same as PyTorch’s torch.sparse_csc.

torch.sparse_csrvalueSame as PyTorch
sparse_csr = torch.sparse_csr

Same as PyTorch’s torch.sparse_csr.

torch.stridedvalueSame as PyTorch
strided = torch.strided

Same as PyTorch’s torch.strided.

torch.uint16valueSame as PyTorch
uint16 = riptorch.uint16

Same as PyTorch’s torch.uint16.

torch.uint32valueSame as PyTorch
uint32 = riptorch.uint32

Same as PyTorch’s torch.uint32.

torch.uint64valueSame as PyTorch
uint64 = riptorch.uint64

Same as PyTorch’s torch.uint64.

torch.uint8valueSame as PyTorch
uint8 = riptorch.uint8

Same as PyTorch’s torch.uint8.

torch.WEIGHT_MAPSvalueRiptorch extra
WEIGHT_MAPS = ('exp', 'taylor2', 'cayley', 'square_linear', 'relu_square')

Riptorch extra: not in stock PyTorch.

In-place functions

torch.abs_functionSame as PyTorch
abs_(input, *a, **k)

input.abs_(...): abs in place on input; returns input.

torch.absolute_functionRiptorch extra
absolute_(input, *a, **k)

input.absolute_(...): absolute in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.acos_functionSame as PyTorch
acos_(input, *a, **k)

input.acos_(...): acos in place on input; returns input.

torch.acosh_functionSame as PyTorch
acosh_(input, *a, **k)

input.acosh_(...): acosh in place on input; returns input.

torch.addbmm_functionRiptorch extra
addbmm_(input, *a, **k)

input.addbmm_(...): addbmm in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.addcdiv_functionRiptorch extra
addcdiv_(input, *a, **k)

input.addcdiv_(...): addcdiv in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.addcmul_functionRiptorch extra
addcmul_(input, *a, **k)

input.addcmul_(...): addcmul in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.addmm_functionRiptorch extra
addmm_(input, *a, **k)

input.addmm_(...): addmm in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.addmv_functionSame as PyTorch
addmv_(input, *a, **k)

input.addmv_(...): addmv in place on input; returns input.

torch.addr_functionRiptorch extra
addr_(input, *a, **k)

input.addr_(...): addr in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.alpha_dropout_functionSame as PyTorch
alpha_dropout_(input, p, train)

In-place alpha_dropout.

torch.arccos_functionSame as PyTorch
arccos_(input, *a, **k)

input.arccos_(...): arccos in place on input; returns input.

torch.arccosh_functionSame as PyTorch
arccosh_(input, *a, **k)

input.arccosh_(...): arccosh in place on input; returns input.

torch.arcsin_functionSame as PyTorch
arcsin_(input, *a, **k)

input.arcsin_(...): arcsin in place on input; returns input.

torch.arcsinh_functionSame as PyTorch
arcsinh_(input, *a, **k)

input.arcsinh_(...): arcsinh in place on input; returns input.

torch.arctan2_functionRiptorch extra
arctan2_(input, *a, **k)

input.arctan2_(...): arctan2 in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.arctan_functionSame as PyTorch
arctan_(input, *a, **k)

input.arctan_(...): arctan in place on input; returns input.

torch.arctanh_functionSame as PyTorch
arctanh_(input, *a, **k)

input.arctanh_(...): arctanh in place on input; returns input.

torch.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).

torch.asin_functionSame as PyTorch
asin_(input, *a, **k)

input.asin_(...): asin in place on input; returns input.

torch.asinh_functionSame as PyTorch
asinh_(input, *a, **k)

input.asinh_(...): asinh in place on input; returns input.

torch.atan2_functionRiptorch extra
atan2_(input, *a, **k)

input.atan2_(...): atan2 in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.atan_functionSame as PyTorch
atan_(input, *a, **k)

input.atan_(...): atan in place on input; returns input.

torch.atanh_functionSame as PyTorch
atanh_(input, *a, **k)

input.atanh_(...): atanh in place on input; returns input.

torch.baddbmm_functionRiptorch extra
baddbmm_(input, *a, **k)

input.baddbmm_(...): baddbmm in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.bitwise_and_functionRiptorch extra
bitwise_and_(input, *a, **k)

input.bitwise_and_(...): bitwise_and in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.bitwise_left_shift_functionRiptorch extra
bitwise_left_shift_(input, *a, **k)

input.bitwise_left_shift_(...): bitwise_left_shift in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.bitwise_not_functionRiptorch extra
bitwise_not_(input, *a, **k)

input.bitwise_not_(...): bitwise_not in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.bitwise_or_functionRiptorch extra
bitwise_or_(input, *a, **k)

input.bitwise_or_(...): bitwise_or in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.bitwise_right_shift_functionRiptorch extra
bitwise_right_shift_(input, *a, **k)

input.bitwise_right_shift_(...): bitwise_right_shift in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.bitwise_xor_functionRiptorch extra
bitwise_xor_(input, *a, **k)

input.bitwise_xor_(...): bitwise_xor in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.ceil_functionSame as PyTorch
ceil_(input, *a, **k)

input.ceil_(...): ceil in place on input; returns input.

torch.celu_functionSame as PyTorch
celu_(input, alpha=1.0)

In-place CELU.

torch.clamp_functionSame as PyTorch
clamp_(input, *a, **k)

input.clamp_(...): clamp in place on input; returns input.

torch.clamp_max_functionSame as PyTorch
clamp_max_(input, *a, **k)

input.clamp_max_(...): clamp_max in place on input; returns input.

torch.clamp_min_functionSame as PyTorch
clamp_min_(input, *a, **k)

input.clamp_min_(...): clamp_min in place on input; returns input.

torch.clip_functionSame as PyTorch
clip_(input, *a, **k)

input.clip_(...): clip in place on input; returns input.

torch.conj_physical_functionSame as PyTorch
conj_physical_(input)

In-place conjugate; real tensors are returned unchanged.

torch.copysign_functionRiptorch extra
copysign_(input, *a, **k)

input.copysign_(...): copysign in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.cos_functionSame as PyTorch
cos_(input, *a, **k)

input.cos_(...): cos in place on input; returns input.

torch.cosh_functionSame as PyTorch
cosh_(input, *a, **k)

input.cosh_(...): cosh in place on input; returns input.

torch.deg2rad_functionSame as PyTorch
deg2rad_(input, *a, **k)

input.deg2rad_(...): deg2rad in place on input; returns input.

torch.detach_functionSame as PyTorch
detach_(input)

input.detach_.

torch.digamma_functionRiptorch extra
digamma_(input, *a, **k)

input.digamma_(...): digamma in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.divide_functionRiptorch extra
divide_(input, *a, **k)

input.divide_(...): divide in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.dropout_functionSame as PyTorch
dropout_(input, p, train)

In-place dropout.

torch.embedding_renorm_functionDifferent from PyTorch
embedding_renorm_(input, indices, max_norm, norm_type)

Different from PyTorch: correctly rounded rescaled rows; PyTorch's float32 arithmetic left 21374 of 160000 values off (200 random 50x16 weights)

PyTorch
the row norm and the rescaled row in the weight's dtype (float32): rescaled rows are up to an ulp off
Riptorch
norm and rescaling in float64, each value rounded once to the weight's dtype
Measured
200 random 50x16 float32 weights (std 3), 20 indices, max_norm 1: values off the correctly rounded result: PyTorch 21374 of 160000, Riptorch 0
Stock behaviour
torch.set_compat("pytorch")
torch.eq_functionRiptorch extra
eq_(input, *a, **k)

input.eq_(...): eq in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.erf_functionSame as PyTorch
erf_(input, *a, **k)

input.erf_(...): erf in place on input; returns input.

torch.erfc_functionSame as PyTorch
erfc_(input, *a, **k)

input.erfc_(...): erfc in place on input; returns input.

torch.erfinv_functionRiptorch extra
erfinv_(input, *a, **k)

input.erfinv_(...): erfinv in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.exp2_functionSame as PyTorch
exp2_(input, *a, **k)

input.exp2_(...): exp2 in place on input; returns input.

torch.exp_functionSame as PyTorch
exp_(input, *a, **k)

input.exp_(...): exp in place on input; returns input.

torch.expm1_functionSame as PyTorch
expm1_(input, *a, **k)

input.expm1_(...): expm1 in place on input; returns input.

torch.feature_alpha_dropout_functionSame as PyTorch
feature_alpha_dropout_(input, p, train)

In-place feature_alpha_dropout.

torch.feature_dropout_functionSame as PyTorch
feature_dropout_(input, p, train)

In-place feature_dropout.

torch.fill_functionSame as PyTorch
fill_(input, value)

Fills the tensor in place with value (a number or a 0-d tensor); returns it.

torch.fix_functionSame as PyTorch
fix_(input, *a, **k)

input.fix_(...): fix in place on input; returns input.

torch.float_power_functionRiptorch extra
float_power_(input, *a, **k)

input.float_power_(...): float_power in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.floor_functionSame as PyTorch
floor_(input, *a, **k)

input.floor_(...): floor in place on input; returns input.

torch.fmod_functionRiptorch extra
fmod_(input, *a, **k)

input.fmod_(...): fmod in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.frac_functionSame as PyTorch
frac_(input, *a, **k)

input.frac_(...): frac in place on input; returns input.

torch.gcd_functionSame as PyTorch
gcd_(input, *a, **k)

input.gcd_(...): gcd in place on input; returns input.

torch.ge_functionRiptorch extra
ge_(input, *a, **k)

input.ge_(...): ge in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.greater_functionRiptorch extra
greater_(input, *a, **k)

input.greater_(...): greater in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.greater_equal_functionRiptorch extra
greater_equal_(input, *a, **k)

input.greater_equal_(...): greater_equal in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.gt_functionRiptorch extra
gt_(input, *a, **k)

input.gt_(...): gt in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.heaviside_functionRiptorch extra
heaviside_(input, *a, **k)

input.heaviside_(...): heaviside in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.hypot_functionRiptorch extra
hypot_(input, *a, **k)

input.hypot_(...): hypot in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.i0_functionSame as PyTorch
i0_(input, *a, **k)

input.i0_(...): i0 in place on input; returns input.

torch.igamma_functionRiptorch extra
igamma_(input, *a, **k)

input.igamma_(...): igamma in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.igammac_functionRiptorch extra
igammac_(input, *a, **k)

input.igammac_(...): igammac in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.index_put_functionSame as PyTorch
index_put_(input, *a, **k)

input.index_put_(...): index_put in place on input; returns input.

torch.lcm_functionSame as PyTorch
lcm_(input, *a, **k)

input.lcm_(...): lcm in place on input; returns input.

torch.ldexp_functionSame as PyTorch
ldexp_(input, *a, **k)

input.ldexp_(...): ldexp in place on input; returns input.

torch.le_functionRiptorch extra
le_(input, *a, **k)

input.le_(...): le in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.lerp_functionRiptorch extra
lerp_(input, *a, **k)

input.lerp_(...): lerp in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.less_functionRiptorch extra
less_(input, *a, **k)

input.less_(...): less in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.less_equal_functionRiptorch extra
less_equal_(input, *a, **k)

input.less_equal_(...): less_equal in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.lgamma_functionRiptorch extra
lgamma_(input, *a, **k)

input.lgamma_(...): lgamma in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.log10_functionSame as PyTorch
log10_(input, *a, **k)

input.log10_(...): log10 in place on input; returns input.

torch.log1p_functionSame as PyTorch
log1p_(input, *a, **k)

input.log1p_(...): log1p in place on input; returns input.

torch.log2_functionSame as PyTorch
log2_(input, *a, **k)

input.log2_(...): log2 in place on input; returns input.

torch.log_functionSame as PyTorch
log_(input, *a, **k)

input.log_(...): log in place on input; returns input.

torch.logical_and_functionRiptorch extra
logical_and_(input, *a, **k)

input.logical_and_(...): logical_and in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.logical_not_functionRiptorch extra
logical_not_(input, *a, **k)

input.logical_not_(...): logical_not in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.logical_or_functionRiptorch extra
logical_or_(input, *a, **k)

input.logical_or_(...): logical_or in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.logical_xor_functionRiptorch extra
logical_xor_(input, *a, **k)

input.logical_xor_(...): logical_xor in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.logit_functionSame as PyTorch
logit_(input, *a, **k)

input.logit_(...): logit in place on input; returns input.

torch.lt_functionRiptorch extra
lt_(input, *a, **k)

input.lt_(...): lt in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.masked_scatter_functionRiptorch extra
masked_scatter_(input, *a, **k)

input.masked_scatter_(...): masked_scatter in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.multiply_functionRiptorch extra
multiply_(input, *a, **k)

input.multiply_(...): multiply in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.mvlgamma_functionRiptorch extra
mvlgamma_(input, *a, **k)

input.mvlgamma_(...): mvlgamma in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.nan_to_num_functionSame as PyTorch
nan_to_num_(input, *a, **k)

input.nan_to_num_(...): nan_to_num in place on input; returns input.

torch.ne_functionRiptorch extra
ne_(input, *a, **k)

input.ne_(...): ne in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.neg_functionSame as PyTorch
neg_(input, *a, **k)

input.neg_(...): neg in place on input; returns input.

torch.negative_functionSame as PyTorch
negative_(input, *a, **k)

input.negative_(...): negative in place on input; returns input.

torch.nextafter_functionRiptorch extra
nextafter_(input, *a, **k)

input.nextafter_(...): nextafter in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.not_equal_functionRiptorch extra
not_equal_(input, *a, **k)

input.not_equal_(...): not_equal in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.polygamma_functionRiptorch extra
polygamma_(input, *a, **k)

input.polygamma_(...): polygamma in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.pow_functionRiptorch extra
pow_(input, *a, **k)

input.pow_(...): pow in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.put_functionRiptorch extra
put_(input, *a, **k)

input.put_(...): put in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.rad2deg_functionSame as PyTorch
rad2deg_(input, *a, **k)

input.rad2deg_(...): rad2deg in place on input; returns input.

torch.reciprocal_functionSame as PyTorch
reciprocal_(input, *a, **k)

input.reciprocal_(...): reciprocal in place on input; returns input.

torch.relu_functionSame as PyTorch
relu_(*a, **k)

input.relu_(...): relu in place on input; returns input. A quantized input runs the quantized kernel (same parameters).

torch.remainder_functionRiptorch extra
remainder_(input, *a, **k)

input.remainder_(...): remainder in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.renorm_functionRiptorch extra
renorm_(input, *a, **k)

input.renorm_(...): renorm in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.resize_as_functionSame as PyTorch
resize_as_(input, the_template, *, memory_format=None)

Resizes in place to the template's shape (kept values in order, new ones zero).

torch.resize_as_sparse_functionSame as PyTorch
resize_as_sparse_(input, the_template)

input.resize_as_sparse_(the_template): input (sparse COO) takes the template's size, sparse_dim and dense_dim.

torch.round_functionSame as PyTorch
round_(input, *a, **k)

input.round_(...): round in place on input; returns input.

torch.rrelu_functionSame as PyTorch
rrelu_(input, lower=0.125, upper=0.3333333333333333, training=False, generator=None)

In-place rrelu.

torch.rsqrt_functionSame as PyTorch
rsqrt_(input, *a, **k)

input.rsqrt_(...): rsqrt in place on input; returns input.

torch.selu_functionSame as PyTorch
selu_(input)

In-place SELU.

torch.sgn_functionRiptorch extra
sgn_(input, *a, **k)

input.sgn_(...): sgn in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.sigmoid_functionSame as PyTorch
sigmoid_(input, *a, **k)

input.sigmoid_(...): sigmoid in place on input; returns input.

torch.sign_functionRiptorch extra
sign_(input, *a, **k)

input.sign_(...): sign in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.sin_functionSame as PyTorch
sin_(input, *a, **k)

input.sin_(...): sin in place on input; returns input.

torch.sinc_functionSame as PyTorch
sinc_(input, *a, **k)

input.sinc_(...): sinc in place on input; returns input.

torch.sinh_functionSame as PyTorch
sinh_(input, *a, **k)

input.sinh_(...): sinh in place on input; returns input.

torch.sqrt_functionSame as PyTorch
sqrt_(input, *a, **k)

input.sqrt_(...): sqrt in place on input; returns input.

torch.square_functionSame as PyTorch
square_(input, *a, **k)

input.square_(...): square in place on input; returns input.

torch.sub_functionRiptorch extra
sub_(input, *a, **k)

input.sub_(...): sub in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.subtract_functionRiptorch extra
subtract_(input, *a, **k)

input.subtract_(...): subtract in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.tan_functionSame as PyTorch
tan_(input, *a, **k)

input.tan_(...): tan in place on input; returns input.

torch.tanh_functionSame as PyTorch
tanh_(input, *a, **k)

input.tanh_(...): tanh in place on input; returns input.

torch.threshold_functionSame as PyTorch
threshold_(input, threshold, value)

In-place threshold: elements <= threshold become value.

torch.tril_functionRiptorch extra
tril_(input, *a, **k)

input.tril_(...): tril in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.triu_functionRiptorch extra
triu_(input, *a, **k)

input.triu_(...): triu in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.true_divide_functionRiptorch extra
true_divide_(input, *a, **k)

input.true_divide_(...): true_divide in place on input; returns input.

Riptorch extra: not in stock PyTorch.

torch.trunc_functionSame as PyTorch
trunc_(input, *a, **k)

input.trunc_(...): trunc in place on input; returns input.

torch.xlogy_functionSame as PyTorch
xlogy_(input, *a, **k)

input.xlogy_(...): xlogy in place on input; returns input.

torch.zero_functionSame as PyTorch
zero_(input)

input.zero_: input filled with zeros in place.

More functions

torch.adaptive_avg_pool1dfunctionSame as PyTorch
adaptive_avg_pool1d(input, output_size)

F.adaptive_avg_pool1d: averages over output_size equal-ish windows of the last dim (area interpolation).

torch.adaptive_max_pool1dfunctionSame as PyTorch
adaptive_max_pool1d(input, output_size)

Adaptive 1-d max pooling to output_size, always with the indices: (values, indices).

torch.affine_grid_generatorfunctionSame as PyTorch
affine_grid_generator(theta, size, align_corners)

F.affine_grid: the sampling grid of the affine maps theta for an output of shape size.

torch.alias_copyfunctionSame as PyTorch
alias_copy(x, *a, **k)

alias(...) as a new tensor (the view's copy: no memory shared with the input).

torch.as_strided_copyfunctionSame as PyTorch
as_strided_copy(input, size, stride, storage_offset=0)

as_strided(...) as a new tensor (the view's copy: no memory shared with the input).

torch.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.

torch.autocast_decrement_nestingfunctionSame as PyTorch
autocast_decrement_nesting()

Decrements autocast's nesting counter; returns the new depth.

torch.autocast_increment_nestingfunctionSame as PyTorch
autocast_increment_nesting()

Increments autocast's nesting counter; returns the new depth.

torch.avg_pool2dfunctionRiptorch extra
avg_pool2d(input, kernel_size, stride=None, padding=(0,), ceil_mode=False, count_include_pad=True, divisor_override=None)

A depthwise convolution with a constant kernel: sums over each window divided by its size, or (count_include_pad=False) by the number of real (unpadded) entries. 1-d runs as 2-d with height 1; adaptive_avg_pool1d is the area interpolation. ceil_mode=True raises NotImplementedError.

Riptorch extra: not in stock PyTorch.

torch.backendfunctionRiptorch extra
backend() -> str

Names the engine that runs large operations: the Metal GPU on a Mac with one (for example "riptide metal (Apple M1 Pro)"), otherwise "cpu".

torch.batch_norm_backward_elemtfunctionSame as PyTorch
batch_norm_backward_elemt(*a, **k)

CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel).

torch.batch_norm_backward_reducefunctionSame as PyTorch
batch_norm_backward_reduce(*a, **k)

CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel).

torch.batch_norm_elemtfunctionSame as PyTorch
batch_norm_elemt(*a, **k)

CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel).

torch.batch_norm_gather_statsfunctionSame as PyTorch
batch_norm_gather_stats(*a, **k)

CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel).

batch_norm_gather_stats_with_counts(*a, **k)

CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel).

torch.batch_norm_statsfunctionSame as PyTorch
batch_norm_stats(*a, **k)

CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel).

torch.batch_norm_update_statsfunctionSame as PyTorch
batch_norm_update_stats(input, running_mean, running_var, momentum)

(mean, unbiased var) of input per channel, running stats updated in place (CPU kernel in PyTorch).

torch.bilinearfunctionSame as PyTorch
bilinear(input1, input2, weight, bias=None)

x1^T A x2 + b per output feature: weight (out, in1, in2), bias (out,) or None.

binary_cross_entropy_with_logits(*args, **kw)

F.binary_cross_entropy_with_logits: binary cross entropy of sigmoid(input) computed stably from the logits; pos_weight weighs the positive term.

torch.ccol_indices_copyfunctionSame as PyTorch
ccol_indices_copy(x, *a, **k)

ccol_indices(...) as a new tensor (the view's copy: no memory shared with the input).

torch.choose_qparams_optimizedfunctionSame as PyTorch
choose_qparams_optimized(input, numel, n_bins, ratio, bit_width)

The [xmin, xmax] range (returned as (xmax, xmin)) that a greedy search shrinking it bin by bin finds with the least L2 quantization error at bit_width bits (embedding-bag row quantization).

torch.clamp_maxfunctionSame as PyTorch
clamp_max(input, max)

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

torch.clamp_minfunctionSame as PyTorch
clamp_min(input, min)

clamp(input, min=min).

torch.classpropertyfunctionSame as PyTorch
classproperty(func)

A read-only property of the class (and its instances).

torch.clear_autocast_cachefunctionSame as PyTorch
clear_autocast_cache()

Does nothing: Riptorch keeps no autocast weight cache.

torch.col_indices_copyfunctionSame as PyTorch
col_indices_copy(x, *a, **k)

col_indices(...) as a new tensor (the view's copy: no memory shared with the input).

torch.constant_pad_ndfunctionSame as PyTorch
constant_pad_nd(input, pad, value=0)

Pads with a constant: pad lists (before, after) pairs from the last dim backwards, as F.pad.

torch.conv_tbcfunctionSame as PyTorch
conv_tbc(input, weight, bias, pad=0)

Time x batch x channel convolution: input (T, B, Cin), weight (k, Cin, Cout), bias (Cout,).

torch.convolutionfunctionSame as PyTorch
convolution(input, weight, bias, stride, padding, dilation, transposed, output_padding, groups)

Convolution or transposed convolution of 1-3 spatial dims with every option given explicitly (the aten form behind F.conv*d and F.conv_transpose*d).

torch.cosine_embedding_lossfunctionSame as PyTorch
cosine_embedding_loss(input1, input2, target, margin=0.0, reduction=1)

F.cosine_embedding_loss with PyTorch's integer reduction (0 none, 1 mean, 2 sum).

torch.cross_similarityfunctionRiptorch extra
cross_similarity(x1, x2, dim=1, eps=1e-08) -> Tensor

The signed cross sign(u·v) (u·v)² / (Q(u) Q(v)): 1 − spread with the sign of u·v, in [−1, 1]. It is cos θ · |cos θ|, so it ranks pairs exactly as cosine similarity does, and it needs only dot products.

torch.crow_indices_copyfunctionSame as PyTorch
crow_indices_copy(x, *a, **k)

crow_indices(...) as a new tensor (the view's copy: no memory shared with the input).

torch.ctc_lossfunctionSame as PyTorch
ctc_loss(log_probs, targets, input_lengths, target_lengths, blank=0, reduction=1, zero_infinity=False)

Connectionist temporal classification loss with PyTorch's integer reduction (0 none, 1 mean, 2 sum).

torch.cudnn_affine_grid_generatorfunctionSame as PyTorch
cudnn_affine_grid_generator(input, *args, **kwargs)

torch.cudnn_affine_grid_generator: a cudnn kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.cudnn_batch_normfunctionSame as PyTorch
cudnn_batch_norm(input, *args, **kwargs)

torch.cudnn_batch_norm: a cudnn kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.cudnn_convolutionfunctionSame as PyTorch
cudnn_convolution(input, *args, **kwargs)

torch.cudnn_convolution: a cudnn kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.cudnn_convolution_add_relufunctionSame as PyTorch
cudnn_convolution_add_relu(input, *args, **kwargs)

torch.cudnn_convolution_add_relu: a cudnn kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.cudnn_convolution_relufunctionSame as PyTorch
cudnn_convolution_relu(input, *args, **kwargs)

torch.cudnn_convolution_relu: a cudnn kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.cudnn_convolution_transposefunctionSame as PyTorch
cudnn_convolution_transpose(input, *args, **kwargs)

torch.cudnn_convolution_transpose: a cudnn kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.cudnn_grid_samplerfunctionSame as PyTorch
cudnn_grid_sampler(input, *args, **kwargs)

torch.cudnn_grid_sampler: a cudnn kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.cudnn_is_acceptablefunctionSame as PyTorch
cudnn_is_acceptable(input)

False for every tensor (no cuDNN on a Mac); TypeError for a non-tensor, as PyTorch.

torch.detachfunctionSame as PyTorch
detach(input)

input.detach: the same values, no longer recording gradients.

torch.detach_copyfunctionSame as PyTorch
detach_copy(input)

detach(...) as a new tensor (the view's copy: no memory shared with the input).

torch.diagonal_copyfunctionSame as PyTorch
diagonal_copy(input, offset=0, dim1=0, dim2=1)

diagonal(...) as a new tensor (the view's copy: no memory shared with the input).

torch.dsmmfunctionSame as PyTorch
dsmm(input, mat2)

torch.spmm: sparse @ dense -> dense.

torch.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.)

torch.empty_permutedfunctionSame as PyTorch
empty_permuted(size, physical_layout, *, dtype=None, **kw)

A zero-filled tensor of size; physical_layout is ignored (contiguous layout).

torch.empty_quantizedfunctionSame as PyTorch
empty_quantized(size, qtensor, *, dtype=None, layout=None, device=None, pin_memory=None, memory_format=None)

A quantized tensor of the given size with qtensor's parameters (its values: the zero point, a defined 'empty').

torch.expand_copyfunctionSame as PyTorch
expand_copy(x, *a, **k)

expand(...) as a new tensor (the view's copy: no memory shared with the input).

torch.fbgemm_linear_fp16_weightfunctionSame as PyTorch
fbgemm_linear_fp16_weight(*a, **k)

FBGEMM fp16-weight linear: raises as PyTorch on arm64 (no FBGEMM).

fbgemm_linear_fp16_weight_fp32_activation(*a, **k)

FBGEMM fp16-weight linear: raises as PyTorch on arm64 (no FBGEMM).

torch.fbgemm_linear_int8_weightfunctionSame as PyTorch
fbgemm_linear_int8_weight(*a, **k)

FBGEMM fp16-weight linear: raises as PyTorch on arm64 (no FBGEMM).

fbgemm_linear_int8_weight_fp32_activation(*a, **k)

FBGEMM fp16-weight linear: raises as PyTorch on arm64 (no FBGEMM).

fbgemm_linear_quantize_weight(*a, **k)

FBGEMM fp16-weight linear: raises as PyTorch on arm64 (no FBGEMM).

torch.fbgemm_pack_gemm_matrix_fp16functionSame as PyTorch
fbgemm_pack_gemm_matrix_fp16(*a, **k)

FBGEMM fp16-weight linear: raises as PyTorch on arm64 (no FBGEMM).

torch.fbgemm_pack_quantized_matrixfunctionSame as PyTorch
fbgemm_pack_quantized_matrix(*a, **k)

FBGEMM fp16-weight linear: raises as PyTorch on arm64 (no FBGEMM).

torch.fillfunctionSame as PyTorch
fill(input, value)

A tensor like input filled with value (a number or a one-element tensor).

torch.forkfunctionSame as PyTorch
fork(fn, *a, **k)

Runs fn(*args, **kwargs) at once and returns a completed Future with its result or exception (PyTorch may run it on another thread; Riptorch runs it inline).

torch.frobenius_normfunctionSame as PyTorch
frobenius_norm(input, dim, keepdim=False)

Deprecated in PyTorch (its warning, once): the 2-norm over dim, as linalg.vector_norm.

fused_moving_avg_obs_fake_quant(input, observer_on, fake_quant_on, running_min, running_max, scale, zero_point, averaging_const, quant_min, quant_max, ch_axis, per_row_fake_quant=False, symmetric_quant=False)

Observe input (moving-average min / max, updating running_min / running_max, scale and zero_point in place) then fake-quantize it, as FusedMovingAvgObsFakeQuantize's forward does.

torch.get_autocast_cpu_dtypefunctionSame as PyTorch
get_autocast_cpu_dtype()

Deprecated (DeprecationWarning, as PyTorch): get_autocast_dtype('cpu').

torch.get_autocast_gpu_dtypefunctionSame as PyTorch
get_autocast_gpu_dtype()

Deprecated (DeprecationWarning, as PyTorch): get_autocast_dtype('cuda').

torch.get_autocast_ipu_dtypefunctionSame as PyTorch
get_autocast_ipu_dtype()

Deprecated (DeprecationWarning, as PyTorch): get_autocast_dtype('ipu').

torch.get_autocast_xla_dtypefunctionSame as PyTorch
get_autocast_xla_dtype()

Deprecated (DeprecationWarning, as PyTorch): get_autocast_dtype('xla').

torch.get_compatfunctionRiptorch extra
get_compat() -> str

"riptorch" (the correct-by-default behaviour) or "pytorch" (stock behaviour), as set_compat set it.

torch.get_devicefunctionSame as PyTorch
get_device(x)

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

torch.get_file_pathfunctionSame as PyTorch
get_file_path(*path_components)

A path inside the installed package.

torch.get_float64functionRiptorch extra
get_float64() -> str

Where float64 graphs run now: "auto", "gpu", "cpu" or "fast".

torch.get_int_matmulfunctionRiptorch extra
get_int_matmul() -> str

Where exact integer matmuls run: "auto" (default), "gpu" or "cpu".

torch.get_mathsfunctionRiptorch extra
get_maths() -> str

The model maths set_maths chose: "transcendental" (the default) or "rational".

torch.get_matmulfunctionRiptorch extra
get_matmul() -> str

The precision set_matmul chose: "fp32" (default), "bf16", "fp16", "exact", "fast" or "high".

torch.grid_samplerfunctionSame as PyTorch
grid_sampler(input, grid, interpolation_mode, padding_mode, align_corners)

F.grid_sample with integer modes: interpolation 0 bilinear, 1 nearest, 2 bicubic; padding 0 zeros, 1 border, 2 reflection. Also torch.grid_sampler_2d / grid_sampler_3d.

torch.grid_sampler_2dfunctionSame as PyTorch
grid_sampler_2d(input, grid, interpolation_mode, padding_mode, align_corners)

F.grid_sample with integer modes: interpolation 0 bilinear, 1 nearest, 2 bicubic; padding 0 zeros, 1 border, 2 reflection. Also torch.grid_sampler_2d / grid_sampler_3d.

torch.grid_sampler_3dfunctionSame as PyTorch
grid_sampler_3d(input, grid, interpolation_mode, padding_mode, align_corners)

F.grid_sample with integer modes: interpolation 0 bilinear, 1 nearest, 2 bicubic; padding 0 zeros, 1 border, 2 reflection. Also torch.grid_sampler_2d / grid_sampler_3d.

torch.grufunctionSame as PyTorch
gru(*args)

Multi-layer gru over a padded sequence (input, hx, params, has_biases, num_layers, dropout, train, bidirectional, batch_first) or packed data (data, batch_sizes, hx, params,...); params per layer and direction: w_ih, w_hh[, b_ih, b_hh][, w_hr]. Returns (output, h_n).

torch.gru_cellfunctionSame as PyTorch
gru_cell(input, hx, w_ih, w_hh, b_ih=None, b_hh=None)

One GRU step; gates in the order reset, update, new. Returns h'.

torch.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.

torch.hinge_embedding_lossfunctionSame as PyTorch
hinge_embedding_loss(input, target, margin=1.0, reduction=1)

F.hinge_embedding_loss with PyTorch's integer reduction (0 none, 1 mean, 2 sum).

torch.hsmmfunctionSame as PyTorch
hsmm(mat1, mat2)

torch.hsmm: hspmm (sparse @ dense as a hybrid COO tensor).

torch.hspmmfunctionSame as PyTorch
hspmm(mat1, mat2)

Same as PyTorch’s torch.hspmm.

torch.import_ir_modulefunctionSame as PyTorch
import_ir_module(cu, filename, map_location, extra_files, restore_shapes=False)

Raises RuntimeError: TorchScript archives need the TorchScript interpreter (torch.load reads state_dicts).

torch.import_ir_module_from_bufferfunctionSame as PyTorch
import_ir_module_from_buffer(cu, buffer, map_location, extra_files, restore_shapes=False)

Raises RuntimeError: TorchScript archives need the TorchScript interpreter (torch.load reads state_dicts).

torch.improvementsfunctionRiptorch extra
improvements(name=None, vs=None) -> list | dict | None

Every function whose Riptorch default differs from stock PyTorch's because PyTorch's result is wrong or degraded, each as a dict with the measurement behind it: name, area, headline, stock (what PyTorch does), riptorch (what Riptorch does), measured, and compat (how to get PyTorch's behaviour back).

improvements("index_add") returns one entry (or None when the function behaves as stock); vs="pytorch" or vs="mlx" keeps the entries measured against that library.

torch.indices_copyfunctionSame as PyTorch
indices_copy(x, *a, **k)

indices(...) as a new tensor (the view's copy: no memory shared with the input).

torch.init_num_threadsfunctionSame as PyTorch
init_num_threads()

Nothing to do: Riptorch's thread pools start on their own.

torch.int_reprfunctionSame as PyTorch
int_repr(input)

The stored integers of a quantized tensor.

torch.interpreter_statsfunctionRiptorch extra
interpreter_stats() -> tuple

(graphs, seconds): how many graphs the CPU reference interpreter ran in this process and the time spent there (normally 0).

torch.is_anomaly_check_nan_enabledfunctionSame as PyTorch
is_anomaly_check_nan_enabled()

False: anomaly detection is not tracked.

torch.is_anomaly_enabledfunctionSame as PyTorch
is_anomaly_enabled()

False: anomaly detection is not tracked.

torch.is_autocast_cache_enabledfunctionSame as PyTorch
is_autocast_cache_enabled()

The flag set_autocast_cache_enabled set (True by default).

torch.is_autocast_cpu_enabledfunctionSame as PyTorch
is_autocast_cpu_enabled()

Whether autocast is on for the CPU.

torch.is_autocast_ipu_enabledfunctionSame as PyTorch
is_autocast_ipu_enabled()

Deprecated (DeprecationWarning, as PyTorch): is_autocast_enabled('ipu').

torch.is_autocast_xla_enabledfunctionSame as PyTorch
is_autocast_xla_enabled()

Deprecated (DeprecationWarning, as PyTorch): is_autocast_enabled('xla').

torch.is_distributedfunctionSame as PyTorch
is_distributed(x)

False: no tensor is distributed across processes.

torch.is_inferencefunctionSame as PyTorch
is_inference(x)

False: Riptorch has no inference tensors (inference_mode is no_grad).

torch.is_same_sizefunctionSame as PyTorch
is_same_size(a, b)

Whether a and b have the same shape.

torch.is_signedfunctionSame as PyTorch
is_signed(x)

Whether x's dtype holds negative values (floats and signed integers).

torch.is_torch_aliasfunctionRiptorch extra
is_torch_alias() -> bool

True when import torch in this process gives Riptorch (Riptorch was imported first and registered itself under that name).

torch.is_vulkan_availablefunctionSame as PyTorch
is_vulkan_available()

False: no Vulkan backend (as PyTorch does on a Mac).

torch.kl_divfunctionSame as PyTorch
kl_div(*args, **kw)

F.kl_div: target * (log target - input) with input as log-probabilities (log_target for log-space targets); reduction 'batchmean' divides the sum by the batch size.

torch.lstmfunctionSame as PyTorch
lstm(*args)

Multi-layer lstm over a padded sequence (input, hx, params, has_biases, num_layers, dropout, train, bidirectional, batch_first) or packed data (data, batch_sizes, hx, params,...); params per layer and direction: w_ih, w_hh[, b_ih, b_hh][, w_hr]. Returns (output, h_n, c_n).

torch.lstm_cellfunctionSame as PyTorch
lstm_cell(input, hx, w_ih, w_hh, b_ih=None, b_hh=None)

One LSTM step: hx = (h, c); gates in the order input, forget, cell, output. Returns (h', c').

torch.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.)

torch.margin_ranking_lossfunctionSame as PyTorch
margin_ranking_loss(*args, **kw)

F.margin_ranking_loss: max(0, -target * (input1 - input2) + margin), reduced.

torch.maths_configfunctionRiptorch extra
maths_config() -> dict

The current set_maths settings as a dict.

torch.maths_statsfunctionRiptorch extra
maths_stats()

A lazy tensor [clamped above, clamped below, entries, largest entry] over every Cayley map built since maths_stats_reset; a compiled step can return it.

Riptorch extra: not in stock PyTorch.

torch.maths_stats_resetfunctionRiptorch extra
maths_stats_reset()

Forgets the Cayley clamp statistics recorded so far (call at the start of a step).

Riptorch extra: not in stock PyTorch.

torch.matrix_rankfunctionSame as PyTorch
matrix_rank(input, tol=None, symmetric=False, *, out=None) -> torch.Tensor

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

torch.matrix_unitfunctionRiptorch extra
matrix_unit() -> str

The CPU matrix unit Riptorch's CPU matrix multiplies run on: "SME" on Apple M4 and later, "AMX" on M1 to M3, "none" elsewhere (the portable kernels).

torch.matrix_unit_modesfunctionRiptorch extra
matrix_unit_modes() -> list[str]

The matrix-multiply input and output types this CPU runs on its matrix unit, using all cores, for example "s8s8_i32" (int8 × int8 → int32), "s16s16_i64", "f16_f32" or "bf16_f32".

torch.matrix_unit_statusfunctionRiptorch extra
matrix_unit_status() -> dict

The matrix unit, its modes and whether its library loaded, as one dict (for bug reports).

torch.max_pool1d_with_indicesfunctionSame as PyTorch
max_pool1d_with_indices(input, kernel_size, stride=(), padding=0, dilation=1, ceil_mode=False)

1-d max pooling with the argmax indices: (values, indices).

torch.merge_type_from_type_commentfunctionSame as PyTorch
merge_type_from_type_comment(decl, type_annotation_decl, is_method)

A declaration with the type comment's types applied to its parameters (self skipped for methods).

torch.miopen_batch_normfunctionSame as PyTorch
miopen_batch_norm(input, *args, **kwargs)

torch.miopen_batch_norm: a miopen kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.miopen_convolutionfunctionSame as PyTorch
miopen_convolution(input, *args, **kwargs)

torch.miopen_convolution: a miopen kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.miopen_convolution_add_relufunctionSame as PyTorch
miopen_convolution_add_relu(input, *args, **kwargs)

torch.miopen_convolution_add_relu: a miopen kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.miopen_convolution_relufunctionSame as PyTorch
miopen_convolution_relu(input, *args, **kwargs)

torch.miopen_convolution_relu: a miopen kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.miopen_convolution_transposefunctionSame as PyTorch
miopen_convolution_transpose(input, *args, **kwargs)

torch.miopen_convolution_transpose: a miopen kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.miopen_ctc_lossfunctionSame as PyTorch
miopen_ctc_loss(input, *args, **kwargs)

torch.miopen_ctc_loss: a miopen kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.miopen_depthwise_convolutionfunctionSame as PyTorch
miopen_depthwise_convolution(input, *args, **kwargs)

torch.miopen_depthwise_convolution: a miopen kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.miopen_rnnfunctionSame as PyTorch
miopen_rnn(input, *args, **kwargs)

torch.miopen_rnn: a miopen kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.mkldnn_adaptive_avg_pool2dfunctionSame as PyTorch
mkldnn_adaptive_avg_pool2d(input, *args, **kwargs)

torch.mkldnn_adaptive_avg_pool2d: a mkldnn kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.mkldnn_convolutionfunctionSame as PyTorch
mkldnn_convolution(input, *args, **kwargs)

torch.mkldnn_convolution: a mkldnn kernel PyTorch on a Mac does not have (raises as PyTorch).

mkldnn_linear_backward_weights(input, *args, **kwargs)

torch.mkldnn_linear_backward_weights: a mkldnn kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.mkldnn_max_pool2dfunctionSame as PyTorch
mkldnn_max_pool2d(input, *args, **kwargs)

torch.mkldnn_max_pool2d: a mkldnn kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.mkldnn_max_pool3dfunctionSame as PyTorch
mkldnn_max_pool3d(input, *args, **kwargs)

torch.mkldnn_max_pool3d: a mkldnn kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.mkldnn_rnn_layerfunctionSame as PyTorch
mkldnn_rnn_layer(input, *args, **kwargs)

torch.mkldnn_rnn_layer: a mkldnn kernel PyTorch on a Mac does not have (raises as PyTorch).

torch.native_batch_normfunctionSame as PyTorch
native_batch_norm(input, weight, bias, running_mean, running_var, training, momentum, eps)

(output, save_mean, save_invstd). Training: batch statistics, running_mean / running_var updated in place (unbiased variance); eval: the running statistics, and empty save tensors (as PyTorch).

torch.native_channel_shufflefunctionSame as PyTorch
native_channel_shuffle(input, groups)

Shuffles the channels (dim 1) across groups: (N, g*k,...) read as (N, g, k,...) and transposed.

torch.native_dropoutfunctionSame as PyTorch
native_dropout(input, p, train)

(output, mask): dropout with its keep mask (bool). train=False returns a copy and an all-True mask.

torch.native_group_normfunctionSame as PyTorch
native_group_norm(input, weight, bias, N, C, HxW, group, eps)

(output, mean, rstd) of group norm on input viewed as (N, group, C // group * HxW); mean and rstd have shape (N, group).

torch.native_layer_normfunctionSame as PyTorch
native_layer_norm(input, normalized_shape, weight, bias, eps)

(output, mean, rstd) over the last len(normalized_shape) dims; mean and rstd keep those dims as 1.

torch.native_normfunctionSame as PyTorch
native_norm(*a, **k)

CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel).

torch.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).

torch.norm_except_dimfunctionSame as PyTorch
norm_except_dim(v, pow=2, dim=0)

p-norm over every dim but dim (keepdim shape); dim=-1: the norm of the whole tensor.

torch.normalized_mapfunctionRiptorch extra
normalized_map(x, kind)

p_i = w(x_i) / sum_j w(x_j) over the last dim, nothing recentered or tempered.

Riptorch extra: not in stock PyTorch.

torch.nuclear_normfunctionSame as PyTorch
nuclear_norm(input, dim=None, keepdim=False)

Deprecated in PyTorch (its warning, once): sum of singular values over the last two dims (or dim).

torch.parse_irfunctionSame as PyTorch
parse_ir(input, parse_tensor_constants=False)

A Graph from TorchScript's IR text form (graph inputs keep their names; node outputs are numbered).

torch.parse_schemafunctionSame as PyTorch
parse_schema(schema, allow_typevars=True)

FunctionSchema from text: ns::name.overload(Type name=default, *,...) -> ret.

torch.parse_type_commentfunctionSame as PyTorch
parse_type_comment(comment)

'# type: (int, float) -> int' as a declaration (argument and return types, as text).

torch.permute_copyfunctionSame as PyTorch
permute_copy(input, *dims)

permute(...) as a new tensor (the view's copy: no memory shared with the input).

torch.poisson_nll_lossfunctionSame as PyTorch
poisson_nll_loss(input, target, log_input, full, eps, reduction)

F.poisson_nll_loss with PyTorch's positional arguments and integer reduction (0 none, 1 mean, 2 sum).

prepare_multiprocessing_environment(path)

No-op (PyTorch sets up shared-memory file handling for worker processes; Riptorch shares no storage).

profiler_allow_cudagraph_cupti_lazy_reinit_cuda12()

True, as PyTorch on this platform.

torch.program_statsfunctionRiptorch extra
program_stats() -> tuple

Counts for the last program that ran (its steps) and how many graphs ran so far: a diagnostic for performance reports.

torch.q_per_channel_axisfunctionSame as PyTorch
q_per_channel_axis(input)

The per-channel axis of a quantized tensor.

torch.q_per_channel_scalesfunctionSame as PyTorch
q_per_channel_scales(input)

The per-channel scales of a quantized tensor.

torch.q_per_channel_zero_pointsfunctionSame as PyTorch
q_per_channel_zero_points(input)

The per-channel zero points of a quantized tensor.

torch.q_scalefunctionSame as PyTorch
q_scale(input)

The scale of a per-tensor quantized tensor.

torch.q_zero_pointfunctionSame as PyTorch
q_zero_point(input)

The zero point of a per-tensor quantized tensor.

torch.quantize_per_tensor_dynamicfunctionSame as PyTorch
quantize_per_tensor_dynamic(input, dtype, reduce_range)

Quantize with a scale / zero point chosen from the tensor's own range (as a dynamic observer would).

torch.quantized_grufunctionSame as PyTorch
quantized_gru(input, hx, params, *a, **k)

Legacy quantized GRU over FBGEMM-packed weights: raises as PyTorch on arm64 (no FBGEMM).

torch.quantized_gru_cellfunctionSame as PyTorch
quantized_gru_cell(*a, **k)

Legacy FBGEMM quantized GRU cell: raises as PyTorch on arm64 (no FBGEMM).

torch.quantized_lstmfunctionSame as PyTorch
quantized_lstm(input, hx, params, *a, **k)

Legacy quantized GRU over FBGEMM-packed weights: raises as PyTorch on arm64 (no FBGEMM).

torch.quantized_lstm_cellfunctionSame as PyTorch
quantized_lstm_cell(*a, **k)

Legacy FBGEMM quantized GRU cell: raises as PyTorch on arm64 (no FBGEMM).

torch.quantized_max_pool3dfunctionSame as PyTorch
quantized_max_pool3d(input, kernel_size, stride=(), padding=0, dilation=1, ceil_mode=False)

3-d max pooling of a quantized tensor, on its integers (exact; the same parameters).

torch.quantized_rnn_relu_cellfunctionSame as PyTorch
quantized_rnn_relu_cell(*a, **k)

Legacy FBGEMM quantized GRU cell: raises as PyTorch on arm64 (no FBGEMM).

torch.quantized_rnn_tanh_cellfunctionSame as PyTorch
quantized_rnn_tanh_cell(*a, **k)

Legacy FBGEMM quantized GRU cell: raises as PyTorch on arm64 (no FBGEMM).

torch.realizer_reportfunctionRiptorch extra
realizer_report() -> str

Where this process's work ran: how many GPU programs and CPU programs, and for each graph that did not run on the GPU, why (for example a small graph where a GPU round trip costs more, or float64). Use it to check that a model runs where you expect after switching.

torch.rms_normfunctionSame as PyTorch
rms_norm(input, normalized_shape, weight=None, eps=None, *, maths=None)

x / sqrt(mean(x^2 over the normalized dims) + eps) * weight; eps defaults to float32's machine epsilon. The rational maths divides by the mean quadrance instead: x / (1 + mean(x^2)).

torch.rnn_relufunctionSame as PyTorch
rnn_relu(*args)

Multi-layer rnn_relu over a padded sequence (input, hx, params, has_biases, num_layers, dropout, train, bidirectional, batch_first) or packed data (data, batch_sizes, hx, params,...); params per layer and direction: w_ih, w_hh[, b_ih, b_hh][, w_hr]. Returns (output, h_n).

torch.rnn_relu_cellfunctionSame as PyTorch
rnn_relu_cell(input, hx, w_ih, w_hh, b_ih=None, b_hh=None)

One Elman RNN step with ReLU: relu(x W_ih^T + b_ih + h W_hh^T + b_hh).

torch.rnn_tanhfunctionSame as PyTorch
rnn_tanh(*args)

Multi-layer rnn_tanh over a padded sequence (input, hx, params, has_biases, num_layers, dropout, train, bidirectional, batch_first) or packed data (data, batch_sizes, hx, params,...); params per layer and direction: w_ih, w_hh[, b_ih, b_hh][, w_hr]. Returns (output, h_n).

torch.rnn_tanh_cellfunctionSame as PyTorch
rnn_tanh_cell(input, hx, w_ih, w_hh, b_ih=None, b_hh=None)

One Elman RNN step: tanh(x W_ih^T + b_ih + h W_hh^T + b_hh).

torch.row_indices_copyfunctionSame as PyTorch
row_indices_copy(x, *a, **k)

row_indices(...) as a new tensor (the view's copy: no memory shared with the input).

torch.rsubfunctionSame as PyTorch
rsub(input, other, *, alpha=1)

other - alpha * input (subtraction with the arguments reversed).

torch.saddmmfunctionSame as PyTorch
saddmm(input, mat1, mat2, *, beta=1, alpha=1, out=None)

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

torch.select_copyfunctionSame as PyTorch
select_copy(*a, **k)

select(...) as a new tensor (the view's copy: no memory shared with the input).

torch.set_anomaly_enabledfunctionSame as PyTorch
set_anomaly_enabled(enabled, check_nan=True)

Accepted and ignored: anomaly detection is not tracked.

torch.set_autocast_cache_enabledfunctionSame as PyTorch
set_autocast_cache_enabled(enabled)

Records whether autocast caches casts (Riptorch's autocast has no cast cache; the flag is kept).

torch.set_autocast_cpu_dtypefunctionSame as PyTorch
set_autocast_cpu_dtype(dtype)

Deprecated (DeprecationWarning, as PyTorch): set_autocast_dtype('cpu', dtype).

torch.set_autocast_cpu_enabledfunctionSame as PyTorch
set_autocast_cpu_enabled(enabled)

Deprecated (DeprecationWarning, as PyTorch): set_autocast_enabled('cpu', enabled).

torch.set_autocast_dtypefunctionSame as PyTorch
set_autocast_dtype(device_type, dtype)

Sets the dtype autocast uses on device_type.

torch.set_autocast_gpu_dtypefunctionSame as PyTorch
set_autocast_gpu_dtype(dtype)

Deprecated (DeprecationWarning, as PyTorch): set_autocast_dtype('cuda', dtype).

torch.set_autocast_ipu_dtypefunctionSame as PyTorch
set_autocast_ipu_dtype(dtype)

Deprecated (DeprecationWarning, as PyTorch): set_autocast_dtype('ipu', dtype).

torch.set_autocast_ipu_enabledfunctionSame as PyTorch
set_autocast_ipu_enabled(enabled)

Deprecated (DeprecationWarning, as PyTorch): set_autocast_enabled('ipu', enabled).

torch.set_autocast_xla_dtypefunctionSame as PyTorch
set_autocast_xla_dtype(dtype)

Deprecated (DeprecationWarning, as PyTorch): set_autocast_dtype('xla', dtype).

torch.set_autocast_xla_enabledfunctionSame as PyTorch
set_autocast_xla_enabled(enabled)

Deprecated (DeprecationWarning, as PyTorch): set_autocast_enabled('xla', enabled).

torch.set_compatfunctionRiptorch extra
set_compat(mode)

Riptorch's results are correct by default: int8 @ int8 gives exact int32, int16 @ int16 exact int64, int32 and int64 products exact int64, and the other measured improvements listed by torch.improvements().

set_compat("pytorch") (or RIPTORCH_COMPAT=pytorch before import) gives stock PyTorch's behaviour instead: integer products keep the input dtype and wrap modulo 2^bits, int8 @ uint8 raises, float64 runs on the CPU. set_compat("riptorch") returns to the default.

torch.set_float64functionRiptorch extra
set_float64(mode=None, min_work=None)

Where float64 work runs on a Mac with an Apple GPU (which has no float64 hardware):

  • "auto" (default): IEEE float64 on the CPU, unless every operation in a graph is as precise on the GPU.
  • "fast": the GPU wherever it is measured faster, using double-float arithmetic (two float32 values per number, about 48 significant bits).
  • "gpu": the GPU whenever the graph can run there.
  • "cpu": IEEE float64 on the CPU (PyTorch's behaviour; set_compat("pytorch") also gives it).

min_work is the smallest graph sent to the GPU. A value outside 2⁻⁷⁴ … 2¹⁰⁰ reruns the graph on the CPU in every mode. RIPTORCH_FLOAT64 and RIPTORCH_FLOAT64_MIN_WORK set them at import.

torch.set_int_matmulfunctionRiptorch extra
set_int_matmul(device)

Where exact integer matrix multiplies (int8, uint8, int16 and uint16, in any same-width pair) run:

  • "auto" (default): the GPU's int8 matrix hardware for large products (from 2²⁴ multiply-adds for 8-bit inputs and 2²⁵ for 16-bit), the CPU's matrix unit below that.
  • "gpu" or "cpu": always that side.

The results are the same exact integers either way. RIPTORCH_INT_MATMUL sets it at import.

torch.set_mathsfunctionRiptorch extra
set_maths(mode=None, *, weight=None, attention=None, loss=None, recenter=None, temperature=None, cayley_eps=None)

Chooses the model maths for experiments. "classic" (default, also called "transcendental") is PyTorch's: the exponential softmax, cross-entropy, layer norm, GELU, tanh, sigmoid, Adam and norm clipping.

"rational" keeps every map to order 2 or below: second-order softmax weightings, the Brier score, spread norm, ReLU², softsign, Lion and quadrance clipping. The keyword arguments set one piece at a time: weight (the softmax's weighting map: "exp", "taylor2", "cayley", "square_linear" or "relu_square"), attention, loss ("cross_entropy", "brier" or "spherical"), recenter, temperature and cayley_eps.

Set it before building a model's training step. RIPTORCH_MATHS=rational sets it at import.

torch.set_matmulfunctionRiptorch extra
set_matmul(precision)

Sets how floating-point matrix multiplies are computed (matmul, linear, convolutions and the attention backward):

  • "fp32" (default): float32 inputs and float32 accumulation on the fastest hardware, with fused multiply-adds.
  • "bf16" or "fp16": mixed precision. Each multiply rounds its inputs to 16 bits and accumulates in float32; weights, gradients and optimizer state stay float32.
  • "exact": the unfused reference order (multiply, then add, in a fixed order), so results are the same bits run to run.
  • On the Apple GPU, also "fast" (scaled half-precision multiplies that never overflow) and "high" (about twice float32's accuracy at about float32's speed).

RIPTORCH_MATMUL sets it at import. Compiled programs are cached per precision, so you can change it between training steps. See Matmul precision and speed settings.

torch.similarity_topkfunctionRiptorch extra
similarity_topk(queries, keys, k, metric="cosine", exact=False, eps=1e-08) -> (values, indices)

For each query ([D] or [B, D]), the k rows of keys ([N, D]) most similar to it, scored and selected in one pass, so the [B, N] score matrix is never stored.

metric is "cosine", "cross" (the signed cross, sign(q·x) (q·x)² / (Q(q) Q(x)) with Q(x) = x·x: the same ranking as cosine), "spread" (1 − (q·x)² / (Q(q) Q(x)), smallest first) or "dot".

With exact=True the vectors must hold whole numbers (int8 or int16 tensors, or float32 tensors holding whole numbers in that range). The dot products are computed in integers and the ranking is decided by comparing exact fractions, so the result is exact: the same top-k on every CPU and GPU, at every batch size. Ties go to the lowest index. The returned values are recomputed in float64 from the vectors.

Returns (values, indices), like torch.topk. See the guide Exact vector search for RAG.

torch.slice_copyfunctionSame as PyTorch
slice_copy(x, dim=0, start=None, end=None, step=1)

slice(...) as a new tensor (the view's copy: no memory shared with the input).

torch.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.

torch.smmfunctionSame as PyTorch
smm(input, mat2)

Same as PyTorch’s torch.smm.

torch.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.)

torch.split_copyfunctionSame as PyTorch
split_copy(*a, **k)

split(...) as a new tensor (the view's copy: no memory shared with the input).

torch.split_with_sizes_copyfunctionSame as PyTorch
split_with_sizes_copy(input, split_sizes, dim=0)

split_with_sizes(...) as a new tensor (the view's copy: no memory shared with the input).

torch.spmmfunctionSame as PyTorch
spmm(input, mat2)

torch.spmm: sparse @ dense -> dense.

torch.spreadfunctionRiptorch extra
spread(x1, x2, dim=1, eps=1e-08) -> Tensor

The spread between vectors along dim: 1 − (u·v)² / (Q(u) Q(v)), where Q(u) = u·u: 0 for parallel vectors (pointing the same way or opposite ways), 1 for perpendicular ones. Computed from dot products alone, so whole-number inputs give an exact fraction.

torch.squeeze_copyfunctionSame as PyTorch
squeeze_copy(*a, **k)

squeeze(...) as a new tensor (the view's copy: no memory shared with the input).

torch.sspaddmmfunctionSame as PyTorch
sspaddmm(input, mat1, mat2, *, beta=1, alpha=1, out=None)

entries in every column of the rows mat1 has entries in (uncoalesced, as PyTorch).

torch.sym_constrain_rangefunctionSame as PyTorch
sym_constrain_range(size, *, min=None, max=None)

No-op on concrete sizes (PyTorch's runtime check only applies to symbolic ones).

torch.sym_constrain_range_for_sizefunctionSame as PyTorch
sym_constrain_range_for_size(size, *, min=None, max=None)

No-op on concrete sizes (PyTorch's runtime check only applies to symbolic ones).

torch.sym_floatfunctionSame as PyTorch
sym_float(a)

float of a concrete number.

torch.sym_fresh_sizefunctionSame as PyTorch
sym_fresh_size(expr)

The size itself (no symbolic sizes in Riptorch).

torch.sym_intfunctionSame as PyTorch
sym_int(a)

int of a concrete number (symbolic ints don't occur in Riptorch).

torch.sym_itefunctionSame as PyTorch
sym_ite(b, t, f)

t if b else f.

torch.sym_maxfunctionSame as PyTorch
sym_max(a, b)

max(a, b) of concrete numbers.

torch.sym_minfunctionSame as PyTorch
sym_min(a, b)

min(a, b) of concrete numbers.

torch.sym_notfunctionSame as PyTorch
sym_not(a)

not a.

torch.sym_sqrtfunctionSame as PyTorch
sym_sqrt(a)

math.sqrt of a concrete number.

torch.sym_sumfunctionSame as PyTorch
sym_sum(args)

Sum of the numbers in args.

torch.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.)

torch.t_copyfunctionSame as PyTorch
t_copy(x, *a, **k)

t(...) as a new tensor (the view's copy: no memory shared with the input).

torch.thread_safe_generatorfunctionSame as PyTorch
thread_safe_generator()

torch.default_generator.

torch.to_dlpackfunctionSame as PyTorch
to_dlpack(tensor)

A DLPack capsule ("dltensor") of a CPU copy of tensor.

torch.transpose_copyfunctionSame as PyTorch
transpose_copy(*a, **k)

transpose(...) as a new tensor (the view's copy: no memory shared with the input).

torch.triplet_margin_lossfunctionSame as PyTorch
triplet_margin_loss(anchor, positive, negative, margin=1.0, p=2.0, eps=1e-06, swap=False, reduction=1)

F.triplet_margin_loss with PyTorch's integer reduction (0 none, 1 mean, 2 sum).

torch.unbind_copyfunctionSame as PyTorch
unbind_copy(*a, **k)

unbind(...) as a new tensor (the view's copy: no memory shared with the input).

torch.unfoldfunctionRiptorch extra
unfold(input, dimension, size, step)

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

Riptorch extra: not in stock PyTorch.

torch.unfold_copyfunctionSame as PyTorch
unfold_copy(input, dimension, size, step)

unfold(...) as a new tensor (the view's copy: no memory shared with the input).

torch.unify_type_listfunctionSame as PyTorch
unify_type_list(types)

The one type a list of types unifies to (None with T gives Optional[T]), or RuntimeError.

torch.unsafe_split_with_sizesfunctionSame as PyTorch
unsafe_split_with_sizes(input, *a, **k)

input.unsafe_split_with_sizes(...).

torch.unsqueeze_copyfunctionSame as PyTorch
unsqueeze_copy(*a, **k)

unsqueeze(...) as a new tensor (the view's copy: no memory shared with the input).

torch.values_copyfunctionSame as PyTorch
values_copy(x, *a, **k)

values(...) as a new tensor (the view's copy: no memory shared with the input).

torch.view_as_complex_copyfunctionSame as PyTorch
view_as_complex_copy(x)

view_as_complex(...) as a new tensor (the view's copy: no memory shared with the input).

torch.view_as_real_copyfunctionSame as PyTorch
view_as_real_copy(x)

view_as_real(...) as a new tensor (the view's copy: no memory shared with the input).

torch.view_copyfunctionSame as PyTorch
view_copy(x, *a, **k)

view(...) as a new tensor (the view's copy: no memory shared with the input).

torch.waitfunctionSame as PyTorch
wait(fut)

Same as PyTorch’s torch.wait.

torch.weight_mapfunctionRiptorch extra
weight_map(x, kind)

w(x) of a weighting map, elementwise.

Riptorch extra: not in stock PyTorch.

torch.weight_ratefunctionRiptorch extra
weight_rate(x, kind)

r(x) = w'(x) / w(x) of a weighting map, elementwise.

Riptorch extra: not in stock PyTorch.