Tensors
get_default_device()torch.get_default_device: what set_default_device recorded, else device('cpu').
get_default_dtype()torch.get_default_dtype: the dtype of new floating tensors (float32 unless set_default_dtype changed it).
is_conj(x)False: Riptorch never keeps lazy conjugate or negation bits.
is_floating_point(input)Same as PyTorch’s torch.is_floating_point.
is_neg(x)False: Riptorch never keeps lazy conjugate or negation bits.
is_nonzero(x)The truth value of a one-element tensor (more elements raise).
is_storage(obj)False: Riptorch tensors expose no separate storage objects here.
set_default_device(device)torch.set_default_device: recorded (get_default_device returns it); every Riptorch tensor is in unified memory.
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.
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).
set_flush_denormal(mode)Returns True and changes nothing (denormals are kept).
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
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).
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).
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).
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).
complex(real, imag)torch.complex(real, imag): float32 parts give complex64, float64 parts complex128.
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")
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.
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).
empty_strided(size, stride, *, dtype=None, **kw)A zero-filled tensor of size; stride is ignored (contiguous layout).
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).
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).
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).
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).
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).
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).
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).
heaviside(input, values, *, out=None)The step function: 0 where input < 0, 1 where input > 0, values where input == 0; input's dtype.
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).
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).
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).
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).
quantize_per_channel(input, scales, zero_points, axis, dtype)Quantize along axis with one scale / zero point per channel.
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")
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.
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).
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.
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.
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.
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].
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.
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.
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).
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.
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
adjoint(input)Conjugate transpose of the last two dims (a plain transpose for real tensors).
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.
cat(Tensor[] tensors, int dim=0) -> TensorAlso takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch. A quantized input runs the quantized kernel (same parameters).
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.
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.
concat(Tensor[] tensors, int dim=0) -> TensorAlso takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch. A quantized input runs the quantized kernel (same parameters).
concatenate(Tensor[] tensors, int dim=0) -> TensorAlso takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch. A quantized input runs the quantized kernel (same parameters).
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.
dstack(tensors, *, out=None)The tensors concatenated along dim 2, after atleast_3d.
gather(Tensor self, int dim, Tensor index, *, bool sparse_grad=False) -> Tensorout[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.
hsplit(input, sections)tensor_split along dim 1 (dim 0 for a 1-d input).
hstack(tensors, *, out=None)The tensors concatenated along dim 1 (dim 0 when they are 1-d), after atleast_1d.
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")
index_copy(input, dim, index, source)A copy of input with source's slices written at index along dim.
index_fill(input, dim, index, value)A copy of input with value written into the slices at index along dim.
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")
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.
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.
masked_fill(input, mask, value)value where mask is true, else the input; the result keeps the input's dtype.
masked_scatter(input, mask, source)A copy of input whose True positions of mask (broadcast), in row-major order, take source's leading elements.
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.
moveaxis(input, source, destination)input with the dims at source moved to destination (ints or sequences), the others in order; a view.
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.
narrow(Tensor self, int dim, int start, int length) -> TensorThe 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.
narrow_copy(self, dim, start, length)narrow(dim, start, length) as a new tensor.
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.
permute(input, *dims)Reorders the dimensions. Dtypes: every dtype (autograd for the floating-point types).
put(input, index, source, accumulate=False)A copy of input with the flat positions index set to source's values (accumulate=True: added instead).
row_stack(tensors, *, out=None)The tensors concatenated along dim 0, after atleast_2d (1-d tensors become rows).
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.
scatter_add(input, dim, index, src)scatter with reduce='add': repeated indices accumulate.
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).
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).
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.
select_scatter(input, src, dim, index)A copy of input with input.select(dim, index) replaced by src.
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.
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.
split_with_sizes(input, split_sizes, dim=0)Consecutive pieces of input along dim with the given sizes, as a tuple.
squeeze(Tensor self, dim=None) -> TensorRemoves 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.
stack(Tensor[] tensors, int dim=0) -> TensorJoins 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).
swapaxes(Tensor self, int dim0, int dim1) -> TensorSwaps 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.
swapdims(Tensor self, int dim0, int dim1) -> TensorSwaps 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.
t(input)Transpose of a tensor of at most 2 dims (0-d and 1-d come back as they are).
take(input, index)input's elements at the given flat indices (input read as 1-d), shaped like index.
take_along_dim(*a, **k)input's values at indices along dim, input and indices broadcast on the other dims; dim=None takes from the flattened input.
Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.
tensor_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.
tile(input, dims)input repeated dims[i] times along each dimension; a dims shorter than input's rank is padded with leading 1s.
transpose(Tensor self, int dim0, int dim1) -> TensorSwaps 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.
unbind(*a, **k)A tuple of the slices along dim, each without dim.
Also takes NumPy's axis= / keepdims= for dim= / keepdim=, 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.
unsqueeze(Tensor self, int dim) -> TensorInserts 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.
vstack(tensors, *, out=None)The tensors concatenated along dim 0, after atleast_2d (1-d tensors become rows).
where(condition, input=None, other=None)Same as PyTorch’s torch.where.
Random sampling
bernoulli(input, p=None, *, generator=None, out=None)torch.bernoulli: 1 with probability input (or p), as input's dtype.
binomial(count, prob, generator=None)torch.binomial: a Binomial(count, prob) draw per element.
default_generator = <riptorch default generator>Same as PyTorch’s torch.default_generator.
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.
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).
initial_seed()The seed of the default generator (the one manual_seed set).
manual_seed(seed)The numbers differ from PyTorch's for the same seed: PyTorch's generator sequence is not part of its API.
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).
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.
poisson(input, generator=None)torch.poisson: a Poisson draw per rate (input's dtype).
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).
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).
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).
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).
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).
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).
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).
seed()torch.seed: seeds with a non-deterministic number and returns it.
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
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.
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
get_num_interop_threads()torch.get_num_interop_threads: the recorded value, else os.cpu_count.
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).
set_num_interop_threads(n)torch.set_num_interop_threads: recorded for get_num_interop_threads (Riptorch has no inter-op pool).
set_num_threads(n)Same as PyTorch’s torch.set_num_threads.
Gradient mode
enable_grad(orig_func=None)with torch.enable_grad: ops record gradients again inside no_grad (LBFGS closures). Also a decorator.
inference_mode(mode=True)torch.inference_mode(mode=True): no gradients recorded (as no_grad); a context manager and a decorator.
is_grad_enabled()Whether gradient recording is on (no_grad / enable_grad / set_grad_enabled change it).
is_inference_mode_enabled()Whether an inference_mode block is active.
no_grad(orig_func=None)with torch.no_grad: ops don't record gradients. Also a decorator: @torch.no_grad or @torch.no_grad.
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
abs(input)Elementwise absolute value. Every dtype; autograd for the floating-point types.
absolute(input)Elementwise absolute value. Every dtype; autograd for the floating-point types.
acos(input, *, out=None)Arccosine, elementwise, as atan2(sqrt(1 - x^2), x); differentiable. Integer input is computed in float32.
acosh(input)Inverse hyperbolic cosine (NaN below 1). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
add(input, other, *, alpha=1)self + alpha * other, with broadcasting and PyTorch type promotion. Every dtype; autograd for the floating-point types.
addcdiv(input, tensor1, tensor2, *, value=1)input + value * tensor1 / tensor2.
addcmul(input, tensor1, tensor2, *, value=1)input + value * tensor1 * tensor2.
alpha_dropout(input, p, train)Alpha dropout (keeps SELU's mean and variance) when train is True; the input otherwise.
angle(x)The argument atan2(imag, real) of each complex value (0 or pi for real values).
arccos(input, *, out=None)Arccosine, elementwise, as atan2(sqrt(1 - x^2), x); differentiable. Integer input is computed in float32.
arccosh(input)Inverse hyperbolic cosine (NaN below 1). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
arcsin(input, *, out=None)Arcsine, elementwise, as atan2(x, sqrt(1 - x^2)); differentiable. Integer input is computed in float32.
arcsinh(input)Inverse hyperbolic sine. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
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.
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.
arctanh(input)Inverse hyperbolic tangent (inf at +-1, NaN outside). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
asin(input, *, out=None)Arcsine, elementwise, as atan2(x, sqrt(1 - x^2)); differentiable. Integer input is computed in float32.
asinh(input)Inverse hyperbolic sine. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
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.
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.
atanh(input)Inverse hyperbolic tangent (inf at +-1, NaN outside). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
bitwise_and(input, other)Bitwise AND of integers, logical AND of bools (also &, and torch.logical_and on bool casts). Every dtype.
bitwise_left_shift(input, other, *, out=None)Shift left: input << other, elementwise on integers, wrapping to input's width as PyTorch.
bitwise_not(input)Bitwise NOT of integers, logical NOT of bools (also ~, and logical_not on bool casts). Every dtype.
bitwise_or(input, other)Bitwise OR of integers, logical OR of bools (also |, and torch.logical_or on bool casts). Every dtype.
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.
bitwise_xor(input, other)Bitwise XOR of integers, logical XOR of bools (also ^). Every dtype.
ceil(input)Rounds up to an integer value (the dtype is kept). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
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).
clamp(input, min=None, max=None)Limits values to [min, max] (either may be None; clip too).
clip(input, min=None, max=None)Limits values to [min, max] (either may be None; clip too).
conj_physical(x)The complex conjugate (a real tensor is returned as it is).
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.
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
cosh(input)Hyperbolic cosine. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
deg2rad(input)Degrees to radians. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
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)
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.
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.
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.
erf(input)The error function. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
erfc(input)1 - erf(x), accurate in the upper tail. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
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)
exp(input)Elementwise e^x. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
exp2(input)Elementwise 2^x. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
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).
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")
feature_alpha_dropout(input, p, train)Alpha dropout of whole channels (dim 1) when train is True; the input otherwise.
feature_dropout(input, p, train)Dropout of whole channels (dim 1, one draw per batch x channel), survivors scaled by 1 / (1 - p).
fix(input)Rounds toward zero (fix too). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
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).
floor(input)Rounds down to an integer value (the dtype is kept). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
floor_divide(input, other, *, out=None)Division rounded down (torch.div with rounding_mode='floor'); integers stay integers.
frac(input)x - trunc(x), keeping the sign. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
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.
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.
hardshrink(input, lambd=0.5)x where |x| > lambd, else 0. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
hypot(input, other)sqrt(a^2 + b^2) elementwise. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
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)
igamma(input, other, *, out=None)The regularized lower incomplete gamma function P(a, x) (input a, other x), in float64 and rounded once.
igammac(input, other, *, out=None)The regularized upper incomplete gamma function Q(a, x) = 1 - P(a, x), in float64 and rounded once.
ldexp(input, other, *, out=None)input * 2**other, elementwise, as a float tensor.
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.
log(input)Elementwise natural log (-inf at 0, NaN below 0). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
log10(input)Elementwise log base 10. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
log1p(input)2 atanh(x / (2 + x)) below 1/4, log(1 + x) with the rounding of 1 + x put back above.
log2(input)Elementwise log base 2. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
log_softmax(Tensor input, int? dim=None, *, dtype? dtype=None) -> Tensorlog(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.
logaddexp(input, other)log(exp(a) + exp(b)) computed stably. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
logaddexp2(input, other, *, out=None)log2(2^input + 2^other) without overflow: max + log2(1 + 2^-|input - other|).
logical_and(*args, **kw)logical_and: the inputs as bool, then bitwise_and (a bool result, as PyTorch's logical ops).
logical_not(*args, **kw)logical_not: the inputs as bool, then bitwise_not (a bool result, as PyTorch's logical ops).
logical_or(*args, **kw)logical_or: the inputs as bool, then bitwise_or (a bool result, as PyTorch's logical ops).
logical_xor(input, other, *, out=None)Elementwise XOR of the inputs' truth values (nonzero is True); bool.
logit(input)log(x / (1 - x)). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
mul(input, other)Elementwise product, with broadcasting and PyTorch type promotion. Every dtype; autograd for the floating-point types.
multiply(input, other)Elementwise product, with broadcasting and PyTorch type promotion. Every dtype; autograd for the floating-point types.
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).
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).
negative(input)-x (alias of neg). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
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.
polygamma(n, input, *, out=None)polygamma(n, x): the n-th derivative of digamma.
positive(input)x unchanged. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
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).
prelu(input, weight)weight has 1 or C (= input.shape[1]) entries, broadcast over dim 1.
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).
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).
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).
rad2deg(input)Radians to degrees. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
real(x)The real part of a complex tensor (a real tensor is returned as it is).
reciprocal(input)1 / x. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
relu(Tensor self, bool inplace=False) -> Tensormax(x, 0). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types). A quantized input runs the quantized kernel (same parameters).
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
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).
rsqrt(input)Classic only: as an elementwise op it has no rational form (the rational RMSNorm is a module-level row).
selu(input, inplace=False)scale * elu(x, alpha) with the SELU constants. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
sgn(input)-1, 0 or 1 by sign (sgn too). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
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).
sign(input)-1, 0 or 1 by sign (sgn too). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
signbit(input, *, out=None)True where the sign bit is set: negative values and -0.0 (integers: x < 0).
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
sinh(input)Hyperbolic sine. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
softmax(Tensor input, int? dim=None, *, dtype? dtype=None) -> TensorAlso takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.
sqrt(input)Elementwise square root (NaN below 0). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
square(input)x * x. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
sub(input, other, *, alpha=1)self - alpha * other, with broadcasting and PyTorch type promotion. Every dtype; autograd for the floating-point types.
subtract(input, other, *, alpha=1)self - alpha * other, with broadcasting and PyTorch type promotion. Every dtype; autograd for the floating-point types.
tan(input)Elementwise tangent. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
threshold(input, threshold, value, inplace=False)x where x > threshold, else value. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
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.
trunc(input)Rounds toward zero (fix too). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
xlogy(input, other)x * log(y), 0 where x is 0. Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
Reductions
all(Tensor self, int? dim=None, bool keepdim=False) -> TensorWhether 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.
amax(Tensor self, int[] dim=[], bool keepdim=False) -> TensorMaximum 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.
amin(Tensor self, int[] dim=[], bool keepdim=False) -> TensorMinimum 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.
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.
any(Tensor self, int? dim=None, bool keepdim=False) -> TensorWhether 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.
argmax(Tensor self, int? dim=None, bool keepdim=False) -> TensorThe first index of the maximum (as PyTorch), int64.
Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.
argmin(Tensor self, int? dim=None, bool keepdim=False) -> TensorIndex 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.
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.
dist(input, other, p=2)The p-norm (default 2) of input - other over all elements.
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")
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.
mean(Tensor self, int[]? dim=None, bool keepdim=False, *, dtype? dtype=None) -> TensorMean 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.
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.
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.
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).
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.
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.
nanquantile(input, q, dim=None, keepdim=False, *, interpolation='linear', out=None)quantile ignoring NaN: NaN only where a row has no other values.
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.
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.
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.
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.
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.
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).
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
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).
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.
var(Tensor self, int[]? dim=None, *, float correction=1, bool keepdim=False, bool? unbiased=None) -> TensorVariance 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.
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
allclose(input, other, rtol=1e-05, atol=1e-08, equal_nan=False)Whether isclose holds everywhere; a Python bool.
argsort(Tensor self, int dim=-1, bool descending=False, *, bool stable=False) -> TensorIndices that sort along dim (descending= for largest first); ties keep their original order.
Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch.
eq(input, other)Elementwise ==, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.
equal(*a, **k)True if both tensors have the same shape and the same values. A quantized input runs the quantized kernel (same parameters).
fmax(input, other, *, out=None)Elementwise maximum ignoring NaN: where one side is NaN the other is returned (NaN only when both are).
fmin(input, other, *, out=None)Elementwise minimum ignoring NaN: where one side is NaN the other is returned (NaN only when both are).
ge(input, other)Elementwise >=, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.
greater(input, other)Elementwise >, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.
greater_equal(input, other)Elementwise >=, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.
gt(input, other)Elementwise >, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.
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.
isfinite(input)True where the element is neither inf nor NaN (always True for integer and bool tensors).
isin(elements, test_elements, *, assume_unique=False, invert=False)Whether each element occurs in test_elements (invert=True negates); returns bool.
isinf(input)True where the element is +inf or -inf (always False for integer and bool tensors).
isnan(input)Tensor.isnan / torch.isnan: True where the element is NaN (x != x); always False for integer and bool tensors.
isreal(x)Elementwise: True where the imaginary part is zero (all True for real tensors).
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.
le(input, other)Elementwise <=, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.
less(input, other)Elementwise <, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.
less_equal(input, other)Elementwise <=, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.
lt(input, other)Elementwise <, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.
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.
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.
ne(input, other)Elementwise !=, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.
not_equal(input, other)Elementwise !=, with broadcasting and PyTorch type promotion; returns bool. Every dtype; autograd for the floating-point types.
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.
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
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.
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.
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.
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).
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.
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.
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
atleast_1d(*tensors)Each tensor with at least one dim (0-d becomes shape (1,)); one tensor in gives one out, several a tuple.
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.
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)).
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).
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.
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.
block_diag(*tensors)A block-diagonal matrix from the tensors (0-d and 1-d become one row), in the first tensor's dtype.
broadcast_shapes(*shapes)The shape the given shapes broadcast to; RuntimeError when they don't, as PyTorch.
broadcast_tensors(*tensors)The tensors expanded to their common broadcast shape; also broadcast_shapes and broadcast_to.
broadcast_to(input, size)The tensor expanded to size (-1 keeps a dim), a broadcast view.
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.
cartesian_prod(*tensors)Every combination of the 1-d tensors' entries as rows (one tensor: returned as it is).
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].
channel_shuffle(input, groups)Shuffles the channels (dim 1) across groups: (N, g*k,...) read as (N, g, k,...) and transposed.
combinations(input, r=2, with_replacement=False)The r-length combinations of the 1-d input's entries as rows, in itertools order.
conv1d(input, weight, bias=None, stride=(1,), padding=(0,), dilation=(1,), groups=1)Same as PyTorch’s torch.conv1d.
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.
conv3d(input, weight, bias=None, stride=(1,), padding=(0,), dilation=(1,), groups=1)Same as PyTorch’s torch.conv3d.
conv_transpose1d(input, weight, bias=None, stride=(1,), padding=(0,), output_padding=(0,), groups=1, dilation=(1,))Same as PyTorch’s torch.conv_transpose1d.
conv_transpose2d(input, weight, bias=None, stride=(1,), padding=(0,), output_padding=(0,), groups=1, dilation=(1,))Same as PyTorch’s torch.conv_transpose2d.
conv_transpose3d(input, weight, bias=None, stride=(1,), padding=(0,), output_padding=(0,), groups=1, dilation=(1,))Same as PyTorch’s torch.conv_transpose3d.
corrcoef(input)The Pearson correlation matrix of the rows of input, clamped to [-1, 1].
cosine_similarity(x1, x2, dim=1, eps=1e-08, *, maths=None)Same as PyTorch’s torch.cosine_similarity.
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.
cross(input, other, dim=-1)The 3-d cross product along dim (size 3), broadcasting.
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.
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.
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.
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.
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.
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).
diagflat(input, offset=0)A square 2-d tensor with input's elements (flattened) on the offset diagonal and zeros elsewhere.
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).
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.
einsum(equation, *operands)Einstein summation: the operands contracted as the equation says (the core's einsum; gradients flow).
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).
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.
flatten(Tensor self, int start_dim=0, int end_dim=-1) -> TensorA 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).
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.
gcd(input, other, *, out=None)Elementwise greatest common divisor of integer tensors, exact (Python integers), in the first input's dtype.
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).
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).
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.
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.
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).
kron(input, other, *, out=None)torch.kron(a, b): the Kronecker product (dims aligned from the right), differentiable.
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).
lcm(input, other, *, out=None)Elementwise least common multiple of integer tensors (0 where either is 0), in the first input's dtype.
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.
max_pool1d(*a, **k)1-d max pooling (aten form: stride= means kernel_size). A quantized input runs the quantized kernel (same parameters).
max_pool2d(Tensor input, int[] kernel_size, int[] stride=(), int[] padding=(0,), int[] dilation=(1,), bool ceil_mode=False, bool return_indices=False) -> TensorAny 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
max_pool3d(*a, **k)3-d max pooling (aten form: stride= means kernel_size). A quantized input runs the quantized kernel (same parameters).
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.
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).
pdist(input, p=2)Pairwise p-norm distances between the rows of a 2-d tensor (the upper triangle, row by row).
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).
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).
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).
repeat_interleave(Tensor self, int repeats, int? dim=None) -> TensorRepeats 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.
resolve_conj(x)x: there is never a lazy conjugate or negation to resolve.
resolve_neg(x)x: there is never a lazy conjugate or negation to resolve.
roll(Tensor input, int[] shifts, int[] dims=()) -> TensorEach 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.
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.
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).
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.
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.
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).
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.
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).
unflatten(input, dim, sizes)input with dim replaced by the given sizes (one of them may be -1).
vander(x, N=None, increasing=False)torch.vander(x, N=None, increasing=False): decreasing powers by default (unlike linalg.vander).
view_as_complex(x)A complex tensor over a float32 / float64 tensor whose last dim is 2 (real, imaginary), without a copy.
view_as_real(x)The [..., 2] float view (real, imaginary) of a complex tensor, without a copy; RuntimeError for real tensors.
BLAS and LAPACK
addbmm(input, batch1, batch2, *, beta=1, alpha=1, out=None)beta * input + alpha * sum over the batch of batch1[i] @ batch2[i].
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).
addmv(input, mat, vec, *, beta=1, alpha=1, out=None)beta * input + alpha * (mat @ vec).
addr(input, vec1, vec2, *, beta=1, alpha=1, out=None)beta * input + alpha * outer(vec1, vec2).
baddbmm(input, batch1, batch2, *, beta=1, alpha=1, out=None)beta * input + alpha * (batch1 @ batch2), batched.
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).
chain_matmul(*matrices, out=None)torch.chain_matmul (deprecated in PyTorch): linalg.multi_dot of the matrices.
cholesky(A, upper=False, *, out=None)torch.cholesky (deprecated in PyTorch): linalg.cholesky(A, upper=upper).
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).
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).
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.
det(A, *, out=None, maths=None, exact=False)Same as PyTorch’s torch.det.
ger(input, vec2, *, out=None)The outer product of two vectors (ger too).
inner(input, other, *, out=None)Inner product over the last dims (a scalar input multiplies).
inverse(A, *, out=None)torch.inverse: linalg.inv(A) (integer A gives the exact inverse as a FractionTensor).
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)
logdet(A)torch.logdet(A): log det A (nan for a negative determinant, -inf for zero).
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.
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.
lu_unpack(LU_data, LU_pivots, unpack_data=True, unpack_pivots=True, *, out=None)Same as PyTorch’s torch.lu_unpack.
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")
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).
matrix_power(A, n, *, out=None)linalg.matrix_power(A, n): repeated squaring (n < 0: of the inverse); n = 0 gives the identity.
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")
mv(input, vec, *, out=None)Matrix-vector product (2-d @ 1-d); other ranks raise as PyTorch.
orgqr(A, tau, *, out=None)linalg.householder_product(A, tau): the first n columns of H_1... H_k (LAPACK orgqr).
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.
outer(input, vec2, *, out=None)The outer product of two vectors (ger too).
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)).
pinverse(input, rcond=1e-15)torch.pinverse: linalg.pinv with rtol=rcond.
qr(A, some=True, *, out=None)torch.qr (deprecated in PyTorch): linalg.qr with mode 'reduced' (some=True) or 'complete'.
slogdet(A, *, out=None, maths=None)Same as PyTorch’s torch.slogdet.
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.
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.
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).
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).
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).
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.
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).
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).
compiled_with_cxx11_abi()True, as PyTorch's macOS builds report.
cond(pred, true_fn, false_fn, operands=())true_fn(*operands) if pred else false_fn(*operands), run eagerly (pred read as a bool).
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).
get_deterministic_debug_mode()0 ('default').
get_device_module(device=None)The torch.<device type> module for a device ('cpu' when none is given).
get_float32_matmul_precision()The precision set_float32_matmul_precision recorded ('highest' by default; Riptorch's matmul precision is set with torch.set_matmul).
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.
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.
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.
set_autocast_enabled(*args)set_autocast_enabled([device_type,] enabled): turns autocast on or off (device_type defaults to cuda).
set_deterministic_debug_mode(mode)Does nothing: Riptorch's ops are deterministic.
set_float32_matmul_precision(p)Records 'highest', 'high' or 'medium' (RuntimeError otherwise); use torch.set_matmul to change Riptorch's matmul precision.
set_warn_always(b)Does nothing (Riptorch's warnings follow Python's warnings filters).
typename(obj)The name of obj's type: the legacy tensor type name for tensors (torch.FloatTensor, torch.LongTensor,...), module.qualname otherwise.
use_deterministic_algorithms(mode, *, warn_only=False)Records the flag (Riptorch's ops are deterministic either way).
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).
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
AcceleratorErrorAn accelerator failed (a RuntimeError, as PyTorch).
AggregationType(*values)Same as PyTorch’s torch.AggregationType.
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).
BenchmarkConfig()ThroughputBenchmark settings: num_calling_threads, num_worker_threads, num_warmup_iters, num_iters, profiler_output_path.
BenchmarkExecutionStats(*a, **k)Raw ThroughputBenchmark results: latency_avg_ms and num_iters (not constructible, as PyTorch).
BFloat16Storage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.bfloat16)Same as PyTorch’s torch.BFloat16Storage.
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.
Block(*a, **k)A list of nodes with its own inputs (param node) and outputs (return node).
BoolStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.bool)Same as PyTorch’s torch.BoolStorage.
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.
ByteStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.uint8)Same as PyTorch’s torch.ByteStorage.
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.
CallStack(*args)A TorchScript call-stack entry: name and source range.
CharStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.int8)Same as PyTorch’s torch.CharStorage.
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.
ClassType(*args)A TorchScript class type, by qualified name (ClassType("__torch__.M")). PyTorch raises when constructed from Python; Riptorch builds it.
CompilationUnit(lang=None, _frames_up=0)Same as PyTorch’s torch.CompilationUnit.
CompleteArgumentSpec(*a, **k)Same as PyTorch’s torch.CompleteArgumentSpec.
ComplexDoubleStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.complex128)Same as PyTorch’s torch.ComplexDoubleStorage.
ComplexFloatStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.complex64)Same as PyTorch’s torch.ComplexFloatStorage.
ComplexTensor(rv)A complex tensor: _rv is its real view [..., 2].
Riptorch extra: not in stock 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.
DeepCopyMemoTable(*a, **k)Same as PyTorch’s torch.DeepCopyMemoTable.
DeserializationStorageContext()Storages by key while an archive is loaded.
device(type, index=None)torch.device: a device type and index. Riptorch's tensors are in unified memory: every tensor reports cpu.
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).
DispatchKeySet(*args)A set of dispatch keys (| & -, has, add, remove, highestPriorityTypeId, raw_repr).
DoubleStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.float64)Same as PyTorch’s torch.DoubleStorage.
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.
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.
EnumType(*args)A TorchScript enum type: EnumType(qualified_name, value_type, values).
ErrorReport(*args)A TorchScript compile error at a source range (an Exception).
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.
ExcludeDispatchKeyGuard(*args)Excludes dispatch keys while alive (Riptorch dispatches without keys: a guard with nothing to exclude).
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.
finfo(type=None)The floating-point limits of a dtype (IEEE 754 and the OCP 8-bit formats), as PyTorch reports them.
FloatStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.float32)Same as PyTorch’s torch.FloatStorage.
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.
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.
FunctionSchema(*args)An operator schema: name, overload_name, arguments, returns (parse_schema reads the text form).
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).
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).
Graph()A TorchScript-style graph: graph inputs, nodes in order, outputs; printed in TorchScript's IR text form.
GraphExecutorState(*a, **k)Same as PyTorch’s torch.GraphExecutorState.
HalfStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.float16)Same as PyTorch’s torch.HalfStorage.
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.
iinfo(type)Bits, min and max of an integer dtype; bool and float dtypes raise TypeError, as PyTorch.
InferredType(*args)The result of inferring a value's type: success and type, or reason.
InterfaceType(*args)A TorchScript interface type, by qualified name.
IntStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.int32)Same as PyTorch’s torch.IntStorage.
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.
layout(name)torch.layout: strided, sparse_coo, sparse_csr, sparse_csc, sparse_bsr, sparse_bsc, jagged, _mkldnn.
LiteScriptModule(*args)A module of the TorchScript mobile runtime; construction raises as PyTorch does from Python.
LockingLogger()Counters by key, summed or averaged (set_aggregation_type).
LoggerBase(*a, **k)Base of the TorchScript stat loggers (not constructible, as PyTorch).
LongStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.int64)Same as PyTorch’s torch.LongStorage.
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.
memory_format(name)torch.memory_format: a name (contiguous_format, channels_last,...); Riptorch tensors have one layout.
ModuleDict(modules=None)torch.nn.ModuleDict: modules by name, registered as submodules in insertion order.
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.
Node(*a, **k)One operation of the IR: kind ("aten::add"), inputs, outputs, attributes, blocks.
OutOfMemoryErrorOut of memory (a RuntimeError, as PyTorch).
ParameterDict(parameters=None)Parameters by key, registered under the keys; plain tensors become parameters.
PyTorchFileReader(f)Reads a torch.save zip archive: records by name (without the archive's directory).
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.
QInt32Storage(*args, wrap_storage=None, dtype=None, device=None, _internal=False)A storage of quantized values (torch.<Name>Storage): its raw integers.
QInt8Storage(*args, wrap_storage=None, dtype=None, device=None, _internal=False)A storage of quantized values (torch.<Name>Storage): its raw integers.
qscheme(name)torch.qscheme: how a quantized tensor maps its integers to reals.
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.
QUInt2x4Storage(*args, wrap_storage=None, dtype=None, device=None, _internal=False)A storage of quantized values (torch.<Name>Storage): its raw integers.
QUInt4x2Storage(*args, wrap_storage=None, dtype=None, device=None, _internal=False)A storage of quantized values (torch.<Name>Storage): its raw integers.
QUInt8Storage(*args, wrap_storage=None, dtype=None, device=None, _internal=False)A storage of quantized values (torch.<Name>Storage): its raw integers.
ScriptClassFunction(*a, **k)Same as PyTorch’s torch.ScriptClassFunction.
ScriptDictIterator(*a, **k)Same as PyTorch’s torch.ScriptDictIterator.
ScriptDictKeyIterator(*a, **k)Same as PyTorch’s torch.ScriptDictKeyIterator.
ScriptFunction(*a, **k)Same as PyTorch’s torch.ScriptFunction.
ScriptListIterator(*a, **k)Same as PyTorch’s torch.ScriptListIterator.
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.
ScriptModuleSerializer(*args)Writes a ScriptModule archive; serialize raises (TorchScript serialization needs TorchScript).
ScriptObjectProperty(*a, **k)Same as PyTorch’s torch.ScriptObjectProperty.
SerializationStorageContext(*a, **k)Same as PyTorch’s torch.SerializationStorageContext.
ShortStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.int16)Same as PyTorch’s torch.ShortStorage.
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.
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.
Size(sizes=())torch.Size: a tuple of ints (numel, and a tuple's operations).
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.
Storage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.float32)Same as PyTorch’s torch.Storage.
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.
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.
TensorType(*a, **k)The TorchScript tensor type: TensorType.get (any tensor) or the dtype, sizes and requires_grad of one tensor (create_from_tensor).
ThroughputBenchmark(module)Runs a module (or function) on recorded inputs from several threads and measures latency / throughput.
Type(*a, **k)A TorchScript type: str, kind, isSubtypeOf, containedTypes; tensor queries on TensorType.
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.
UntypedStorage(*args, device=None)torch.UntypedStorage: bytes.
Use(*a, **k)One use of a Value: the node using it (user) and the input position (offset).
Value(*a, **k)A value of the IR: one node's output or a graph / block input.
Data types and constants
channels_last = riptorch.channels_lastSame as PyTorch’s torch.channels_last.
channels_last_3d = riptorch.channels_last_3dSame as PyTorch’s torch.channels_last_3d.
complex128 = riptorch.complex128Same as PyTorch’s torch.complex128.
contiguous_format = riptorch.contiguous_formatSame as PyTorch’s torch.contiguous_format.
float8_e4m3fn = riptorch.float8_e4m3fnSame as PyTorch’s torch.float8_e4m3fn.
float8_e4m3fnuz = riptorch.float8_e4m3fnuzSame as PyTorch’s torch.float8_e4m3fnuz.
float8_e5m2 = riptorch.float8_e5m2Same as PyTorch’s torch.float8_e5m2.
float8_e5m2fnuz = riptorch.float8_e5m2fnuzSame as PyTorch’s torch.float8_e5m2fnuz.
float8_e8m0fnu = riptorch.float8_e8m0fnuSame as PyTorch’s torch.float8_e8m0fnu.
LOSSES = ('cross_entropy', 'brier', 'spherical')Riptorch extra: not in stock PyTorch.
per_channel_affine = riptorch.per_channel_affineSame as PyTorch’s torch.per_channel_affine.
per_channel_affine_float_qparams = riptorch.per_channel_affine_float_qparamsSame as PyTorch’s torch.per_channel_affine_float_qparams.
per_channel_symmetric = riptorch.per_channel_symmetricSame as PyTorch’s torch.per_channel_symmetric.
per_tensor_affine = riptorch.per_tensor_affineSame as PyTorch’s torch.per_tensor_affine.
per_tensor_symmetric = riptorch.per_tensor_symmetricSame as PyTorch’s torch.per_tensor_symmetric.
preserve_format = riptorch.preserve_formatSame as PyTorch’s torch.preserve_format.
sparse_bsc = torch.sparse_bscSame as PyTorch’s torch.sparse_bsc.
sparse_bsr = torch.sparse_bsrSame as PyTorch’s torch.sparse_bsr.
sparse_coo = torch.sparse_cooSame as PyTorch’s torch.sparse_coo.
sparse_csc = torch.sparse_cscSame as PyTorch’s torch.sparse_csc.
sparse_csr = torch.sparse_csrSame as PyTorch’s torch.sparse_csr.
WEIGHT_MAPS = ('exp', 'taylor2', 'cayley', 'square_linear', 'relu_square')Riptorch extra: not in stock PyTorch.
In-place functions
abs_(input, *a, **k)input.abs_(...): abs in place on input; returns input.
absolute_(input, *a, **k)input.absolute_(...): absolute in place on input; returns input.
Riptorch extra: not in stock PyTorch.
acos_(input, *a, **k)input.acos_(...): acos in place on input; returns input.
acosh_(input, *a, **k)input.acosh_(...): acosh in place on input; returns input.
addbmm_(input, *a, **k)input.addbmm_(...): addbmm in place on input; returns input.
Riptorch extra: not in stock PyTorch.
addcdiv_(input, *a, **k)input.addcdiv_(...): addcdiv in place on input; returns input.
Riptorch extra: not in stock PyTorch.
addcmul_(input, *a, **k)input.addcmul_(...): addcmul in place on input; returns input.
Riptorch extra: not in stock PyTorch.
addmm_(input, *a, **k)input.addmm_(...): addmm in place on input; returns input.
Riptorch extra: not in stock PyTorch.
addmv_(input, *a, **k)input.addmv_(...): addmv in place on input; returns input.
addr_(input, *a, **k)input.addr_(...): addr in place on input; returns input.
Riptorch extra: not in stock PyTorch.
arccos_(input, *a, **k)input.arccos_(...): arccos in place on input; returns input.
arccosh_(input, *a, **k)input.arccosh_(...): arccosh in place on input; returns input.
arcsin_(input, *a, **k)input.arcsin_(...): arcsin in place on input; returns input.
arcsinh_(input, *a, **k)input.arcsinh_(...): arcsinh in place on input; returns input.
arctan2_(input, *a, **k)input.arctan2_(...): arctan2 in place on input; returns input.
Riptorch extra: not in stock PyTorch.
arctan_(input, *a, **k)input.arctan_(...): arctan in place on input; returns input.
arctanh_(input, *a, **k)input.arctanh_(...): arctanh in place on input; returns input.
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).
asin_(input, *a, **k)input.asin_(...): asin in place on input; returns input.
asinh_(input, *a, **k)input.asinh_(...): asinh in place on input; returns input.
atan2_(input, *a, **k)input.atan2_(...): atan2 in place on input; returns input.
Riptorch extra: not in stock PyTorch.
atan_(input, *a, **k)input.atan_(...): atan in place on input; returns input.
atanh_(input, *a, **k)input.atanh_(...): atanh in place on input; returns input.
baddbmm_(input, *a, **k)input.baddbmm_(...): baddbmm in place on input; returns input.
Riptorch extra: not in stock PyTorch.
bitwise_and_(input, *a, **k)input.bitwise_and_(...): bitwise_and in place on input; returns input.
Riptorch extra: not in stock PyTorch.
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.
bitwise_not_(input, *a, **k)input.bitwise_not_(...): bitwise_not in place on input; returns input.
Riptorch extra: not in stock PyTorch.
bitwise_or_(input, *a, **k)input.bitwise_or_(...): bitwise_or in place on input; returns input.
Riptorch extra: not in stock PyTorch.
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.
bitwise_xor_(input, *a, **k)input.bitwise_xor_(...): bitwise_xor in place on input; returns input.
Riptorch extra: not in stock PyTorch.
ceil_(input, *a, **k)input.ceil_(...): ceil in place on input; returns input.
clamp_(input, *a, **k)input.clamp_(...): clamp in place on input; returns input.
clamp_max_(input, *a, **k)input.clamp_max_(...): clamp_max in place on input; returns input.
clamp_min_(input, *a, **k)input.clamp_min_(...): clamp_min in place on input; returns input.
clip_(input, *a, **k)input.clip_(...): clip in place on input; returns input.
conj_physical_(input)In-place conjugate; real tensors are returned unchanged.
copysign_(input, *a, **k)input.copysign_(...): copysign in place on input; returns input.
Riptorch extra: not in stock PyTorch.
cos_(input, *a, **k)input.cos_(...): cos in place on input; returns input.
cosh_(input, *a, **k)input.cosh_(...): cosh in place on input; returns input.
deg2rad_(input, *a, **k)input.deg2rad_(...): deg2rad in place on input; returns input.
digamma_(input, *a, **k)input.digamma_(...): digamma in place on input; returns input.
Riptorch extra: not in stock PyTorch.
divide_(input, *a, **k)input.divide_(...): divide in place on input; returns input.
Riptorch extra: not in stock 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")
eq_(input, *a, **k)input.eq_(...): eq in place on input; returns input.
Riptorch extra: not in stock PyTorch.
erf_(input, *a, **k)input.erf_(...): erf in place on input; returns input.
erfc_(input, *a, **k)input.erfc_(...): erfc in place on input; returns input.
erfinv_(input, *a, **k)input.erfinv_(...): erfinv in place on input; returns input.
Riptorch extra: not in stock PyTorch.
exp2_(input, *a, **k)input.exp2_(...): exp2 in place on input; returns input.
exp_(input, *a, **k)input.exp_(...): exp in place on input; returns input.
expm1_(input, *a, **k)input.expm1_(...): expm1 in place on input; returns input.
feature_alpha_dropout_(input, p, train)In-place feature_alpha_dropout.
feature_dropout_(input, p, train)In-place feature_dropout.
fill_(input, value)Fills the tensor in place with value (a number or a 0-d tensor); returns it.
fix_(input, *a, **k)input.fix_(...): fix in place on input; returns input.
float_power_(input, *a, **k)input.float_power_(...): float_power in place on input; returns input.
Riptorch extra: not in stock PyTorch.
floor_(input, *a, **k)input.floor_(...): floor in place on input; returns input.
fmod_(input, *a, **k)input.fmod_(...): fmod in place on input; returns input.
Riptorch extra: not in stock PyTorch.
frac_(input, *a, **k)input.frac_(...): frac in place on input; returns input.
gcd_(input, *a, **k)input.gcd_(...): gcd in place on input; returns input.
ge_(input, *a, **k)input.ge_(...): ge in place on input; returns input.
Riptorch extra: not in stock PyTorch.
greater_(input, *a, **k)input.greater_(...): greater in place on input; returns input.
Riptorch extra: not in stock PyTorch.
greater_equal_(input, *a, **k)input.greater_equal_(...): greater_equal in place on input; returns input.
Riptorch extra: not in stock PyTorch.
gt_(input, *a, **k)input.gt_(...): gt in place on input; returns input.
Riptorch extra: not in stock PyTorch.
heaviside_(input, *a, **k)input.heaviside_(...): heaviside in place on input; returns input.
Riptorch extra: not in stock PyTorch.
hypot_(input, *a, **k)input.hypot_(...): hypot in place on input; returns input.
Riptorch extra: not in stock PyTorch.
i0_(input, *a, **k)input.i0_(...): i0 in place on input; returns input.
igamma_(input, *a, **k)input.igamma_(...): igamma in place on input; returns input.
Riptorch extra: not in stock PyTorch.
igammac_(input, *a, **k)input.igammac_(...): igammac in place on input; returns input.
Riptorch extra: not in stock PyTorch.
index_put_(input, *a, **k)input.index_put_(...): index_put in place on input; returns input.
lcm_(input, *a, **k)input.lcm_(...): lcm in place on input; returns input.
ldexp_(input, *a, **k)input.ldexp_(...): ldexp in place on input; returns input.
le_(input, *a, **k)input.le_(...): le in place on input; returns input.
Riptorch extra: not in stock PyTorch.
lerp_(input, *a, **k)input.lerp_(...): lerp in place on input; returns input.
Riptorch extra: not in stock PyTorch.
less_(input, *a, **k)input.less_(...): less in place on input; returns input.
Riptorch extra: not in stock PyTorch.
less_equal_(input, *a, **k)input.less_equal_(...): less_equal in place on input; returns input.
Riptorch extra: not in stock PyTorch.
lgamma_(input, *a, **k)input.lgamma_(...): lgamma in place on input; returns input.
Riptorch extra: not in stock PyTorch.
log10_(input, *a, **k)input.log10_(...): log10 in place on input; returns input.
log1p_(input, *a, **k)input.log1p_(...): log1p in place on input; returns input.
log2_(input, *a, **k)input.log2_(...): log2 in place on input; returns input.
log_(input, *a, **k)input.log_(...): log in place on input; returns input.
logical_and_(input, *a, **k)input.logical_and_(...): logical_and in place on input; returns input.
Riptorch extra: not in stock PyTorch.
logical_not_(input, *a, **k)input.logical_not_(...): logical_not in place on input; returns input.
Riptorch extra: not in stock PyTorch.
logical_or_(input, *a, **k)input.logical_or_(...): logical_or in place on input; returns input.
Riptorch extra: not in stock PyTorch.
logical_xor_(input, *a, **k)input.logical_xor_(...): logical_xor in place on input; returns input.
Riptorch extra: not in stock PyTorch.
logit_(input, *a, **k)input.logit_(...): logit in place on input; returns input.
lt_(input, *a, **k)input.lt_(...): lt in place on input; returns input.
Riptorch extra: not in stock PyTorch.
masked_scatter_(input, *a, **k)input.masked_scatter_(...): masked_scatter in place on input; returns input.
Riptorch extra: not in stock PyTorch.
multiply_(input, *a, **k)input.multiply_(...): multiply in place on input; returns input.
Riptorch extra: not in stock PyTorch.
mvlgamma_(input, *a, **k)input.mvlgamma_(...): mvlgamma in place on input; returns input.
Riptorch extra: not in stock PyTorch.
nan_to_num_(input, *a, **k)input.nan_to_num_(...): nan_to_num in place on input; returns input.
ne_(input, *a, **k)input.ne_(...): ne in place on input; returns input.
Riptorch extra: not in stock PyTorch.
neg_(input, *a, **k)input.neg_(...): neg in place on input; returns input.
negative_(input, *a, **k)input.negative_(...): negative in place on input; returns input.
nextafter_(input, *a, **k)input.nextafter_(...): nextafter in place on input; returns input.
Riptorch extra: not in stock PyTorch.
not_equal_(input, *a, **k)input.not_equal_(...): not_equal in place on input; returns input.
Riptorch extra: not in stock PyTorch.
polygamma_(input, *a, **k)input.polygamma_(...): polygamma in place on input; returns input.
Riptorch extra: not in stock PyTorch.
pow_(input, *a, **k)input.pow_(...): pow in place on input; returns input.
Riptorch extra: not in stock PyTorch.
put_(input, *a, **k)input.put_(...): put in place on input; returns input.
Riptorch extra: not in stock PyTorch.
rad2deg_(input, *a, **k)input.rad2deg_(...): rad2deg in place on input; returns input.
reciprocal_(input, *a, **k)input.reciprocal_(...): reciprocal in place on input; returns input.
relu_(*a, **k)input.relu_(...): relu in place on input; returns input. A quantized input runs the quantized kernel (same parameters).
remainder_(input, *a, **k)input.remainder_(...): remainder in place on input; returns input.
Riptorch extra: not in stock PyTorch.
renorm_(input, *a, **k)input.renorm_(...): renorm in place on input; returns input.
Riptorch extra: not in stock PyTorch.
resize_as_(input, the_template, *, memory_format=None)Resizes in place to the template's shape (kept values in order, new ones zero).
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.
round_(input, *a, **k)input.round_(...): round in place on input; returns input.
rrelu_(input, lower=0.125, upper=0.3333333333333333, training=False, generator=None)In-place rrelu.
rsqrt_(input, *a, **k)input.rsqrt_(...): rsqrt in place on input; returns input.
sgn_(input, *a, **k)input.sgn_(...): sgn in place on input; returns input.
Riptorch extra: not in stock PyTorch.
sigmoid_(input, *a, **k)input.sigmoid_(...): sigmoid in place on input; returns input.
sign_(input, *a, **k)input.sign_(...): sign in place on input; returns input.
Riptorch extra: not in stock PyTorch.
sin_(input, *a, **k)input.sin_(...): sin in place on input; returns input.
sinc_(input, *a, **k)input.sinc_(...): sinc in place on input; returns input.
sinh_(input, *a, **k)input.sinh_(...): sinh in place on input; returns input.
sqrt_(input, *a, **k)input.sqrt_(...): sqrt in place on input; returns input.
square_(input, *a, **k)input.square_(...): square in place on input; returns input.
sub_(input, *a, **k)input.sub_(...): sub in place on input; returns input.
Riptorch extra: not in stock PyTorch.
subtract_(input, *a, **k)input.subtract_(...): subtract in place on input; returns input.
Riptorch extra: not in stock PyTorch.
tan_(input, *a, **k)input.tan_(...): tan in place on input; returns input.
tanh_(input, *a, **k)input.tanh_(...): tanh in place on input; returns input.
threshold_(input, threshold, value)In-place threshold: elements <= threshold become value.
tril_(input, *a, **k)input.tril_(...): tril in place on input; returns input.
Riptorch extra: not in stock PyTorch.
triu_(input, *a, **k)input.triu_(...): triu in place on input; returns input.
Riptorch extra: not in stock PyTorch.
true_divide_(input, *a, **k)input.true_divide_(...): true_divide in place on input; returns input.
Riptorch extra: not in stock PyTorch.
trunc_(input, *a, **k)input.trunc_(...): trunc in place on input; returns input.
xlogy_(input, *a, **k)input.xlogy_(...): xlogy in place on input; returns input.
More functions
adaptive_avg_pool1d(input, output_size)F.adaptive_avg_pool1d: averages over output_size equal-ish windows of the last dim (area interpolation).
adaptive_max_pool1d(input, output_size)Adaptive 1-d max pooling to output_size, always with the indices: (values, indices).
affine_grid_generator(theta, size, align_corners)F.affine_grid: the sampling grid of the affine maps theta for an output of shape size.
alias_copy(x, *a, **k)alias(...) as a new tensor (the view's copy: no memory shared with the input).
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).
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.
autocast_decrement_nesting()Decrements autocast's nesting counter; returns the new depth.
autocast_increment_nesting()Increments autocast's nesting counter; returns the new depth.
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.
backend() -> strNames the engine that runs large operations: the Metal GPU on a Mac with one (for example "riptide metal (Apple M1 Pro)"), otherwise "cpu".
batch_norm_backward_elemt(*a, **k)CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel).
batch_norm_backward_reduce(*a, **k)CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel).
batch_norm_elemt(*a, **k)CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel).
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).
batch_norm_stats(*a, **k)CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel).
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).
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.
ccol_indices_copy(x, *a, **k)ccol_indices(...) as a new tensor (the view's copy: no memory shared with the input).
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).
clamp_max(input, max)min(x, max). Dtypes: float32, float64, float16 and bfloat16 (autograd for the floating-point types).
classproperty(func)A read-only property of the class (and its instances).
clear_autocast_cache()Does nothing: Riptorch keeps no autocast weight cache.
col_indices_copy(x, *a, **k)col_indices(...) as a new tensor (the view's copy: no memory shared with the input).
constant_pad_nd(input, pad, value=0)Pads with a constant: pad lists (before, after) pairs from the last dim backwards, as F.pad.
conv_tbc(input, weight, bias, pad=0)Time x batch x channel convolution: input (T, B, Cin), weight (k, Cin, Cout), bias (Cout,).
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).
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).
cross_similarity(x1, x2, dim=1, eps=1e-08) -> TensorThe 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.
crow_indices_copy(x, *a, **k)crow_indices(...) as a new tensor (the view's copy: no memory shared with the input).
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).
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).
cudnn_batch_norm(input, *args, **kwargs)torch.cudnn_batch_norm: a cudnn kernel PyTorch on a Mac does not have (raises as PyTorch).
cudnn_convolution(input, *args, **kwargs)torch.cudnn_convolution: a cudnn kernel PyTorch on a Mac does not have (raises 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).
cudnn_convolution_relu(input, *args, **kwargs)torch.cudnn_convolution_relu: a cudnn kernel PyTorch on a Mac does not have (raises 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).
cudnn_grid_sampler(input, *args, **kwargs)torch.cudnn_grid_sampler: a cudnn kernel PyTorch on a Mac does not have (raises as PyTorch).
cudnn_is_acceptable(input)False for every tensor (no cuDNN on a Mac); TypeError for a non-tensor, as PyTorch.
detach(input)input.detach: the same values, no longer recording gradients.
detach_copy(input)detach(...) as a new tensor (the view's copy: no memory shared with the input).
diagonal_copy(input, offset=0, dim1=0, dim2=1)diagonal(...) as a new tensor (the view's copy: no memory shared with the input).
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.)
empty_permuted(size, physical_layout, *, dtype=None, **kw)A zero-filled tensor of size; physical_layout is ignored (contiguous layout).
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').
expand_copy(x, *a, **k)expand(...) as a new tensor (the view's copy: no memory shared with the input).
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).
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).
fbgemm_pack_gemm_matrix_fp16(*a, **k)FBGEMM fp16-weight linear: raises as PyTorch on arm64 (no FBGEMM).
fbgemm_pack_quantized_matrix(*a, **k)FBGEMM fp16-weight linear: raises as PyTorch on arm64 (no FBGEMM).
fill(input, value)A tensor like input filled with value (a number or a one-element tensor).
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).
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.
get_autocast_cpu_dtype()Deprecated (DeprecationWarning, as PyTorch): get_autocast_dtype('cpu').
get_autocast_gpu_dtype()Deprecated (DeprecationWarning, as PyTorch): get_autocast_dtype('cuda').
get_autocast_ipu_dtype()Deprecated (DeprecationWarning, as PyTorch): get_autocast_dtype('ipu').
get_autocast_xla_dtype()Deprecated (DeprecationWarning, as PyTorch): get_autocast_dtype('xla').
get_compat() -> str"riptorch" (the correct-by-default behaviour) or "pytorch" (stock behaviour), as set_compat set it.
get_device(x)-1, PyTorch's answer for a CPU tensor (Riptorch's memory is unified).
get_file_path(*path_components)A path inside the installed package.
get_float64() -> strWhere float64 graphs run now: "auto", "gpu", "cpu" or "fast".
get_int_matmul() -> strWhere exact integer matmuls run: "auto" (default), "gpu" or "cpu".
get_maths() -> strThe model maths set_maths chose: "transcendental" (the default) or "rational".
get_matmul() -> strThe precision set_matmul chose: "fp32" (default), "bf16", "fp16", "exact", "fast" or "high".
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.
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.
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.
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).
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'.
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.
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).
hsmm(mat1, mat2)torch.hsmm: hspmm (sparse @ dense as a hybrid COO tensor).
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).
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).
improvements(name=None, vs=None) -> list | dict | NoneEvery 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.
indices_copy(x, *a, **k)indices(...) as a new tensor (the view's copy: no memory shared with the input).
init_num_threads()Nothing to do: Riptorch's thread pools start on their own.
interpreter_stats() -> tuple(graphs, seconds): how many graphs the CPU reference interpreter ran in this process and the time spent there (normally 0).
is_anomaly_check_nan_enabled()False: anomaly detection is not tracked.
is_anomaly_enabled()False: anomaly detection is not tracked.
is_autocast_cache_enabled()The flag set_autocast_cache_enabled set (True by default).
is_autocast_cpu_enabled()Whether autocast is on for the CPU.
is_autocast_ipu_enabled()Deprecated (DeprecationWarning, as PyTorch): is_autocast_enabled('ipu').
is_autocast_xla_enabled()Deprecated (DeprecationWarning, as PyTorch): is_autocast_enabled('xla').
is_distributed(x)False: no tensor is distributed across processes.
is_inference(x)False: Riptorch has no inference tensors (inference_mode is no_grad).
is_signed(x)Whether x's dtype holds negative values (floats and signed integers).
is_torch_alias() -> boolTrue when import torch in this process gives Riptorch (Riptorch was imported first and registered itself under that name).
is_vulkan_available()False: no Vulkan backend (as PyTorch does on a Mac).
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.
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).
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').
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.)
margin_ranking_loss(*args, **kw)F.margin_ranking_loss: max(0, -target * (input1 - input2) + margin), reduced.
maths_config() -> dictThe current set_maths settings as a dict.
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.
maths_stats_reset()Forgets the Cayley clamp statistics recorded so far (call at the start of a step).
Riptorch extra: not in stock PyTorch.
matrix_rank(input, tol=None, symmetric=False, *, out=None) -> torch.TensorRemoved in PyTorch: raises its RuntimeError (use torch.linalg.matrix_rank).
matrix_unit() -> strThe 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).
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".
matrix_unit_status() -> dictThe matrix unit, its modes and whether its library loaded, as one dict (for bug reports).
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).
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).
miopen_batch_norm(input, *args, **kwargs)torch.miopen_batch_norm: a miopen kernel PyTorch on a Mac does not have (raises as PyTorch).
miopen_convolution(input, *args, **kwargs)torch.miopen_convolution: a miopen kernel PyTorch on a Mac does not have (raises 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).
miopen_convolution_relu(input, *args, **kwargs)torch.miopen_convolution_relu: a miopen kernel PyTorch on a Mac does not have (raises 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).
miopen_ctc_loss(input, *args, **kwargs)torch.miopen_ctc_loss: a miopen kernel PyTorch on a Mac does not have (raises 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).
miopen_rnn(input, *args, **kwargs)torch.miopen_rnn: a miopen kernel PyTorch on a Mac does not have (raises 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).
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).
mkldnn_max_pool2d(input, *args, **kwargs)torch.mkldnn_max_pool2d: a mkldnn kernel PyTorch on a Mac does not have (raises 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).
mkldnn_rnn_layer(input, *args, **kwargs)torch.mkldnn_rnn_layer: a mkldnn kernel PyTorch on a Mac does not have (raises 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).
native_channel_shuffle(input, groups)Shuffles the channels (dim 1) across groups: (N, g*k,...) read as (N, g, k,...) and transposed.
native_dropout(input, p, train)(output, mask): dropout with its keep mask (bool). train=False returns a copy and an all-True mask.
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).
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.
native_norm(*a, **k)CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel).
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).
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.
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.
nuclear_norm(input, dim=None, keepdim=False)Deprecated in PyTorch (its warning, once): sum of singular values over the last two dims (or dim).
parse_ir(input, parse_tensor_constants=False)A Graph from TorchScript's IR text form (graph inputs keep their names; node outputs are numbered).
parse_schema(schema, allow_typevars=True)FunctionSchema from text: ns::name.overload(Type name=default, *,...) -> ret.
parse_type_comment(comment)'# type: (int, float) -> int' as a declaration (argument and return types, as text).
permute_copy(input, *dims)permute(...) as a new tensor (the view's copy: no memory shared with the input).
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.
program_stats() -> tupleCounts for the last program that ran (its steps) and how many graphs ran so far: a diagnostic for performance reports.
q_per_channel_axis(input)The per-channel axis of a quantized tensor.
q_per_channel_scales(input)The per-channel scales of a quantized tensor.
q_per_channel_zero_points(input)The per-channel zero points of a quantized tensor.
q_zero_point(input)The zero point of a per-tensor quantized tensor.
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).
quantized_gru(input, hx, params, *a, **k)Legacy quantized GRU over FBGEMM-packed weights: raises as PyTorch on arm64 (no FBGEMM).
quantized_gru_cell(*a, **k)Legacy FBGEMM quantized GRU cell: raises as PyTorch on arm64 (no FBGEMM).
quantized_lstm(input, hx, params, *a, **k)Legacy quantized GRU over FBGEMM-packed weights: raises as PyTorch on arm64 (no FBGEMM).
quantized_lstm_cell(*a, **k)Legacy FBGEMM quantized GRU cell: raises as PyTorch on arm64 (no FBGEMM).
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).
quantized_rnn_relu_cell(*a, **k)Legacy FBGEMM quantized GRU cell: raises as PyTorch on arm64 (no FBGEMM).
quantized_rnn_tanh_cell(*a, **k)Legacy FBGEMM quantized GRU cell: raises as PyTorch on arm64 (no FBGEMM).
realizer_report() -> strWhere 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.
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)).
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).
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).
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).
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).
row_indices_copy(x, *a, **k)row_indices(...) as a new tensor (the view's copy: no memory shared with the input).
rsub(input, other, *, alpha=1)other - alpha * input (subtraction with the arguments reversed).
saddmm(input, mat1, mat2, *, beta=1, alpha=1, out=None)torch.saddmm: sspaddmm (beta * input + alpha * (mat1 @ mat2), sparse).
select_copy(*a, **k)select(...) as a new tensor (the view's copy: no memory shared with the input).
set_anomaly_enabled(enabled, check_nan=True)Accepted and ignored: anomaly detection is not tracked.
set_autocast_cache_enabled(enabled)Records whether autocast caches casts (Riptorch's autocast has no cast cache; the flag is kept).
set_autocast_cpu_dtype(dtype)Deprecated (DeprecationWarning, as PyTorch): set_autocast_dtype('cpu', dtype).
set_autocast_cpu_enabled(enabled)Deprecated (DeprecationWarning, as PyTorch): set_autocast_enabled('cpu', enabled).
set_autocast_dtype(device_type, dtype)Sets the dtype autocast uses on device_type.
set_autocast_gpu_dtype(dtype)Deprecated (DeprecationWarning, as PyTorch): set_autocast_dtype('cuda', dtype).
set_autocast_ipu_dtype(dtype)Deprecated (DeprecationWarning, as PyTorch): set_autocast_dtype('ipu', dtype).
set_autocast_ipu_enabled(enabled)Deprecated (DeprecationWarning, as PyTorch): set_autocast_enabled('ipu', enabled).
set_autocast_xla_dtype(dtype)Deprecated (DeprecationWarning, as PyTorch): set_autocast_dtype('xla', dtype).
set_autocast_xla_enabled(enabled)Deprecated (DeprecationWarning, as PyTorch): set_autocast_enabled('xla', enabled).
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.
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.
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.
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.
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.
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.
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).
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.
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.)
split_copy(*a, **k)split(...) as a new tensor (the view's copy: no memory shared with the input).
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).
spread(x1, x2, dim=1, eps=1e-08) -> TensorThe 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.
squeeze_copy(*a, **k)squeeze(...) as a new tensor (the view's copy: no memory shared with the input).
sspaddmm(input, mat1, mat2, *, beta=1, alpha=1, out=None)entries in every column of the rows mat1 has entries in (uncoalesced, as PyTorch).
sym_constrain_range(size, *, min=None, max=None)No-op on concrete sizes (PyTorch's runtime check only applies to symbolic ones).
sym_constrain_range_for_size(size, *, min=None, max=None)No-op on concrete sizes (PyTorch's runtime check only applies to symbolic ones).
sym_fresh_size(expr)The size itself (no symbolic sizes in Riptorch).
sym_int(a)int of a concrete number (symbolic ints don't occur in Riptorch).
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.)
t_copy(x, *a, **k)t(...) as a new tensor (the view's copy: no memory shared with the input).
to_dlpack(tensor)A DLPack capsule ("dltensor") of a CPU copy of tensor.
transpose_copy(*a, **k)transpose(...) as a new tensor (the view's copy: no memory shared with the input).
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).
unbind_copy(*a, **k)unbind(...) as a new tensor (the view's copy: no memory shared with the input).
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.
unfold_copy(input, dimension, size, step)unfold(...) as a new tensor (the view's copy: no memory shared with the input).
unify_type_list(types)The one type a list of types unifies to (None with T gives Optional[T]), or RuntimeError.
unsafe_split_with_sizes(input, *a, **k)input.unsafe_split_with_sizes(...).
unsqueeze_copy(*a, **k)unsqueeze(...) as a new tensor (the view's copy: no memory shared with the input).
values_copy(x, *a, **k)values(...) as a new tensor (the view's copy: no memory shared with the input).
view_as_complex_copy(x)view_as_complex(...) as a new tensor (the view's copy: no memory shared with the input).
view_as_real_copy(x)view_as_real(...) as a new tensor (the view's copy: no memory shared with the input).
view_copy(x, *a, **k)view(...) as a new tensor (the view's copy: no memory shared with the input).
weight_map(x, kind)w(x) of a weighting map, elementwise.
Riptorch extra: not in stock PyTorch.
weight_rate(x, kind)r(x) = w'(x) / w(x) of a weighting map, elementwise.
Riptorch extra: not in stock PyTorch.