# Riptorch reference (plain text) import riptorch as torch ## torch ### Tensors - get_default_device() [same] — torch.get_default_device: what set_default_device recorded, else device('cpu'). - get_default_dtype() [same] — torch.get_default_dtype: the dtype of new floating tensors (float32 unless set_default_dtype changed it). - is_complex(input) [same] — Whether the tensor's dtype is complex. - is_conj(x) [same] — False: Riptorch never keeps lazy conjugate or negation bits. - is_floating_point(input) [same] - is_neg(x) [same] — False: Riptorch never keeps lazy conjugate or negation bits. - is_nonzero(x) [same] — The truth value of a one-element tensor (more elements raise). - is_storage(obj) [same] — False: Riptorch tensors expose no separate storage objects here. - is_tensor(obj) [same] — Whether obj is a Riptorch tensor. - numel(input) [same] — The number of elements of the tensor. - set_default_device(device) [same] — torch.set_default_device: recorded (get_default_device returns it); every Riptorch tensor is in unified memory. - set_default_dtype(d) [same] — torch.set_default_dtype: the dtype of new floating tensors (float32 by default). - set_default_tensor_type(t) [same] — 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) [same] — Returns True and changes nothing (denormals are kept). - set_printoptions(precision=None, threshold=None, edgeitems=None, linewidth=None, profile=None, sci_mode=None) [same] — 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 d ### Creation ops - arange(start, end=None, step=1, *, dtype=None, device=None, requires_grad=False) [same] — int64 when start, end and step are all integers, else float32 (PyTorch's rule); [start, end) by step. - as_strided(input, size, stride, storage_offset=0) [same] — 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) [same] — data as a tensor: a tensor as it is (cast when dtype differs), a NumPy array through from_numpy, anything else through torch.tensor. - asarray(obj, *, dtype=None, device=None, copy=None, requires_grad=False) [same] — 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) [same] — torch.complex(real, imag): float32 parts give complex64, float64 parts complex128. - dequantize(input) [different] Different: 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 - empty(*size, dtype=None, device=None, requires_grad=False) [same] — empty is zeros here (PyTorch leaves the values unspecified). - empty_like(input, *, dtype=None, device=None, requires_grad=False, memory_format=None) [same] — empty_like / full_like / new_ones / new_zeros / new_full / new_empty / new_tensor - empty_strided(size, stride, *, dtype=None, **kw) [same] — 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) [same] — torch.eye(n, m=None). - from_dlpack(ext_tensor) [same] — A Riptorch tensor with the data of an object implementing the DLPack protocol (__dlpack__, e.g. - from_file(filename, shared=None, size=0, *, dtype=None, layout=None, device=None, pin_memory=False) [same] — 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) [same] — A tensor with the array's values, dtype and shape. - frombuffer(buffer, dtype=None, count=-1, offset=0) [same] — torch.frombuffer: a 1-d tensor over the buffer's values (copied). - full(size, fill_value, *, dtype=None, device=None, requires_grad=False) [same] — The dtype follows the fill value when none is given (bool, int64, float32), as in PyTorch. - full_like(input, fill_value, *, dtype=None, device=None, requires_grad=False, memory_format=None) [same] — Also accepts layout=, pin_memory=, names= (one unified memory; strided layout only). - heaviside(input, values, *, out=None) [same] — 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) [same] — steps values from start to end inclusive, evenly spaced. - logspace(start, end, steps, base=10.0, *, out=None, dtype=None, layout=None, device=None, requires_grad=False) [same] — base ** linspace(start, end, steps), computed in float64 and cast to dtype (the default dtype when none). - ones(*size, dtype=None, device=None, requires_grad=False) [same] — Ones of the given size (float32 unless dtype=). - ones_like(input, *, dtype=None, device=None, requires_grad=False) [same] — Ones with the input's shape (and dtype unless dtype= is given). - polar(abs, angle) [same] — torch.polar: abs (cos angle + i sin angle). - quantize_per_channel(input, scales, zero_points, axis, dtype) [same] — Quantize along axis with one scale / zero point per channel. - quantize_per_tensor(input, scale, zero_point, dtype) [different] Different: quantized integers are the exact quotient rounded half to even; PyTorch lands one step off on 5491 of 24000 values at the .5 boundaries - range(start=0, end=None, step=1, *, out=None, dtype=None, layout=None, device=None, requires_grad=False) [same] — 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) [same] — A 0-d tensor holding s, in dtype (the default dtype when none). - sparse_bsc_tensor(compressed_indices, plain_indices, values, size=None, *, dtype=None, device=None, pin_memory=False, requires_grad=False, check_invariants=None) [same] — 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) [same] — 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) [same] — 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) [same] — 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) [same] — 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) [same] — torch.sparse_csr_tensor: a sparse_csr tensor. - tensor(data, requires_grad=False, dtype=None, device=None) [same] — 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. - zeros(*size, dtype=None, device=None, requires_grad=False) [same] — empty is zeros here (PyTorch leaves the values unspecified). - zeros_like(input, *, dtype=None, device=None, requires_grad=False) [same] — Zeros with the input's shape (and dtype unless dtype= is given). ### Indexing, slicing, joining and mutating - adjoint(input) [same] — Conjugate transpose of the last two dims (a plain transpose for real tensors). - argwhere(input, *, as_tuple=False) [same] — 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) -> Tensor [same] — Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch. - chunk(Tensor self, int chunks, int dim=0) -> Tensor[] [same] — Splits into chunks of ceil(n / chunks) along dim (the last chunk may be smaller, or fewer chunks may come back), as PyTorch. - column_stack(tensors, *, out=None) [same] — 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) -> Tensor [same] — Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch. - concatenate(Tensor[] tensors, int dim=0) -> Tensor [same] — Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch. - conj(x) [same] — The complex conjugate (a real tensor is returned as it is). - diagonal_scatter(input, src, offset=0, dim1=0, dim2=1) [different] — A copy of a 2-d input with its offset diagonal replaced by src. Different: Only 2-d input with dims (0, 1) (or (-2, -1)); others raise NotImplementedError. - dsplit(input, sections) [same] — tensor_split along dim 2. - dstack(tensors, *, out=None) [same] — The tensors concatenated along dim 2, after atleast_3d. - gather(Tensor self, int dim, Tensor index, *, bool sparse_grad=False) -> Tensor [same] — out[i][j][k] = input[index[i][j][k]][j][k] along dim (any dtype). - hsplit(input, sections) [same] — tensor_split along dim 1 (dim 0 for a 1-d input). - hstack(tensors, *, out=None) [same] — 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] Different: repeated indices summed in float64 and rounded once: [1e8, 1, -1e8] at one index gives 1.0, PyTorch's float32 sum gives 0.0 - index_copy(input, dim, index, source) [same] — A copy of input with source's slices written at index along dim. - index_fill(input, dim, index, value) [same] — A copy of input with value written into the slices at index along dim. - index_put(input, indices, values, accumulate=False) [different] Different: accumulate=True sums repeated positions in float64 and rounds once: [1e8, 1, -1e8] at one position gives 1.0, PyTorch gives 0.0 - index_reduce(self, dim, index, source, reduce, *, include_self=True) [same] — 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. - index_select(*a, **k) [same] — The slices of input along dim at index (1-d, int); differentiable. - masked_fill(input, mask, value) [same] — value where mask is true, else the input; the result keeps the input's dtype. - masked_scatter(input, mask, source) [same] — 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) [same] — The elements of input where mask (broadcast with it) is True, as a 1-d tensor in row-major order. - moveaxis(input, source, destination) [same] — input with the dims at source moved to destination (ints or sequences), the others in order; a view. - movedim(*a, **k) [same] — input with the dims at source moved to destination (ints or sequences), the others in order; a view. - narrow(Tensor self, int dim, int start, int length) -> Tensor [same] — The slice [start, start + length) along dim. - narrow_copy(self, dim, start, length) [same] — narrow(dim, start, length) as a new tensor. - nonzero(input, *, as_tuple=False) [same] — 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) [same] — Reorders the dimensions. - put(input, index, source, accumulate=False) [same] — A copy of input with the flat positions index set to source's values (accumulate=True: added instead). - reshape(input, shape) [same] — input.reshape(shape). - row_stack(tensors, *, out=None) [same] — The tensors concatenated along dim 0, after atleast_2d (1-d tensors become rows). - scatter(input, dim, index, src=None, *, value=None, reduce=None) [same] — 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) [same] — scatter with reduce='add': repeated indices accumulate. - scatter_reduce(input, dim, index, src, reduce, *, include_self=True) [same] — 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. - segment_reduce(data, reduce, *, lengths=None, indices=None, offsets=None, axis=0, unsafe=False, initial=None) [same] — Reductions over consecutive segments of data along axis; lengths (or offsets) of shape (*lead, segments) with lead the dims of data before axis. - select(*a, **k) [same] — The slice at index along dim, with dim removed; negative indices count from the end; IndexError outside. - select_scatter(input, src, dim, index) [same] — A copy of input with input.select(dim, index) replaced by src. - slice_scatter(input, src, dim=0, start=None, end=None, step=1) [same] — 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[] [same] — Pieces are narrows: lazy views with gradients on float32 tensors. - split_with_sizes(input, split_sizes, dim=0) [same] — Consecutive pieces of input along dim with the given sizes, as a tuple. - squeeze(Tensor self, dim=None) -> Tensor [same] — Removes size-1 dimensions (all, or the given dim / dims when they have size 1). - stack(Tensor[] tensors, int dim=0) -> Tensor [same] — Joins tensors along a new dimension dim. - swapaxes(Tensor self, int dim0, int dim1) -> Tensor [same] — Swaps two dimensions (swapaxes too). - swapdims(Tensor self, int dim0, int dim1) -> Tensor [same] — Swaps two dimensions (swapaxes too). - t(input) [same] — Transpose of a tensor of at most 2 dims (0-d and 1-d come back as they are). - take(input, index) [same] — input's elements at the given flat indices (input read as 1-d), shaped like index. - take_along_dim(*a, **k) [same] — input's values at indices along dim, input and indices broadcast on the other dims; dim=None takes from the flattened input. - tensor_split(input, indices_or_sections, dim=0) [same] — 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) [same] — 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) -> Tensor [same] — Swaps two dimensions (swapaxes too). - unbind(*a, **k) [same] — A tuple of the slices along dim, each without dim. - unravel_index(indices, shape) [same] — The coordinates of flat indices in an array of the given shape (row-major), as a tuple of int64 tensors. - unsafe_chunk(input, *a, **k) [same] — input.unsafe_chunk(...). - unsafe_split(input, *a, **k) [same] — input.unsafe_split(...). - unsqueeze(Tensor self, int dim) -> Tensor [same] — Inserts a size-1 dimension at dim (negative dims count from the end of the result). - vsplit(input, sections) [same] — tensor_split along dim 0. - vstack(tensors, *, out=None) [same] — The tensors concatenated along dim 0, after atleast_2d (1-d tensors become rows). - where(condition, input=None, other=None) [same] ### Random sampling - bernoulli(input, p=None, *, generator=None, out=None) [same] — torch.bernoulli: 1 with probability input (or p), as input's dtype. - binomial(count, prob, generator=None) [same] — torch.binomial: a Binomial(count, prob) draw per element. - default_generator [same] - Generator(device='cpu') [same] — torch.Generator: its own random stream. - get_rng_state() [same] — 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() [same] — The seed of the default generator (the one manual_seed set). - manual_seed(seed) [same] — 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) [same] — torch.multinomial: indices drawn by the (unnormalised, non-negative) weights in each row of input (1-d or 2-d); int64. - normal(mean=0.0, std=1.0, size=None, *, generator=None, out=None, dtype=None, device=None, requires_grad=False) [same] — torch.normal(mean, std[, size]): tensors broadcast, or floats with a size. - poisson(input, generator=None) [same] — torch.poisson: a Poisson draw per rate (input's dtype). - rand(*size, generator=None, dtype=None, device=None, requires_grad=False) [same] — Uniform draws in [0, 1) from the default generator (or generator=). - rand_like(input, *, dtype=None, layout=None, device=None, requires_grad=False, memory_format=None) [same] — torch.rand_like: uniform [0, 1) draws with input's shape, in dtype (default input's dtype). - randint(low, high=None, size=(), dtype=None, device=None, generator=None) [same] — torch.randint: integers in [low, high), int64 unless dtype says otherwise. - randint_like(input, low=0, high=None, *, dtype=None, layout=None, device=None, requires_grad=False, memory_format=None) [same] — torch.randint_like(input, [low,] high): integers in [low, high) with input's shape, in dtype (default input's dtype). - randn(*size, generator=None, dtype=None, device=None, requires_grad=False) [same] — Standard normal draws from the default generator (or generator=). - randn_like(input, *, dtype=None, device=None, requires_grad=False) [same] — Standard normal draws with the input's shape. - randperm(n, *, generator=None, dtype=None, device=None, requires_grad=False) [same] — Also accepts layout=, pin_memory=, memory_format=, names= (one unified memory; strided layout only). - seed() [same] — torch.seed: seeds with a non-deterministic number and returns it. - set_rng_state(new_state) [same] — 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) [same] — torch.load: PyTorch's zip and legacy formats, and safetensors files. - save(obj, f, pickle_module=, pickle_protocol=2, _use_new_zipfile_serialization=True, _disable_byteorder_record=False) [same] — torch.save: PyTorch's zip format (or the legacy format with _use_new_zipfile_serialization=False). ### Parallelism - get_num_interop_threads() [same] — torch.get_num_interop_threads: the recorded value, else os.cpu_count. - get_num_threads() [same] — 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) [same] — torch.set_num_interop_threads: recorded for get_num_interop_threads (Riptorch has no inter-op pool). - set_num_threads(n) [same] ### Gradient mode - enable_grad(orig_func=None) [same] — with torch.enable_grad: ops record gradients again inside no_grad (LBFGS closures). - inference_mode(mode=True) [same] — torch.inference_mode(mode=True): no gradients recorded (as no_grad); a context manager and a decorator. - is_grad_enabled() [same] — Whether gradient recording is on (no_grad / enable_grad / set_grad_enabled change it). - is_inference_mode_enabled() [same] — Whether an inference_mode block is active. - no_grad(orig_func=None) [same] — with torch.no_grad: ops don't record gradients. - set_grad_enabled(mode) [same] — 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) [same] — Elementwise absolute value. - absolute(input) [same] — Elementwise absolute value. - acos(input, *, out=None) [same] — Arccosine, elementwise, as atan2(sqrt(1 - x^2), x); differentiable. - acosh(input) [same] — Inverse hyperbolic cosine (NaN below 1). - add(input, other, *, alpha=1) [same] — self + alpha * other, with broadcasting and PyTorch type promotion. - addcdiv(input, tensor1, tensor2, *, value=1) [same] — input + value * tensor1 / tensor2. - addcmul(input, tensor1, tensor2, *, value=1) [same] — input + value * tensor1 * tensor2. - alpha_dropout(input, p, train) [same] — Alpha dropout (keeps SELU's mean and variance) when train is True; the input otherwise. - angle(x) [same] — The argument atan2(imag, real) of each complex value (0 or pi for real values). - arccos(input, *, out=None) [same] — Arccosine, elementwise, as atan2(sqrt(1 - x^2), x); differentiable. - arccosh(input) [same] — Inverse hyperbolic cosine (NaN below 1). - arcsin(input, *, out=None) [same] — Arcsine, elementwise, as atan2(x, sqrt(1 - x^2)); differentiable. - arcsinh(input) [same] — Inverse hyperbolic sine. - arctan(input, *, out=None) [same] — 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) [same] — The angle of (other, input) in (-pi, pi], quadrant by quadrant from atan. - arctanh(input) [same] — Inverse hyperbolic tangent (inf at +-1, NaN outside). - asin(input, *, out=None) [same] — Arcsine, elementwise, as atan2(x, sqrt(1 - x^2)); differentiable. - asinh(input) [same] — Inverse hyperbolic sine. - atan(input, *, out=None) [same] — 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) [same] — The angle of (other, input) in (-pi, pi], quadrant by quadrant from atan. - atanh(input) [same] — Inverse hyperbolic tangent (inf at +-1, NaN outside). - bitwise_and(input, other) [same] — Bitwise AND of integers, logical AND of bools (also &, and torch.logical_and on bool casts). - bitwise_left_shift(input, other, *, out=None) [same] — Shift left: input << other, elementwise on integers, wrapping to input's width as PyTorch. - bitwise_not(input) [same] — Bitwise NOT of integers, logical NOT of bools (also ~, and logical_not on bool casts). - bitwise_or(input, other) [same] — Bitwise OR of integers, logical OR of bools (also |, and torch.logical_or on bool casts). - bitwise_right_shift(input, other, *, out=None) [same] — Shift right: input >> other (arithmetic for signed types), elementwise on integers, wrapping to input's width as PyTorch. - bitwise_xor(input, other) [same] — Bitwise XOR of integers, logical XOR of bools (also ^). - ceil(input) [same] — Rounds up to an integer value (the dtype is kept). - celu(input, alpha=1.0, inplace=False) [same] — max(0, x) + min(0, alpha * (exp(x / alpha) - 1)). - clamp(input, min=None, max=None) [same] — Limits values to [min, max] (either may be None; clip too). - clip(input, min=None, max=None) [same] — Limits values to [min, max] (either may be None; clip too). - conj_physical(x) [same] — The complex conjugate (a real tensor is returned as it is). - copysign(input, other, *, out=None) [same] — abs(input) with the sign of other, elementwise (other's sign bit decides, so -0.0 counts as negative); float. - cos(input) [different] Different: 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) - cosh(input) [same] — Hyperbolic cosine. - deg2rad(input) [same] — Degrees to radians. - digamma(input, *, out=None) [different] Different: 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 - div(input, other, *, rounding_mode=None) [same] — Division, true by default; rounding_mode="trunc" or "floor" rounds the quotient. - divide(input, other, *, rounding_mode=None) [same] — Division, true by default; rounding_mode="trunc" or "floor" rounds the quotient. - dropout(input, p=0.5, training=True, inplace=False) [same] — nn.Dropout passes training=self.training. - erf(input) [same] — The error function. - erfc(input) [same] — 1 - erf(x), accurate in the upper tail. - erfinv(input, *, out=None) [different] Different: 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 - exp(input) [same] — Elementwise e^x. - exp2(input) [same] — Elementwise 2^x. - expm1(input) [same] — 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) [same] — Per-channel fake quantization along axis (straight-through gradients). - fake_quantize_per_tensor_affine(input, scale, zero_point, quant_min, quant_max) [different] Different: exact quotient rounding and one-rounding dequantization; PyTorch differs on 1026 of 4000 boundary-heavy values - feature_alpha_dropout(input, p, train) [same] — Alpha dropout of whole channels (dim 1) when train is True; the input otherwise. - feature_dropout(input, p, train) [same] — Dropout of whole channels (dim 1, one draw per batch x channel), survivors scaled by 1 / (1 - p). - fix(input) [same] — Rounds toward zero (fix too). - float_power(input, exponent) [same] — 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) [same] — Rounds down to an integer value (the dtype is kept). - floor_divide(input, other, *, out=None) [same] — Division rounded down (torch.div with rounding_mode='floor'); integers stay integers. - fmod(input, other, *, out=None) [same] — C's fmod, the dividend's sign. - frac(input) [same] — x - trunc(x), keeping the sign. - frexp(input, *, out=None) [same] — (mantissa, exponent) with input = mantissa * 2**exponent and 0.5 <= |mantissa| < 1 (0 for 0). - gradient(input, *, spacing=1, dim=None, edge_order=1) [same] — 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) [same] — x where |x| > lambd, else 0. - hypot(input, other) [same] — sqrt(a^2 + b^2) elementwise. - i0(input, *, out=None) [different] Different: correctly rounded float32 values (computed in float64, rounded once); 1500 inputs in [0, 75]: worst 3 ulp vs 0; MLX has no i0 - igamma(input, other, *, out=None) [same] — The regularized lower incomplete gamma function P(a, x) (input a, other x), in float64 and rounded once. - igammac(input, other, *, out=None) [same] — The regularized upper incomplete gamma function Q(a, x) = 1 - P(a, x), in float64 and rounded once. - imag(x) [same] — The imaginary part of a complex tensor. - ldexp(input, other, *, out=None) [same] — input * 2**other, elementwise, as a float tensor. - lerp(input, end, weight) [same] — input + weight * (end - input). - lgamma(input, *, out=None) [same] — log|Gamma(x)|, per element: computed in float64 and rounded once to the input's float dtype (integer inputs give float32); differentiable. - log(input) [same] — Elementwise natural log (-inf at 0, NaN below 0). - log10(input) [same] — Elementwise log base 10. - log1p(input) [same] — 2 atanh(x / (2 + x)) below 1/4, log(1 + x) with the rounding of 1 + x put back above. - log2(input) [same] — Elementwise log base 2. - log_softmax(Tensor input, int? dim=None, *, dtype? dtype=None) -> Tensor [same] — log(softmax(x)) along dim, computed stably (x - logsumexp); dtype= casts the input first. - logaddexp(input, other) [same] — log(exp(a) + exp(b)) computed stably. - logaddexp2(input, other, *, out=None) [same] — log2(2^input + 2^other) without overflow: max + log2(1 + 2^-|input - other|). - logical_and(*args, **kw) [same] — logical_and: the inputs as bool, then bitwise_and (a bool result, as PyTorch's logical ops). - logical_not(*args, **kw) [same] — logical_not: the inputs as bool, then bitwise_not (a bool result, as PyTorch's logical ops). - logical_or(*args, **kw) [same] — logical_or: the inputs as bool, then bitwise_or (a bool result, as PyTorch's logical ops). - logical_xor(input, other, *, out=None) [same] — Elementwise XOR of the inputs' truth values (nonzero is True); bool. - logit(input) [same] — log(x / (1 - x)). - mul(input, other) [same] — Elementwise product, with broadcasting and PyTorch type promotion. - multiply(input, other) [same] — Elementwise product, with broadcasting and PyTorch type promotion. - mvlgamma(input, p, *, out=None) [same] — 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) [same] — NaN, +inf and -inf replaced by nan, posinf and neginf (default: 0 and the dtype's largest / smallest finite values). - neg(input) [same] — -x. - negative(input) [same] — -x (alias of neg). - nextafter(input, other, *, out=None) [same] — 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) [same] — polygamma(n, x): the n-th derivative of digamma. - positive(input) [same] — x unchanged. - pow(input, exponent) [same] — 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) [same] — 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) [same] — 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) [same] — 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) [same] — 2-d max pooling of a quantized tensor, on its integers (exact; the same parameters). - rad2deg(input) [same] — Radians to degrees. - real(x) [same] — The real part of a complex tensor (a real tensor is returned as it is). - reciprocal(input) [same] — 1 / x. - relu(Tensor self, bool inplace=False) -> Tensor [same] — max(x, 0). - remainder(input, other, *, out=None) [different] Different: 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) - round(input) [same] — Halves to even, as PyTorch. - rrelu(input, lower=0.125, upper=0.3333333333333333, training=False, generator=None) [same] — Randomized leaky ReLU: slope drawn from U(lower, upper) per element when training, (lower + upper) / 2 otherwise. - rsqrt(input) [same] — Classic only: as an elementwise op it has no rational form (the rational RMSNorm is a module-level row). - selu(input, inplace=False) [same] — scale * elu(x, alpha) with the SELU constants. - sgn(input) [same] — -1, 0 or 1 by sign (sgn too). - sigmoid(input, *, maths=None) [same] — 1 / (1 + exp(-x)). - sign(input) [same] — -1, 0 or 1 by sign (sgn too). - signbit(input, *, out=None) [same] — True where the sign bit is set: negative values and -0.0 (integers: x < 0). - sin(input) [different] Different: 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) - sinc(input, *, out=None) [same] - sinh(input) [same] — Hyperbolic sine. - softmax(Tensor input, int? dim=None, *, dtype? dtype=None) -> Tensor [same] — Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch. - sqrt(input) [same] — Elementwise square root (NaN below 0). - square(input) [same] — x * x. - sub(input, other, *, alpha=1) [same] — self - alpha * other, with broadcasting and PyTorch type promotion. - subtract(input, other, *, alpha=1) [same] — self - alpha * other, with broadcasting and PyTorch type promotion. - tan(input) [same] — Elementwise tangent. - tanh(input, *, maths=None) [same] - threshold(input, threshold, value, inplace=False) [same] — x where x > threshold, else value. - true_divide(input, other, *, rounding_mode=None) [same] — Division, true by default; rounding_mode="trunc" or "floor" rounds the quotient. - trunc(input) [same] — Rounds toward zero (fix too). - xlogy(input, other) [same] — x * log(y), 0 where x is 0. ### Reductions - all(Tensor self, int? dim=None, bool keepdim=False) -> Tensor [same] — Whether every element is nonzero, over all elements or along dim; returns bool. - amax(Tensor self, int[] dim=[], bool keepdim=False) -> Tensor [same] — Maximum along the given dims (all dims when empty); gradients split evenly between tied maxima, as PyTorch. - amin(Tensor self, int[] dim=[], bool keepdim=False) -> Tensor [same] — Minimum along the given dims (all dims when empty); gradients split evenly between tied minima, as PyTorch. - aminmax(input, *, dim=None, keepdim=False) [same] — (min, max) over dim, or over all elements when dim is None. - any(Tensor self, int? dim=None, bool keepdim=False) -> Tensor [same] — Whether any element is nonzero, over all elements or along dim; returns bool. - argmax(Tensor self, int? dim=None, bool keepdim=False) -> Tensor [same] — The first index of the maximum (as PyTorch), int64. - argmin(Tensor self, int? dim=None, bool keepdim=False) -> Tensor [same] — Index of the minimum over the flattened tensor or along dim (the first one on ties); int64. - count_nonzero(*a, **k) [same] — The number of non-zero entries (int64), over all or along dim (an int or a tuple). - dist(input, other, p=2) [same] — The p-norm (default 2) of input - other over all elements. - logsumexp(input, dim=None, keepdim=False, *, out=None) [different] Different: dim=[] reduces every dim, as sum(dim=[]) does; PyTorch CPU and MPS raise RuntimeError - max(*a, **k) [same] — max(Tensor self, dim=None, bool keepdim=False) - mean(Tensor self, int[]? dim=None, bool keepdim=False, *, dtype? dtype=None) -> Tensor [same] — Mean over all elements or along dim; dtype= casts first. - median(input, dim=None, keepdim=False, *, out=None) [same] — The lower median (PyTorch's: not the mean of the two middle values), and with dim its index; NaN propagates. - min(*a, **k) [same] — min(Tensor self, dim=None, bool keepdim=False) - mode(input, dim=-1, keepdim=False, *, out=None) [same] — 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) [same] — Mean of the non-NaN elements, over dim or over all elements (NaN where every element is NaN). - nanmedian(input, dim=None, keepdim=False, *, out=None) [same] — The lower median of the non-NaN elements (NaN only when all are NaN); with dim, (values, indices). - nanquantile(input, q, dim=None, keepdim=False, *, interpolation='linear', out=None) [same] — quantile ignoring NaN: NaN only where a row has no other values. - nansum(input, dim=None, keepdim=False, *, dtype=None) [same] — Sum with NaN counted as zero, over dim or over all elements. - norm(input, p: float | str | None = 'fro', dim=None, keepdim=False, out=None, dtype=None) [same] — 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. - prod(input, dim=None, keepdim=False, *, dtype=None) [same] — Product of the elements, over dim or over all of them; dtype= casts first. - quantile(input, q, dim=None, keepdim=False, *, interpolation='linear', out=None, _nan=False) [same] — The q-th quantiles (q a float or a 1-d tensor, each in [0, 1]) over dim or over all elements. - std(input, dim=None, unbiased=None, keepdim=False, *, correction=None, out=None) [same] — Standard deviation over dim (all elements when dim is None): the square root of torch.var. - std_mean(input, dim=None, *, correction=1, keepdim=False, out=None) [same] — (std, mean) over dim (all elements when dim is None), std with correction (default 1). - sum(*a, **k) [different] Different: 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) - unique(input, sorted=True, return_inverse=False, return_counts=False, dim=None) [same] — The distinct values (or distinct slices along dim), sorted; optionally the inverse indices and the counts. - unique_consecutive(input, return_inverse=False, return_counts=False, dim=None) [different] — input with runs of equal consecutive values collapsed to one; optionally the inverse indices and run lengths. Different: 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) -> Tensor [same] — Variance over all elements or along dim with Bessel's correction (correction=, or unbiased=). - var_mean(input, dim=None, *, correction=1, keepdim=False, out=None) [same] — (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) [same] — Whether isclose holds everywhere; a Python bool. - argsort(Tensor self, int dim=-1, bool descending=False, *, bool stable=False) -> Tensor [same] — Indices that sort along dim (descending= for largest first); ties keep their original order. - eq(input, other) [same] — Elementwise ==, with broadcasting and PyTorch type promotion; returns bool. - equal(*a, **k) [same] — True if both tensors have the same shape and the same values. - fmax(input, other, *, out=None) [same] — Elementwise maximum ignoring NaN: where one side is NaN the other is returned (NaN only when both are). - fmin(input, other, *, out=None) [same] — Elementwise minimum ignoring NaN: where one side is NaN the other is returned (NaN only when both are). - ge(input, other) [same] — Elementwise >=, with broadcasting and PyTorch type promotion; returns bool. - greater(input, other) [same] — Elementwise >, with broadcasting and PyTorch type promotion; returns bool. - greater_equal(input, other) [same] — Elementwise >=, with broadcasting and PyTorch type promotion; returns bool. - gt(input, other) [same] — Elementwise >, with broadcasting and PyTorch type promotion; returns bool. - isclose(input, other, rtol=1e-05, atol=1e-08, equal_nan=False) [same] — |input - other| <= atol + rtol * |other| elementwise (equal_nan=True counts NaN == NaN); returns bool. - isfinite(input) [same] — 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) [same] — Whether each element occurs in test_elements (invert=True negates); returns bool. - isinf(input) [same] — True where the element is +inf or -inf (always False for integer and bool tensors). - isnan(input) [same] — Tensor.isnan / torch.isnan: True where the element is NaN (x != x); always False for integer and bool tensors. - isneginf(x) [same] — True where the element is -inf. - isposinf(x) [same] — True where the element is +inf. - isreal(x) [same] — 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) [same] — The k-th smallest (1-based); among equal values the one the stable order puts k-th. - le(input, other) [same] — Elementwise <=, with broadcasting and PyTorch type promotion; returns bool. - less(input, other) [same] — Elementwise <, with broadcasting and PyTorch type promotion; returns bool. - less_equal(input, other) [same] — Elementwise <=, with broadcasting and PyTorch type promotion; returns bool. - lt(input, other) [same] — Elementwise <, with broadcasting and PyTorch type promotion; returns bool. - maximum(input, other) [same] — Elementwise maximum of two tensors; a NaN in either input gives NaN, as in PyTorch. - minimum(input, other) [same] — Elementwise minimum of two tensors; a NaN in either input gives NaN, as in PyTorch. - msort(input) [same] — Sorts along dim 0 (ascending). - ne(input, other) [same] — Elementwise !=, with broadcasting and PyTorch type promotion; returns bool. - not_equal(input, other) [same] — Elementwise !=, with broadcasting and PyTorch type promotion; returns bool. - sort(Tensor self, int dim=-1, bool descending=False, *, bool? stable=False) -> (Tensor values, Tensor indices) [same] — Always stable (equal values keep their order), so stable=False gives the stable order too. - topk(Tensor self, int k, int dim=-1, bool largest=True, bool sorted=True) -> (Tensor values, Tensor indices) [same] — Partial selection on every core (no full sort for small k) or the GPU; values keep gradients. ### Spectral and windows - bartlett_window(window_length, periodic=True, **kw) [same] — Bartlett (triangular) window 1 - |2 i / (N - 1) - 1| of window_length samples. - blackman_window(window_length, periodic=True, **kw) [same] — Blackman window 0.42 - 0.5 cos(2 pi i / (N - 1)) + 0.08 cos(4 pi i / (N - 1)) of window_length samples. - hamming_window(window_length, periodic=True, alpha=0.54, beta=0.46, **kw) [same] — Hamming window alpha - beta cos(2 pi i / (N - 1)) (alpha 0.54, beta 0.46) of window_length samples. - hann_window(window_length, periodic=True, **kw) [same] — Hann window 0.5 - 0.5 cos(2 pi i / (N - 1)) of window_length samples. - istft(input, n_fft, hop_length=None, win_length=None, window=None, center=True, normalized=False, onesided=None, length=None, return_complex=False) [same] — Inverse of stft: the inverse FFT of each frame, windowed, overlap-added and divided by the summed squared window. - kaiser_window(window_length, periodic=True, beta=12.0, **kw) [same] — Kaiser window I0(beta sqrt(1 - (2 i / (N - 1) - 1)^2)) / I0(beta) (beta 12 by default) of window_length samples. - 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) [same] — Short-time Fourier transform of a 1-d signal or a batch of them, through torch.fft. ### Other operations - atleast_1d(*tensors) [same] — Each tensor with at least one dim (0-d becomes shape (1,)); one tensor in gives one out, several a tuple. - atleast_2d(*tensors) [same] — 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) [same] — 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) [same] — 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) [same] — The aten argument order of F.batch_norm; cudnn_enabled is ignored. - bincount(input, weights=None, minlength=0) [same] — 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) [same] — A block-diagonal matrix from the tensors (0-d and 1-d become one row), in the first tensor's dtype. - broadcast_shapes(*shapes) [same] — The shape the given shapes broadcast to; RuntimeError when they don't, as PyTorch. - broadcast_tensors(*tensors) [same] — The tensors expanded to their common broadcast shape; also broadcast_shapes and broadcast_to. - broadcast_to(input, size) [same] — The tensor expanded to size (-1 keeps a dim), a broadcast view. - bucketize(input, boundaries, *, out_int32=False, right=False, out=None) [same] — 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) [same] — 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) [same] — All pairwise p-distances between the rows of x1 [.., P, M] and x2 [.., R, M] -> [.., P, R]. - channel_shuffle(input, groups) [same] — Shuffles the channels (dim 1) across groups: (N, g*k,...) read as (N, g, k,...) and transposed. - clone(input, *, memory_format=None) [same] - combinations(input, r=2, with_replacement=False) [same] — 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] - conv2d(input, weight, bias=None, stride=(1,), padding=(0,), dilation=(1,), groups=1) [same] — 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] - conv_transpose1d(input, weight, bias=None, stride=(1,), padding=(0,), output_padding=(0,), groups=1, dilation=(1,)) [same] - conv_transpose2d(input, weight, bias=None, stride=(1,), padding=(0,), output_padding=(0,), groups=1, dilation=(1,)) [same] - conv_transpose3d(input, weight, bias=None, stride=(1,), padding=(0,), output_padding=(0,), groups=1, dilation=(1,)) [same] - corrcoef(input) [same] — 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] - cov(input, *, correction=1, fweights=None, aweights=None) [same] — The covariance matrix of the rows (variables) of input over its columns (observations); correction=1 is Bessel's; fweights / aweights weight the observations. - cross(input, other, dim=-1) [same] — The 3-d cross product along dim (size 3), broadcasting. - cummax(input, dim) [same] — Running maximum along dim and the index where it was reached, as (values, indices). - cummin(input, dim) [same] — Running minimum along dim and the index where it was reached, as (values, indices). - cumprod(*a, **k) [same] — Products along dim: for float32, a sequential product of slices (differentiable). - cumsum(*a, **k) [same] — The cumulative sum along dim, in dtype if given (integer inputs sum exactly); 0-d and 1-d inputs too. - diag(input, diagonal=0) [same] — 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) [different] — A matrix (per leading index) with input on diagonal offset; dim1=-2, dim2=-1 only (others raise NotImplementedError). Different: A matrix (per leading index) with input on diagonal offset; dim1=-2, dim2=-1 only (others raise NotImplementedError). - diagflat(input, offset=0) [same] — 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) [same] — Tensor.diagonal / torch.diagonal: the diagonal at offset between dim1 and dim2, moved to the last dim (gradients flow). - diff(*a, **k) [same] — The n-th forward difference along dim, after prepend / append are joined on; bool inputs use !=. - einsum(equation, *operands) [same] — 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) [same] — 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) [same] — (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) -> Tensor [same] — A reshape (the dims from start_dim to end_dim become one). - flip(*a, **k) [same] — input reversed along each of dims (an int or a sequence); a copy, as PyTorch. - fliplr(input) [same] — input reversed along dim 1 (left / right). - flipud(input) [same] — input reversed along dim 0 (up / down). - gcd(input, other, *, out=None) [same] — 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) [same] — Normalises each group of channels over its channels and spatial dims, then applies weight and bias per channel. - histc(input, bins=100, min=0, max=0, *, out=None) [same] — Counts in `bins` equal-width bins over [min, max] (the data's range when min == max); values outside and nan are skipped. - histogram(input, bins=100, *, range=None, weight=None, density=False, out=None) [same] — (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) [same] — 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 i - 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) [same] — Each (sample, channel) normalised over its spatial dims (or by running statistics with use_input_stats=False). - kron(input, other, *, out=None) [same] — 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) [same] — Over the last len(normalized_shape) dims; weight / bias of that shape (or none). - lcm(input, other, *, out=None) [same] — Elementwise least common multiple of integer tensors (0 where either is 0), in the first input's dtype. - logcumsumexp(*a, **k) [same] — log(cumsum(exp(input))) along dim, shifted by the maximum so large values don't overflow; integer inputs give float32 (PyTorch raises for them). - max_pool1d(*a, **k) [same] — 1-d max pooling (aten form: stride= means kernel_size). - max_pool2d(Tensor input, int[] kernel_size, int[] stride=(), int[] padding=(0,), int[] dilation=(1,), bool ceil_mode=False, bool return_indices=False) -> Tensor [different] — Any window, stride and padding (padding counts as -inf): the max over the kh x kw shifted strided slices. Different: 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) [same] — 3-d max pooling (aten form: stride= means kernel_size). - meshgrid(*tensors, indexing=None) [same] — 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). - pairwise_distance(x1, x2, p=2.0, eps=1e-06, keepdim=False, *, maths=None) [same] — ||x1 - x2 + eps||_p along the last dim (PyTorch adds eps to the difference). - pdist(input, p=2) [same] — Pairwise p-norm distances between the rows of a 2-d tensor (the upper triangle, row by row). - pixel_shuffle(input, upscale_factor) [same] — Rearranges (C r^2, H, W) to (C, H r, W r). - pixel_unshuffle(input, downscale_factor) [same] — Rearranges (C, H r, W r) to (C r^2, H, W). - ravel(input) [same] — input flattened to 1-d. - renorm(input, p, dim, maxnorm) [same] — 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) -> Tensor [same] — Repeats each element repeats times along dim (flattened when dim is None); per-element repeat counts raise NotImplementedError. - resolve_conj(x) [same] — x: there is never a lazy conjugate or negation to resolve. - resolve_neg(x) [same] — x: there is never a lazy conjugate or negation to resolve. - roll(Tensor input, int[] shifts, int[] dims=()) -> Tensor [same] — Each dim rotated by its shift: two narrows joined by cat. - rot90(input, k=1, dims=(0, 1)) [same] — 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) [same] — 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) [same] — The sum of products over dims: an int (a's last dims with b's first) or two lists of dims; one matmul. - trace(input) [same] — The sum of the main diagonal. - tril(input, diagonal=0, *, out=None) [same] — The upper triangle of the last two dims (on and above the diagonal-th diagonal), the rest zeros. - tril_indices(row, col, offset=0, *, dtype=None, device=None, layout=None) [same] — A 2 x K int64 tensor of the (row, col) positions of the lower triangle (col - row <= offset), row by row. - triu(input, diagonal=0, *, out=None) [same] — The upper triangle of the last two dims (on and above the diagonal-th diagonal), the rest zeros. - triu_indices(row, col, offset=0, *, dtype=None, device=None, layout=None) [same] — A 2 x K int64 tensor of the (row, col) positions of the upper triangle (col - row >= offset), row by row. - unflatten(input, dim, sizes) [same] — input with dim replaced by the given sizes (one of them may be -1). - vander(x, N=None, increasing=False) [same] — torch.vander(x, N=None, increasing=False): decreasing powers by default (unlike linalg.vander). - view_as_complex(x) [same] — A complex tensor over a float32 / float64 tensor whose last dim is 2 (real, imaginary), without a copy. - view_as_real(x) [same] — 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) [same] — beta * input + alpha * sum over the batch of batch1[i] @ batch2[i]. - addmm(input, mat1, mat2, *, beta=1, alpha=1) [same] — beta * self + alpha * (mat1 @ mat2). - addmv(input, mat, vec, *, beta=1, alpha=1, out=None) [same] — beta * input + alpha * (mat @ vec). - addr(input, vec1, vec2, *, beta=1, alpha=1, out=None) [same] — beta * input + alpha * outer(vec1, vec2). - baddbmm(input, batch1, batch2, *, beta=1, alpha=1, out=None) [same] — beta * input + alpha * (batch1 @ batch2), batched. - bmm(input, mat2, *, out=None) [same] — mm / bmm / mv / dot / inner / outer / addmv / baddbmm / einsum - chain_matmul(*matrices, out=None) [same] — torch.chain_matmul (deprecated in PyTorch): linalg.multi_dot of the matrices. - cholesky(A, upper=False, *, out=None) [same] — torch.cholesky (deprecated in PyTorch): linalg.cholesky(A, upper=upper). - cholesky_inverse(L, upper=False, *, out=None) [same] — torch.cholesky_inverse(L, upper=False): (L L^T)^-1 (or (U^T U)^-1). - cholesky_solve(B, L, upper=False, *, out=None) [same] — torch.cholesky_solve(B, L, upper=False): solves A X = B with A = L L^T (or U^T U). - cumulative_trapezoid(y, x=None, *, dx=None, dim=-1) [same] — 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] - dot(input, other, *, out=None) [same] — The dot product of two 1-d tensors. - geqrf(A, *, out=None) [same] - ger(input, vec2, *, out=None) [same] — The outer product of two vectors (ger too). - inner(input, other, *, out=None) [same] — Inner product over the last dims (a scalar input multiplies). - inverse(A, *, out=None) [same] — 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] Different: 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 - logdet(A) [same] — torch.logdet(A): log det A (nan for a negative determinant, -inf for zero). - lu(A, pivot=True, get_infos=False, out=None) [same] — 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) [same] — 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] - matmul(input, other) [different] Different: 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) - matrix_exp(A) [same] — linalg.matrix_exp(A): Pade-13 scaling and squaring (Higham 2005). - matrix_power(A, n, *, out=None) [same] — linalg.matrix_power(A, n): repeated squaring (n < 0: of the inverse); n = 0 gives the identity. - mm(input, mat2, *, out=None) [different] Different: exact integer products like torch.matmul; PyTorch keeps the input dtype and wraps (200 of 200 int8 entries wrong on 10x64 @ 64x20) - mv(input, vec, *, out=None) [same] — Matrix-vector product (2-d @ 1-d); other ranks raise as PyTorch. - orgqr(A, tau, *, out=None) [same] — linalg.householder_product(A, tau): the first n columns of H_1... - ormqr(input, tau, other, left=True, transpose=False, *, out=None) [same] — torch.ormqr(a, tau, C, left=True, transpose=False): C multiplied by Q from geqrf's reflectors. - outer(input, vec2, *, out=None) [same] — The outer product of two vectors (ger too). - pca_lowrank(A, q=None, center=True, niter=2) [same] — 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) [same] — torch.pinverse: linalg.pinv with rtol=rcond. - qr(A, some=True, *, out=None) [same] — torch.qr (deprecated in PyTorch): linalg.qr with mode 'reduced' (some=True) or 'complete'. - slogdet(A, *, out=None, maths=None) [same] - svd(A, some=True, compute_uv=True, *, out=None) [same] — 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) [same] — 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) [same] — 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) [same] — 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) [same] — torch.triangular_solve(b, A, upper=True, transpose=False, unitriangular=False) (deprecated in PyTorch). - vdot(input, other, *, out=None) [same] — Dot product of the flattened inputs: sum(input * other). ### Utilities - are_deterministic_algorithms_enabled() [same] — The flag use_deterministic_algorithms recorded. - can_cast(from_, to) [same] — 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) [different] — Accepts `torch.compile`'s arguments. Different: records a function once and replays it; a module runs eagerly (Riptorch compiles every graph anyway). - compiled_with_cxx11_abi() [same] — True, as PyTorch's macOS builds report. - cond(pred, true_fn, false_fn, operands=()) [same] — true_fn(*operands) if pred else false_fn(*operands), run eagerly (pred read as a bool). - get_autocast_dtype(device_type='cpu') [same] — 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() [same] — 0 ('default'). - get_device_module(device=None) [same] — The torch. module for a device ('cpu' when none is given). - get_float32_matmul_precision() [same] — 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) [same] — Whether autocast is on for device_type (no argument: cuda, PyTorch's deprecated form). - is_deterministic_algorithms_warn_only_enabled() [same] — The warn_only flag use_deterministic_algorithms recorded. - is_warn_always_enabled() [same] — False. - promote_types(type1, type2) [same] — 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) [same] — 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) [same] — set_autocast_enabled([device_type,] enabled): turns autocast on or off (device_type defaults to cuda). - set_deterministic_debug_mode(mode) [same] — Does nothing: Riptorch's ops are deterministic. - set_float32_matmul_precision(p) [same] — Records 'highest', 'high' or 'medium' (RuntimeError otherwise); use torch.set_matmul to change Riptorch's matmul precision. - set_warn_always(b) [same] — Does nothing (Riptorch's warnings follow Python's warnings filters). - typename(obj) [same] — 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) [same] — Records the flag (Riptorch's ops are deterministic either way). - vmap(func, in_dims=0, out_dims=0, randomness='error', *, chunk_size=None) [same] — 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) [same] — Runs carried = body_fn(*carried) while cond_fn(*carried) is true, eagerly; returns the final tuple. ### Classes - AcceleratorError [same] — An accelerator failed (a RuntimeError, as PyTorch). - AggregationType(*values) [same] - AliasDb(*a, **k) [same] - AnyType(*a, **k) [same] - Argument(*args) [same] — One argument (or return) of an operator schema. - ArgumentSpec(*a, **k) [same] - autocast(device_type='cpu', dtype=None, enabled=True, cache_enabled=None) [same] — 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). - AwaitType(*args) [same] - BenchmarkConfig() [same] — ThroughputBenchmark settings: num_calling_threads, num_worker_threads, num_warmup_iters, num_iters, profiler_output_path. - BenchmarkExecutionStats(*a, **k) [same] — 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] - BFloat16Tensor(*data) [same] — 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) [same] — 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] - BoolTensor(*data) [same] — 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. - BoolType(*a, **k) [same] - BufferDict(*args) [same] — The buffers of a C++ ScriptModule, by name. - ByteStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.uint8) [same] - ByteTensor(*data) [same] — 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) [same] — A TorchScript call-stack entry: name and source range. - Capsule(*a, **k) [same] - CharStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.int8) [same] - CharTensor(*data) [same] — 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) [same] — A TorchScript class type, by qualified name (ClassType("__torch__.M")). - Code(*a, **k) [same] - CompilationUnit(lang=None, _frames_up=0) [same] - CompleteArgumentSpec(*a, **k) [same] - ComplexDoubleStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.complex128) [same] - ComplexFloatStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.complex64) [same] - ComplexTensor(rv) [extra] — A complex tensor: `_rv` is its real view [..., 2]. - ComplexType(*a, **k) [same] - ConcreteModuleType(*a, **k) [same] - ConcreteModuleTypeBuilder(*args) [same] — Collects what a module type has (attributes, modules, constants,...) before it is built. - DeepCopyMemoTable(*a, **k) [same] - DeserializationStorageContext() [same] — Storages by key while an archive is loaded. - device(type, index=None) [same] — torch.device: a device type and index. - DeviceObjType(*a, **k) [same] - DictType(*args) [same] - DisableTorchFunction() [same] — Context manager: no __torch_function__ is called inside (Riptorch has none). - DisableTorchFunctionSubclass() [same] — Context manager: __torch_function__ of tensor subclasses is not called inside (Riptorch has none). - DispatchKey(*values) [same] - DispatchKeySet(*args) [same] — 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] - DoubleTensor(*data) [same] — 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) [same] — A dtype. - EnumType(*args) [same] — A TorchScript enum type: EnumType(qualified_name, value_type, values). - ErrorReport(*args) [same] — A TorchScript compile error at a source range (an Exception). - Event(device=None, *, enable_timing=False, blocking=False, interprocess=False) [same] — torch.Event: a marker recorded on a stream. - ExcludeDispatchKeyGuard(*args) [same] — Excludes dispatch keys while alive (Riptorch dispatches without keys: a guard with nothing to exclude). - ExecutionPlan(*a, **k) [same] - FatalError [same] — An unrecoverable error (PyTorch's torch.FatalError). - FileCheck() [same] — 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 fir - finfo(type=None) [same] — 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] - FloatTensor(*data) [same] — 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. - FloatType(*a, **k) [same] - FractionTensor(values, shape) [extra] — Exact results: a tensor of reduced fractions (Python ints of any size, no rounding). - FunctionSchema(*args) [same] — An operator schema: name, overload_name, arguments, returns (parse_schema reads the text form). - Future(*, devices=None) [same] — 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). - FutureType(*args) [same] - Gradient(*a, **k) [same] - GradScaler(device='cuda', init_scale=65536.0, growth_factor=2.0, backoff_factor=0.5, growth_interval=2000, enabled=True) [same] — 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() [same] — A TorchScript-style graph: graph inputs, nodes in order, outputs; printed in TorchScript's IR text form. - GraphExecutorState(*a, **k) [same] - HalfStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.float16) [same] - HalfTensor(*data) [same] — 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) [same] — Bits, min and max of an integer dtype; bool and float dtypes raise TypeError, as PyTorch. - InferredType(*args) [same] — The result of inferring a value's type: success and type, or reason. - InterfaceType(*args) [same] — A TorchScript interface type, by qualified name. - IntStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.int32) [same] - IntTensor(*data) [same] — 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. - IntType(*a, **k) [same] - IODescriptor(*a, **k) [same] - JITException [same] — Unspecified run-time error. - layout(name) [same] — torch.layout: strided, sparse_coo, sparse_csr, sparse_csc, sparse_bsr, sparse_bsc, jagged, _mkldnn. - ListType(*args) [same] - LiteScriptModule(*args) [same] — A module of the TorchScript mobile runtime; construction raises as PyTorch does from Python. - LockingLogger() [same] — Counters by key, summed or averaged (set_aggregation_type). - LoggerBase(*a, **k) [same] — 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] - LongTensor(*data) [same] — 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) [same] — torch.memory_format: a name (contiguous_format, channels_last,...); Riptorch tensors have one layout. - ModuleDict(modules=None) [same] — torch.nn.ModuleDict: modules by name, registered as submodules in insertion order. - NestedTensor(ts, lay=None, ragged=None, lengths=None, offsets=None) [extra] — A nested tensor: `_ts` (the components), `_lay` (strided or jagged), `_ragged` (the RaggedInt of a jagged tensor's ragged dim). - Node(*a, **k) [same] — One operation of the IR: kind ("aten::add"), inputs, outputs, attributes, blocks. - NoneType(*a, **k) [same] - NoopLogger() [same] — A stat logger that records nothing. - NumberType(*a, **k) [same] - OperatorInfo(*a, **k) [same] - OptionalType(*args) [same] - OutOfMemoryError [same] — Out of memory (a RuntimeError, as PyTorch). - ParameterDict(parameters=None) [same] — Parameters by key, registered under the keys; plain tensors become parameters. - PyObjectType(*a, **k) [same] - PyTorchFileReader(f) [same] — Reads a torch.save zip archive: records by name (without the archive's directory). - PyTorchFileWriter(file_name, compute_crc32=True, storage_alignment=64) [same] — Writes the zip archive torch.save uses: records under /, plus version / byteorder /.data/serialization_id at the end. - QInt32Storage(*args, wrap_storage=None, dtype=None, device=None, _internal=False) [same] — A storage of quantized values (torch.Storage): its raw integers. - QInt8Storage(*args, wrap_storage=None, dtype=None, device=None, _internal=False) [same] — A storage of quantized values (torch.Storage): its raw integers. - qscheme(name) [same] — 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) [extra] — 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). - QUInt2x4Storage(*args, wrap_storage=None, dtype=None, device=None, _internal=False) [same] — A storage of quantized values (torch.Storage): its raw integers. - QUInt4x2Storage(*args, wrap_storage=None, dtype=None, device=None, _internal=False) [same] — A storage of quantized values (torch.Storage): its raw integers. - QUInt8Storage(*args, wrap_storage=None, dtype=None, device=None, _internal=False) [same] — A storage of quantized values (torch.Storage): its raw integers. - RRefType(*args) [same] - ScriptClass(*a, **k) [same] - ScriptClassFunction(*a, **k) [same] - ScriptDict(*args) [same] — A dict usable from TorchScript (a dict here). - ScriptDictIterator(*a, **k) [same] - ScriptDictKeyIterator(*a, **k) [same] - ScriptFunction(*a, **k) [same] - ScriptList(*args) [same] — A list usable from TorchScript (a list here). - ScriptListIterator(*a, **k) [same] - ScriptMethod(*a, **k) [same] - ScriptModule(*args) [same] — 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) [same] — Writes a ScriptModule archive; serialize raises (TorchScript serialization needs TorchScript). - ScriptObject(*a, **k) [same] - ScriptObjectProperty(*a, **k) [same] - SerializationStorageContext(*a, **k) [same] - ShortStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.int16) [same] - ShortTensor(*data) [same] — 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) [extra] — Stored vectors (`[N, D]`) prepared once for repeated searches. - Size(sizes=()) [same] — 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) [extra] — A sparse tensor of any sparse layout (see the module docstring). - StaticModule(*a, **k) [same] - Storage(*args, dtype=None, device=None, wrap_storage=None, _internal=False, __dt=riptorch.float32) [same] - StorageBase(*args, device=None) [same] — torch.UntypedStorage: bytes. - Stream(device=None, *, priority=0, **kwargs) [same] — torch.Stream: a device stream. - StreamObjType(*a, **k) [same] - StringType(*a, **k) [same] - SymBool(node) [same] - SymBoolType() [same] - SymFloat(node) [same] - SymInt(node) [same] - SymIntType() [same] - Tag(*values) [same] - Tensor(handle) [same] — A tensor: values of one dtype in a shape, held by Riptorch's Raya core. - TensorType(*a, **k) [same] — The TorchScript tensor type: TensorType.get (any tensor) or the dtype, sizes and requires_grad of one tensor (create_from_tensor). - ThroughputBenchmark(module) [same] — Runs a module (or function) on recorded inputs from several threads and measures latency / throughput. - TracingState(*a, **k) [same] - TupleType(*args) [same] - Type(*a, **k) [same] — A TorchScript type: str, kind, isSubtypeOf, containedTypes; tensor queries on TensorType. - TypedStorage(*args, dtype=None, device=None, wrap_storage=None, _internal=False) [same] — torch.TypedStorage (deprecated in PyTorch, with its warning): a flat, typed sequence. - UnionType(*args) [same] - UntypedStorage(*args, device=None) [same] — torch.UntypedStorage: bytes. - Use(*a, **k) [same] — One use of a Value: the node using it (user) and the input position (offset). - Value(*a, **k) [same] — A value of the IR: one node's output or a graph / block input. ### Data types and constants - bfloat16 [same] - bool [same] - cdouble [same] - cfloat [same] - channels_last [same] - channels_last_3d [same] - complex128 [same] - complex64 [same] - contiguous_format [same] - double [same] - e [same] - float [same] - float16 [same] - float32 [same] - float64 [same] - float8_e4m3fn [same] - float8_e4m3fnuz [same] - float8_e5m2 [same] - float8_e5m2fnuz [same] - float8_e8m0fnu [same] - half [same] - inf [same] - int [same] - int16 [same] - int32 [same] - int64 [same] - int8 [same] - jagged [same] - long [same] - LOSSES [extra] - nan [same] - per_channel_affine [same] - per_channel_affine_float_qparams [same] - per_channel_symmetric [same] - per_tensor_affine [same] - per_tensor_symmetric [same] - pi [same] - preserve_format [same] - qint32 [same] - qint8 [same] - quint2x4 [same] - quint4x2 [same] - quint8 [same] - short [same] - sparse_bsc [same] - sparse_bsr [same] - sparse_coo [same] - sparse_csc [same] - sparse_csr [same] - strided [same] - uint16 [same] - uint32 [same] - uint64 [same] - uint8 [same] - WEIGHT_MAPS [extra] ### In-place functions - abs_(input, *a, **k) [same] — input.abs_(...): abs in place on input; returns input. - absolute_(input, *a, **k) [extra] — input.absolute_(...): absolute in place on input; returns input. - acos_(input, *a, **k) [same] — input.acos_(...): acos in place on input; returns input. - acosh_(input, *a, **k) [same] — input.acosh_(...): acosh in place on input; returns input. - addbmm_(input, *a, **k) [extra] — input.addbmm_(...): addbmm in place on input; returns input. - addcdiv_(input, *a, **k) [extra] — input.addcdiv_(...): addcdiv in place on input; returns input. - addcmul_(input, *a, **k) [extra] — input.addcmul_(...): addcmul in place on input; returns input. - addmm_(input, *a, **k) [extra] — input.addmm_(...): addmm in place on input; returns input. - addmv_(input, *a, **k) [same] — input.addmv_(...): addmv in place on input; returns input. - addr_(input, *a, **k) [extra] — input.addr_(...): addr in place on input; returns input. - alpha_dropout_(input, p, train) [same] — In-place alpha_dropout. - arccos_(input, *a, **k) [same] — input.arccos_(...): arccos in place on input; returns input. - arccosh_(input, *a, **k) [same] — input.arccosh_(...): arccosh in place on input; returns input. - arcsin_(input, *a, **k) [same] — input.arcsin_(...): arcsin in place on input; returns input. - arcsinh_(input, *a, **k) [same] — input.arcsinh_(...): arcsinh in place on input; returns input. - arctan2_(input, *a, **k) [extra] — input.arctan2_(...): arctan2 in place on input; returns input. - arctan_(input, *a, **k) [same] — input.arctan_(...): arctan in place on input; returns input. - arctanh_(input, *a, **k) [same] — input.arctanh_(...): arctanh in place on input; returns input. - as_strided_(input, size, stride, storage_offset=None) [same] — In-place as_strided: the tensor becomes the strided view's values (Riptorch copies; no shared storage). - asin_(input, *a, **k) [same] — input.asin_(...): asin in place on input; returns input. - asinh_(input, *a, **k) [same] — input.asinh_(...): asinh in place on input; returns input. - atan2_(input, *a, **k) [extra] — input.atan2_(...): atan2 in place on input; returns input. - atan_(input, *a, **k) [same] — input.atan_(...): atan in place on input; returns input. - atanh_(input, *a, **k) [same] — input.atanh_(...): atanh in place on input; returns input. - baddbmm_(input, *a, **k) [extra] — input.baddbmm_(...): baddbmm in place on input; returns input. - bitwise_and_(input, *a, **k) [extra] — input.bitwise_and_(...): bitwise_and in place on input; returns input. - bitwise_left_shift_(input, *a, **k) [extra] — input.bitwise_left_shift_(...): bitwise_left_shift in place on input; returns input. - bitwise_not_(input, *a, **k) [extra] — input.bitwise_not_(...): bitwise_not in place on input; returns input. - bitwise_or_(input, *a, **k) [extra] — input.bitwise_or_(...): bitwise_or in place on input; returns input. - bitwise_right_shift_(input, *a, **k) [extra] — input.bitwise_right_shift_(...): bitwise_right_shift in place on input; returns input. - bitwise_xor_(input, *a, **k) [extra] — input.bitwise_xor_(...): bitwise_xor in place on input; returns input. - ceil_(input, *a, **k) [same] — input.ceil_(...): ceil in place on input; returns input. - celu_(input, alpha=1.0) [same] — In-place CELU. - clamp_(input, *a, **k) [same] — input.clamp_(...): clamp in place on input; returns input. - clamp_max_(input, *a, **k) [same] — input.clamp_max_(...): clamp_max in place on input; returns input. - clamp_min_(input, *a, **k) [same] — input.clamp_min_(...): clamp_min in place on input; returns input. - clip_(input, *a, **k) [same] — input.clip_(...): clip in place on input; returns input. - conj_physical_(input) [same] — In-place conjugate; real tensors are returned unchanged. - copysign_(input, *a, **k) [extra] — input.copysign_(...): copysign in place on input; returns input. - cos_(input, *a, **k) [same] — input.cos_(...): cos in place on input; returns input. - cosh_(input, *a, **k) [same] — input.cosh_(...): cosh in place on input; returns input. - deg2rad_(input, *a, **k) [same] — input.deg2rad_(...): deg2rad in place on input; returns input. - detach_(input) [same] — input.detach_. - digamma_(input, *a, **k) [extra] — input.digamma_(...): digamma in place on input; returns input. - divide_(input, *a, **k) [extra] — input.divide_(...): divide in place on input; returns input. - dropout_(input, p, train) [same] — In-place dropout. - embedding_renorm_(input, indices, max_norm, norm_type) [different] Different: correctly rounded rescaled rows; PyTorch's float32 arithmetic left 21374 of 160000 values off (200 random 50x16 weights) - eq_(input, *a, **k) [extra] — input.eq_(...): eq in place on input; returns input. - erf_(input, *a, **k) [same] — input.erf_(...): erf in place on input; returns input. - erfc_(input, *a, **k) [same] — input.erfc_(...): erfc in place on input; returns input. - erfinv_(input, *a, **k) [extra] — input.erfinv_(...): erfinv in place on input; returns input. - exp2_(input, *a, **k) [same] — input.exp2_(...): exp2 in place on input; returns input. - exp_(input, *a, **k) [same] — input.exp_(...): exp in place on input; returns input. - expm1_(input, *a, **k) [same] — input.expm1_(...): expm1 in place on input; returns input. - feature_alpha_dropout_(input, p, train) [same] — In-place feature_alpha_dropout. - feature_dropout_(input, p, train) [same] — In-place feature_dropout. - fill_(input, value) [same] — Fills the tensor in place with value (a number or a 0-d tensor); returns it. - fix_(input, *a, **k) [same] — input.fix_(...): fix in place on input; returns input. - float_power_(input, *a, **k) [extra] — input.float_power_(...): float_power in place on input; returns input. - floor_(input, *a, **k) [same] — input.floor_(...): floor in place on input; returns input. - fmod_(input, *a, **k) [extra] — input.fmod_(...): fmod in place on input; returns input. - frac_(input, *a, **k) [same] — input.frac_(...): frac in place on input; returns input. - gcd_(input, *a, **k) [same] — input.gcd_(...): gcd in place on input; returns input. - ge_(input, *a, **k) [extra] — input.ge_(...): ge in place on input; returns input. - greater_(input, *a, **k) [extra] — input.greater_(...): greater in place on input; returns input. - greater_equal_(input, *a, **k) [extra] — input.greater_equal_(...): greater_equal in place on input; returns input. - gt_(input, *a, **k) [extra] — input.gt_(...): gt in place on input; returns input. - heaviside_(input, *a, **k) [extra] — input.heaviside_(...): heaviside in place on input; returns input. - hypot_(input, *a, **k) [extra] — input.hypot_(...): hypot in place on input; returns input. - i0_(input, *a, **k) [same] — input.i0_(...): i0 in place on input; returns input. - igamma_(input, *a, **k) [extra] — input.igamma_(...): igamma in place on input; returns input. - igammac_(input, *a, **k) [extra] — input.igammac_(...): igammac in place on input; returns input. - index_put_(input, *a, **k) [same] — input.index_put_(...): index_put in place on input; returns input. - lcm_(input, *a, **k) [same] — input.lcm_(...): lcm in place on input; returns input. - ldexp_(input, *a, **k) [same] — input.ldexp_(...): ldexp in place on input; returns input. - le_(input, *a, **k) [extra] — input.le_(...): le in place on input; returns input. - lerp_(input, *a, **k) [extra] — input.lerp_(...): lerp in place on input; returns input. - less_(input, *a, **k) [extra] — input.less_(...): less in place on input; returns input. - less_equal_(input, *a, **k) [extra] — input.less_equal_(...): less_equal in place on input; returns input. - lgamma_(input, *a, **k) [extra] — input.lgamma_(...): lgamma in place on input; returns input. - log10_(input, *a, **k) [same] — input.log10_(...): log10 in place on input; returns input. - log1p_(input, *a, **k) [same] — input.log1p_(...): log1p in place on input; returns input. - log2_(input, *a, **k) [same] — input.log2_(...): log2 in place on input; returns input. - log_(input, *a, **k) [same] — input.log_(...): log in place on input; returns input. - logical_and_(input, *a, **k) [extra] — input.logical_and_(...): logical_and in place on input; returns input. - logical_not_(input, *a, **k) [extra] — input.logical_not_(...): logical_not in place on input; returns input. - logical_or_(input, *a, **k) [extra] — input.logical_or_(...): logical_or in place on input; returns input. - logical_xor_(input, *a, **k) [extra] — input.logical_xor_(...): logical_xor in place on input; returns input. - logit_(input, *a, **k) [same] — input.logit_(...): logit in place on input; returns input. - lt_(input, *a, **k) [extra] — input.lt_(...): lt in place on input; returns input. - masked_scatter_(input, *a, **k) [extra] — input.masked_scatter_(...): masked_scatter in place on input; returns input. - multiply_(input, *a, **k) [extra] — input.multiply_(...): multiply in place on input; returns input. - mvlgamma_(input, *a, **k) [extra] — input.mvlgamma_(...): mvlgamma in place on input; returns input. - nan_to_num_(input, *a, **k) [same] — input.nan_to_num_(...): nan_to_num in place on input; returns input. - ne_(input, *a, **k) [extra] — input.ne_(...): ne in place on input; returns input. - neg_(input, *a, **k) [same] — input.neg_(...): neg in place on input; returns input. - negative_(input, *a, **k) [same] — input.negative_(...): negative in place on input; returns input. - nextafter_(input, *a, **k) [extra] — input.nextafter_(...): nextafter in place on input; returns input. - not_equal_(input, *a, **k) [extra] — input.not_equal_(...): not_equal in place on input; returns input. - polygamma_(input, *a, **k) [extra] — input.polygamma_(...): polygamma in place on input; returns input. - pow_(input, *a, **k) [extra] — input.pow_(...): pow in place on input; returns input. - put_(input, *a, **k) [extra] — input.put_(...): put in place on input; returns input. - rad2deg_(input, *a, **k) [same] — input.rad2deg_(...): rad2deg in place on input; returns input. - reciprocal_(input, *a, **k) [same] — input.reciprocal_(...): reciprocal in place on input; returns input. - relu_(*a, **k) [same] — input.relu_(...): relu in place on input; returns input. - remainder_(input, *a, **k) [extra] — input.remainder_(...): remainder in place on input; returns input. - renorm_(input, *a, **k) [extra] — input.renorm_(...): renorm in place on input; returns input. - resize_as_(input, the_template, *, memory_format=None) [same] — Resizes in place to the template's shape (kept values in order, new ones zero). - resize_as_sparse_(input, the_template) [same] — input.resize_as_sparse_(the_template): input (sparse COO) takes the template's size, sparse_dim and dense_dim. - round_(input, *a, **k) [same] — input.round_(...): round in place on input; returns input. - rrelu_(input, lower=0.125, upper=0.3333333333333333, training=False, generator=None) [same] — In-place rrelu. - rsqrt_(input, *a, **k) [same] — input.rsqrt_(...): rsqrt in place on input; returns input. - selu_(input) [same] — In-place SELU. - sgn_(input, *a, **k) [extra] — input.sgn_(...): sgn in place on input; returns input. - sigmoid_(input, *a, **k) [same] — input.sigmoid_(...): sigmoid in place on input; returns input. - sign_(input, *a, **k) [extra] — input.sign_(...): sign in place on input; returns input. - sin_(input, *a, **k) [same] — input.sin_(...): sin in place on input; returns input. - sinc_(input, *a, **k) [same] — input.sinc_(...): sinc in place on input; returns input. - sinh_(input, *a, **k) [same] — input.sinh_(...): sinh in place on input; returns input. - sqrt_(input, *a, **k) [same] — input.sqrt_(...): sqrt in place on input; returns input. - square_(input, *a, **k) [same] — input.square_(...): square in place on input; returns input. - sub_(input, *a, **k) [extra] — input.sub_(...): sub in place on input; returns input. - subtract_(input, *a, **k) [extra] — input.subtract_(...): subtract in place on input; returns input. - tan_(input, *a, **k) [same] — input.tan_(...): tan in place on input; returns input. - tanh_(input, *a, **k) [same] — input.tanh_(...): tanh in place on input; returns input. - threshold_(input, threshold, value) [same] — In-place threshold: elements <= threshold become value. - tril_(input, *a, **k) [extra] — input.tril_(...): tril in place on input; returns input. - triu_(input, *a, **k) [extra] — input.triu_(...): triu in place on input; returns input. - true_divide_(input, *a, **k) [extra] — input.true_divide_(...): true_divide in place on input; returns input. - trunc_(input, *a, **k) [same] — input.trunc_(...): trunc in place on input; returns input. - xlogy_(input, *a, **k) [same] — input.xlogy_(...): xlogy in place on input; returns input. - zero_(input) [same] — input.zero_: input filled with zeros in place. ### More functions - adaptive_avg_pool1d(input, output_size) [same] — F.adaptive_avg_pool1d: averages over output_size equal-ish windows of the last dim (area interpolation). - adaptive_max_pool1d(input, output_size) [same] — Adaptive 1-d max pooling to output_size, always with the indices: (values, indices). - affine_grid_generator(theta, size, align_corners) [same] — F.affine_grid: the sampling grid of the affine maps theta for an output of shape size. - alias_copy(x, *a, **k) [same] — alias(...) as a new tensor (the view's copy: no memory shared with the input). - as_strided_copy(input, size, stride, storage_offset=0) [same] — 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) [same] — input with the elements that as_strided(input, size, stride, storage_offset) would view replaced by src. - autocast_decrement_nesting() [same] — Decrements autocast's nesting counter; returns the new depth. - autocast_increment_nesting() [same] — 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) [extra] — 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. - backend() -> str [extra] — Names 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) [same] — CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel). - batch_norm_backward_reduce(*a, **k) [same] — CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel). - batch_norm_elemt(*a, **k) [same] — CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel). - batch_norm_gather_stats(*a, **k) [same] — CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel). - batch_norm_gather_stats_with_counts(*a, **k) [same] — CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel). - batch_norm_stats(*a, **k) [same] — 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) [same] — (mean, unbiased var) of input per channel, running stats updated in place (CPU kernel in PyTorch). - bilinear(input1, input2, weight, bias=None) [same] — x1^T A x2 + b per output feature: weight (out, in1, in2), bias (out,) or None. - binary_cross_entropy_with_logits(*args, **kw) [same] — 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) [same] — 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) [same] — 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) [same] — min(x, max). - clamp_min(input, min) [same] — clamp(input, min=min). - classproperty(func) [same] — A read-only property of the class (and its instances). - clear_autocast_cache() [same] — Does nothing: Riptorch keeps no autocast weight cache. - col_indices_copy(x, *a, **k) [same] — col_indices(...) as a new tensor (the view's copy: no memory shared with the input). - constant_pad_nd(input, pad, value=0) [same] — Pads with a constant: pad lists (before, after) pairs from the last dim backwards, as F.pad. - conv_tbc(input, weight, bias, pad=0) [same] — 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) [same] — 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) [same] — F.cosine_embedding_loss with PyTorch's integer reduction (0 none, 1 mean, 2 sum). - cross_similarity(x1, x2, dim=1, eps=1e-08) -> Tensor [extra] — The signed cross `sign(u·v) (u·v)² / (Q(u) Q(v))`: `1 − spread` with the sign of `u·v`, in `[−1, 1]`. - crow_indices_copy(x, *a, **k) [same] — 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) [same] — Connectionist temporal classification loss with PyTorch's integer reduction (0 none, 1 mean, 2 sum). - cudnn_affine_grid_generator(input, *args, **kwargs) [same] — torch.cudnn_affine_grid_generator: a cudnn kernel PyTorch on a Mac does not have (raises as PyTorch). - cudnn_batch_norm(input, *args, **kwargs) [same] — torch.cudnn_batch_norm: a cudnn kernel PyTorch on a Mac does not have (raises as PyTorch). - cudnn_convolution(input, *args, **kwargs) [same] — torch.cudnn_convolution: a cudnn kernel PyTorch on a Mac does not have (raises as PyTorch). - cudnn_convolution_add_relu(input, *args, **kwargs) [same] — torch.cudnn_convolution_add_relu: a cudnn kernel PyTorch on a Mac does not have (raises as PyTorch). - cudnn_convolution_relu(input, *args, **kwargs) [same] — torch.cudnn_convolution_relu: a cudnn kernel PyTorch on a Mac does not have (raises as PyTorch). - cudnn_convolution_transpose(input, *args, **kwargs) [same] — torch.cudnn_convolution_transpose: a cudnn kernel PyTorch on a Mac does not have (raises as PyTorch). - cudnn_grid_sampler(input, *args, **kwargs) [same] — torch.cudnn_grid_sampler: a cudnn kernel PyTorch on a Mac does not have (raises as PyTorch). - cudnn_is_acceptable(input) [same] — False for every tensor (no cuDNN on a Mac); TypeError for a non-tensor, as PyTorch. - detach(input) [same] — input.detach: the same values, no longer recording gradients. - detach_copy(input) [same] — detach(...) as a new tensor (the view's copy: no memory shared with the input). - diagonal_copy(input, offset=0, dim1=0, dim2=1) [same] — diagonal(...) as a new tensor (the view's copy: no memory shared with the input). - dsmm(input, mat2) [same] — torch.spmm: sparse @ dense -> dense. - eig(*a, _m='This function was deprecated since version 1.9 and is now removed. Please use the `torch.linalg.eig` function instead.', **k) [same] — Removed from PyTorch: raises RuntimeError as PyTorch does (This function was deprecated since version 1.9 and is now removed. - empty_permuted(size, physical_layout, *, dtype=None, **kw) [same] — 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) [same] — A quantized tensor of the given size with qtensor's parameters (its values: the zero point, a defined 'empty'). - expand_copy(x, *a, **k) [same] — expand(...) as a new tensor (the view's copy: no memory shared with the input). - fbgemm_linear_fp16_weight(*a, **k) [same] — FBGEMM fp16-weight linear: raises as PyTorch on arm64 (no FBGEMM). - fbgemm_linear_fp16_weight_fp32_activation(*a, **k) [same] — FBGEMM fp16-weight linear: raises as PyTorch on arm64 (no FBGEMM). - fbgemm_linear_int8_weight(*a, **k) [same] — FBGEMM fp16-weight linear: raises as PyTorch on arm64 (no FBGEMM). - fbgemm_linear_int8_weight_fp32_activation(*a, **k) [same] — FBGEMM fp16-weight linear: raises as PyTorch on arm64 (no FBGEMM). - fbgemm_linear_quantize_weight(*a, **k) [same] — FBGEMM fp16-weight linear: raises as PyTorch on arm64 (no FBGEMM). - fbgemm_pack_gemm_matrix_fp16(*a, **k) [same] — FBGEMM fp16-weight linear: raises as PyTorch on arm64 (no FBGEMM). - fbgemm_pack_quantized_matrix(*a, **k) [same] — FBGEMM fp16-weight linear: raises as PyTorch on arm64 (no FBGEMM). - fill(input, value) [same] — A tensor like input filled with value (a number or a one-element tensor). - fork(fn, *a, **k) [same] — 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) [same] — 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) [same] — 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() [same] — Deprecated (DeprecationWarning, as PyTorch): get_autocast_dtype('cpu'). - get_autocast_gpu_dtype() [same] — Deprecated (DeprecationWarning, as PyTorch): get_autocast_dtype('cuda'). - get_autocast_ipu_dtype() [same] — Deprecated (DeprecationWarning, as PyTorch): get_autocast_dtype('ipu'). - get_autocast_xla_dtype() [same] — Deprecated (DeprecationWarning, as PyTorch): get_autocast_dtype('xla'). - get_compat() -> str [extra] — `"riptorch"` (the correct-by-default behaviour) or `"pytorch"` (stock behaviour), as `set_compat` set it. - get_device(x) [same] — -1, PyTorch's answer for a CPU tensor (Riptorch's memory is unified). - get_file_path(*path_components) [same] — A path inside the installed package. - get_float64() -> str [extra] — Where float64 graphs run now: `"auto"`, `"gpu"`, `"cpu"` or `"fast"`. - get_int_matmul() -> str [extra] — Where exact integer matmuls run: `"auto"` (default), `"gpu"` or `"cpu"`. - get_maths() -> str [extra] — The model maths `set_maths` chose: `"transcendental"` (the default) or `"rational"`. - get_matmul() -> str [extra] — The precision `set_matmul` chose: `"fp32"` (default), `"bf16"`, `"fp16"`, `"exact"`, `"fast"` or `"high"`. - grid_sampler(input, grid, interpolation_mode, padding_mode, align_corners) [same] — F.grid_sample with integer modes: interpolation 0 bilinear, 1 nearest, 2 bicubic; padding 0 zeros, 1 border, 2 reflection. - grid_sampler_2d(input, grid, interpolation_mode, padding_mode, align_corners) [same] — F.grid_sample with integer modes: interpolation 0 bilinear, 1 nearest, 2 bicubic; padding 0 zeros, 1 border, 2 reflection. - grid_sampler_3d(input, grid, interpolation_mode, padding_mode, align_corners) [same] — F.grid_sample with integer modes: interpolation 0 bilinear, 1 nearest, 2 bicubic; padding 0 zeros, 1 border, 2 reflection. - gru(*args) [same] — 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 - gru_cell(input, hx, w_ih, w_hh, b_ih=None, b_hh=None) [same] — One GRU step; gates in the order reset, update, new. - hash_tensor(input, dim=(), *, keepdim=False, mode=0) [same] — XOR of the elements' bit patterns (floats as float64 bits, integers as int64), over dim (all when empty). - hinge_embedding_loss(input, target, margin=1.0, reduction=1) [same] — F.hinge_embedding_loss with PyTorch's integer reduction (0 none, 1 mean, 2 sum). - hsmm(mat1, mat2) [same] — torch.hsmm: hspmm (sparse @ dense as a hybrid COO tensor). - hspmm(mat1, mat2) [same] - import_ir_module(cu, filename, map_location, extra_files, restore_shapes=False) [same] — 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) [same] — Raises RuntimeError: TorchScript archives need the TorchScript interpreter (torch.load reads state_dicts). - improvements(name=None, vs=None) -> list | dict | None [extra] — Every function whose Riptorch default differs from stock PyTorch's because PyTorch's result is wrong or degraded, each as a dict with the measurement behind it: `name`, `area`, `headline`, `stock` (wh - indices_copy(x, *a, **k) [same] — indices(...) as a new tensor (the view's copy: no memory shared with the input). - init_num_threads() [same] — Nothing to do: Riptorch's thread pools start on their own. - int_repr(input) [same] — The stored integers of a quantized tensor. - interpreter_stats() -> tuple [extra] — `(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() [same] — False: anomaly detection is not tracked. - is_anomaly_enabled() [same] — False: anomaly detection is not tracked. - is_autocast_cache_enabled() [same] — The flag set_autocast_cache_enabled set (True by default). - is_autocast_cpu_enabled() [same] — Whether autocast is on for the CPU. - is_autocast_ipu_enabled() [same] — Deprecated (DeprecationWarning, as PyTorch): is_autocast_enabled('ipu'). - is_autocast_xla_enabled() [same] — Deprecated (DeprecationWarning, as PyTorch): is_autocast_enabled('xla'). - is_distributed(x) [same] — False: no tensor is distributed across processes. - is_inference(x) [same] — False: Riptorch has no inference tensors (inference_mode is no_grad). - is_same_size(a, b) [same] — Whether a and b have the same shape. - is_signed(x) [same] — Whether x's dtype holds negative values (floats and signed integers). - is_torch_alias() -> bool [extra] — `True` when `import torch` in this process gives Riptorch (Riptorch was imported first and registered itself under that name). - is_vulkan_available() [same] — False: no Vulkan backend (as PyTorch does on a Mac). - kl_div(*args, **kw) [same] — 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) [same] — 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 - lstm_cell(input, hx, w_ih, w_hh, b_ih=None, b_hh=None) [same] — One LSTM step: hx = (h, c); gates in the order input, forget, cell, output. - lstsq(*a, _m='torch.lstsq is deprecated in favor of torch.linalg.lstsq and will be removed in a future PyTorch release.', **k) [same] — 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) [same] — F.margin_ranking_loss: max(0, -target * (input1 - input2) + margin), reduced. - maths_config() -> dict [extra] — The current `set_maths` settings as a dict. - maths_stats() [extra] — 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. - maths_stats_reset() [extra] — Forgets the Cayley clamp statistics recorded so far (call at the start of a step). - matrix_rank(input, tol=None, symmetric=False, *, out=None) -> torch.Tensor [same] — Removed in PyTorch: raises its RuntimeError (use torch.linalg.matrix_rank). - matrix_unit() -> str [extra] — The CPU matrix unit Riptorch's CPU matrix multiplies run on: `"SME"` on Apple M4 and later, `"AMX"` on M1 to M3, `"none"` elsewhere (the portable kernels). - matrix_unit_modes() -> list[str] [extra] — 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() -> dict [extra] — The 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) [same] — 1-d max pooling with the argmax indices: (values, indices). - merge_type_from_type_comment(decl, type_annotation_decl, is_method) [same] — A declaration with the type comment's types applied to its parameters (self skipped for methods). - miopen_batch_norm(input, *args, **kwargs) [same] — torch.miopen_batch_norm: a miopen kernel PyTorch on a Mac does not have (raises as PyTorch). - miopen_convolution(input, *args, **kwargs) [same] — torch.miopen_convolution: a miopen kernel PyTorch on a Mac does not have (raises as PyTorch). - miopen_convolution_add_relu(input, *args, **kwargs) [same] — torch.miopen_convolution_add_relu: a miopen kernel PyTorch on a Mac does not have (raises as PyTorch). - miopen_convolution_relu(input, *args, **kwargs) [same] — torch.miopen_convolution_relu: a miopen kernel PyTorch on a Mac does not have (raises as PyTorch). - miopen_convolution_transpose(input, *args, **kwargs) [same] — torch.miopen_convolution_transpose: a miopen kernel PyTorch on a Mac does not have (raises as PyTorch). - miopen_ctc_loss(input, *args, **kwargs) [same] — torch.miopen_ctc_loss: a miopen kernel PyTorch on a Mac does not have (raises as PyTorch). - miopen_depthwise_convolution(input, *args, **kwargs) [same] — torch.miopen_depthwise_convolution: a miopen kernel PyTorch on a Mac does not have (raises as PyTorch). - miopen_rnn(input, *args, **kwargs) [same] — torch.miopen_rnn: a miopen kernel PyTorch on a Mac does not have (raises as PyTorch). - mkldnn_adaptive_avg_pool2d(input, *args, **kwargs) [same] — torch.mkldnn_adaptive_avg_pool2d: a mkldnn kernel PyTorch on a Mac does not have (raises as PyTorch). - mkldnn_convolution(input, *args, **kwargs) [same] — torch.mkldnn_convolution: a mkldnn kernel PyTorch on a Mac does not have (raises as PyTorch). - mkldnn_linear_backward_weights(input, *args, **kwargs) [same] — torch.mkldnn_linear_backward_weights: a mkldnn kernel PyTorch on a Mac does not have (raises as PyTorch). - mkldnn_max_pool2d(input, *args, **kwargs) [same] — torch.mkldnn_max_pool2d: a mkldnn kernel PyTorch on a Mac does not have (raises as PyTorch). - mkldnn_max_pool3d(input, *args, **kwargs) [same] — torch.mkldnn_max_pool3d: a mkldnn kernel PyTorch on a Mac does not have (raises as PyTorch). - mkldnn_rnn_layer(input, *args, **kwargs) [same] — 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) [same] — (output, save_mean, save_invstd). - native_channel_shuffle(input, groups) [same] — Shuffles the channels (dim 1) across groups: (N, g*k,...) read as (N, g, k,...) and transposed. - native_dropout(input, p, train) [same] — (output, mask): dropout with its keep mask (bool). - native_group_norm(input, weight, bias, N, C, HxW, group, eps) [same] — (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) [same] — (output, mean, rstd) over the last len(normalized_shape) dims; mean and rstd keep those dims as 1. - native_norm(*a, **k) [same] — CUDA-only in PyTorch: on this platform it raises PyTorch's NotImplementedError (no CPU kernel). - nonzero_static(input, *, size, fill_value=-1) [same] — 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) [same] — p-norm over every dim but dim (keepdim shape); dim=-1: the norm of the whole tensor. - normalized_map(x, kind) [extra] — p_i = w(x_i) / sum_j w(x_j) over the last dim, nothing recentered or tempered. - nuclear_norm(input, dim=None, keepdim=False) [same] — Deprecated in PyTorch (its warning, once): sum of singular values over the last two dims (or dim). - parse_ir(input, parse_tensor_constants=False) [same] — A Graph from TorchScript's IR text form (graph inputs keep their names; node outputs are numbered). - parse_schema(schema, allow_typevars=True) [same] — FunctionSchema from text: `ns::name.overload(Type name=default, *,...) -> ret`. - parse_type_comment(comment) [same] — '# type: (int, float) -> int' as a declaration (argument and return types, as text). - permute_copy(input, *dims) [same] — 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) [same] — F.poisson_nll_loss with PyTorch's positional arguments and integer reduction (0 none, 1 mean, 2 sum). - prepare_multiprocessing_environment(path) [same] — No-op (PyTorch sets up shared-memory file handling for worker processes; Riptorch shares no storage). - profiler_allow_cudagraph_cupti_lazy_reinit_cuda12() [same] — True, as PyTorch on this platform. - program_stats() -> tuple [extra] — Counts 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) [same] — The per-channel axis of a quantized tensor. - q_per_channel_scales(input) [same] — The per-channel scales of a quantized tensor. - q_per_channel_zero_points(input) [same] — The per-channel zero points of a quantized tensor. - q_scale(input) [same] — The scale of a per-tensor quantized tensor. - q_zero_point(input) [same] — The zero point of a per-tensor quantized tensor. - quantize_per_tensor_dynamic(input, dtype, reduce_range) [same] — 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) [same] — Legacy quantized GRU over FBGEMM-packed weights: raises as PyTorch on arm64 (no FBGEMM). - quantized_gru_cell(*a, **k) [same] — Legacy FBGEMM quantized GRU cell: raises as PyTorch on arm64 (no FBGEMM). - quantized_lstm(input, hx, params, *a, **k) [same] — Legacy quantized GRU over FBGEMM-packed weights: raises as PyTorch on arm64 (no FBGEMM). - quantized_lstm_cell(*a, **k) [same] — 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) [same] — 3-d max pooling of a quantized tensor, on its integers (exact; the same parameters). - quantized_rnn_relu_cell(*a, **k) [same] — Legacy FBGEMM quantized GRU cell: raises as PyTorch on arm64 (no FBGEMM). - quantized_rnn_tanh_cell(*a, **k) [same] — Legacy FBGEMM quantized GRU cell: raises as PyTorch on arm64 (no FBGEMM). - realizer_report() -> str [extra] — Where this process's work ran: how many GPU programs and CPU programs, and for each graph that did not run on the GPU, why (for example a small graph where a GPU round trip costs more, or float64). - rms_norm(input, normalized_shape, weight=None, eps=None, *, maths=None) [same] — x / sqrt(mean(x^2 over the normalized dims) + eps) * weight; eps defaults to float32's machine epsilon. - rnn_relu(*args) [same] — 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 - rnn_relu_cell(input, hx, w_ih, w_hh, b_ih=None, b_hh=None) [same] — One Elman RNN step with ReLU: relu(x W_ih^T + b_ih + h W_hh^T + b_hh). - rnn_tanh(*args) [same] — 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 - rnn_tanh_cell(input, hx, w_ih, w_hh, b_ih=None, b_hh=None) [same] — One Elman RNN step: tanh(x W_ih^T + b_ih + h W_hh^T + b_hh). - row_indices_copy(x, *a, **k) [same] — row_indices(...) as a new tensor (the view's copy: no memory shared with the input). - rsub(input, other, *, alpha=1) [same] — other - alpha * input (subtraction with the arguments reversed). - saddmm(input, mat1, mat2, *, beta=1, alpha=1, out=None) [same] — torch.saddmm: sspaddmm (beta * input + alpha * (mat1 @ mat2), sparse). - select_copy(*a, **k) [same] — select(...) as a new tensor (the view's copy: no memory shared with the input). - set_anomaly_enabled(enabled, check_nan=True) [same] — Accepted and ignored: anomaly detection is not tracked. - set_autocast_cache_enabled(enabled) [same] — Records whether autocast caches casts (Riptorch's autocast has no cast cache; the flag is kept). - set_autocast_cpu_dtype(dtype) [same] — Deprecated (DeprecationWarning, as PyTorch): set_autocast_dtype('cpu', dtype). - set_autocast_cpu_enabled(enabled) [same] — Deprecated (DeprecationWarning, as PyTorch): set_autocast_enabled('cpu', enabled). - set_autocast_dtype(device_type, dtype) [same] — Sets the dtype autocast uses on device_type. - set_autocast_gpu_dtype(dtype) [same] — Deprecated (DeprecationWarning, as PyTorch): set_autocast_dtype('cuda', dtype). - set_autocast_ipu_dtype(dtype) [same] — Deprecated (DeprecationWarning, as PyTorch): set_autocast_dtype('ipu', dtype). - set_autocast_ipu_enabled(enabled) [same] — Deprecated (DeprecationWarning, as PyTorch): set_autocast_enabled('ipu', enabled). - set_autocast_xla_dtype(dtype) [same] — Deprecated (DeprecationWarning, as PyTorch): set_autocast_dtype('xla', dtype). - set_autocast_xla_enabled(enabled) [same] — Deprecated (DeprecationWarning, as PyTorch): set_autocast_enabled('xla', enabled). - set_compat(mode) [extra] — 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. - set_float64(mode=None, min_work=None) [extra] — Where float64 work runs on a Mac with an Apple GPU (which has no float64 hardware): - set_int_matmul(device) [extra] — Where exact integer matrix multiplies (int8, uint8, int16 and uint16, in any same-width pair) run: - set_maths(mode=None, *, weight=None, attention=None, loss=None, recenter=None, temperature=None, cayley_eps=None) [extra] — Chooses the model maths for experiments. - set_matmul(precision) [extra] — Sets how floating-point matrix multiplies are computed (matmul, linear, convolutions and the attention backward): - similarity_topk(queries, keys, k, metric="cosine", exact=False, eps=1e-08) -> (values, indices) [extra] — 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. - slice_copy(x, dim=0, start=None, end=None, step=1) [same] — 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) [same] — The base a slice was taken from (for functionalization): src, viewed as itself. - smm(input, mat2) [same] - solve(*a, _m='torch.solve is deprecated in favor of torch.linalg.solve and will be removed in a future PyTorch release.', **k) [same] — 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) [same] — split(...) as a new tensor (the view's copy: no memory shared with the input). - split_with_sizes_copy(input, split_sizes, dim=0) [same] — split_with_sizes(...) as a new tensor (the view's copy: no memory shared with the input). - spmm(input, mat2) [same] — torch.spmm: sparse @ dense -> dense. - spread(x1, x2, dim=1, eps=1e-08) -> Tensor [extra] — The spread between vectors along `dim`: `1 − (u·v)² / (Q(u) Q(v))`, where `Q(u) = u·u`. - squeeze_copy(*a, **k) [same] — 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) [same] — entries in every column of the rows mat1 has entries in (uncoalesced, as PyTorch). - sym_constrain_range(size, *, min=None, max=None) [same] — No-op on concrete sizes (PyTorch's runtime check only applies to symbolic ones). - sym_constrain_range_for_size(size, *, min=None, max=None) [same] — No-op on concrete sizes (PyTorch's runtime check only applies to symbolic ones). - sym_float(a) [same] — float of a concrete number. - sym_fresh_size(expr) [same] — The size itself (no symbolic sizes in Riptorch). - sym_int(a) [same] — int of a concrete number (symbolic ints don't occur in Riptorch). - sym_ite(b, t, f) [same] — t if b else f. - sym_max(a, b) [same] — max(a, b) of concrete numbers. - sym_min(a, b) [same] — min(a, b) of concrete numbers. - sym_not(a) [same] — not a. - sym_sqrt(a) [same] — math.sqrt of a concrete number. - sym_sum(args) [same] — Sum of the numbers in args. - symeig(*a, _m='This function was deprecated since version 1.9 and is now removed. Please use the `torch.linalg.eigh` function instead.', **k) [same] — Removed from PyTorch: raises RuntimeError as PyTorch does (This function was deprecated since version 1.9 and is now removed. - t_copy(x, *a, **k) [same] — t(...) as a new tensor (the view's copy: no memory shared with the input). - thread_safe_generator() [same] — torch.default_generator. - to_dlpack(tensor) [same] — A DLPack capsule ("dltensor") of a CPU copy of tensor. - transpose_copy(*a, **k) [same] — 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) [same] — F.triplet_margin_loss with PyTorch's integer reduction (0 none, 1 mean, 2 sum). - unbind_copy(*a, **k) [same] — unbind(...) as a new tensor (the view's copy: no memory shared with the input). - unfold(input, dimension, size, step) [extra] — Tensor.unfold: every window of `size` along `dimension`, `step` apart, as a new last dim. - unfold_copy(input, dimension, size, step) [same] — unfold(...) as a new tensor (the view's copy: no memory shared with the input). - unify_type_list(types) [same] — The one type a list of types unifies to (None with T gives Optional[T]), or RuntimeError. - unsafe_split_with_sizes(input, *a, **k) [same] — input.unsafe_split_with_sizes(...). - unsqueeze_copy(*a, **k) [same] — unsqueeze(...) as a new tensor (the view's copy: no memory shared with the input). - values_copy(x, *a, **k) [same] — values(...) as a new tensor (the view's copy: no memory shared with the input). - view_as_complex_copy(x) [same] — view_as_complex(...) as a new tensor (the view's copy: no memory shared with the input). - view_as_real_copy(x) [same] — view_as_real(...) as a new tensor (the view's copy: no memory shared with the input). - view_copy(x, *a, **k) [same] — view(...) as a new tensor (the view's copy: no memory shared with the input). - wait(fut) [same] - weight_map(x, kind) [extra] — w(x) of a weighting map, elementwise. - weight_rate(x, kind) [extra] — r(x) = w'(x) / w(x) of a weighting map, elementwise. ## Tensor ### Properties - data [same] — The same tensor (in-place fills through.data update it, as in PyTorch). - device [same] — The tensor's device: always cpu, for every dtype (one unified memory). - dtype [same] — The dtype (float32, float64, float16, bfloat16, the integer types or bool). - grad [same] — The gradient (None before backward). - grad_dtype [same] — The dtype of this tensor's gradient (its own dtype for floating tensors, else None). - grad_fn [same] — None for a leaf, else the backward node of the op that made the tensor (name: PyTorch's name, as MulBackward0). - H [same] — The conjugate transpose of a matrix (2-d only, as PyTorch); for real tensors the transpose. - imag [same] — Imaginary part of a complex tensor; TypeError for real tensors, as PyTorch. - is_cpu [same] — True: Riptorch tensors live in one unified memory the CPU reads. - is_cuda [same] — False: no CUDA. - is_distributed_ [extra] — False: Riptorch has no distributed tensors. - is_ipu [same] — False: Riptorch has no ipu tensors. - is_leaf [same] — A tensor that needs no gradient, or one made by the user (not by an op that records gradients). - is_maia [same] — False: Riptorch has no maia tensors. - is_meta [same] — False: no meta tensors. - is_mkldnn [same] — False: Riptorch has no mkldnn tensors. - is_mps [same] — False: the GPU is used internally, tensors are not MPS tensors. - is_mtia [same] — False: Riptorch has no mtia tensors. - is_nested [same] — False for non-nested tensors. - is_quantized [same] — False for non-quantized tensors. - is_quantized_ [extra] — False: Riptorch has no quantized tensors. - is_sparse [same] — False for dense tensors. - is_sparse_csr [same] — False: Riptorch has no sparse_csr tensors. - is_vulkan [same] — False: Riptorch has no vulkan tensors. - is_xla [same] — False: Riptorch has no xla tensors. - is_xpu [same] — False: Riptorch has no xpu tensors. - itemsize [same] — Bytes per element of the dtype. - layout [same] — torch.strided: a dense tensor's layout. - mH [same] — The conjugate transpose of the last two dims (the transpose: real tensors). - mT [same] — The last two dims transposed. - name [same] — The tensor's name (None unless set; named-tensor dims are not supported). - names [extra] — Dimension names: None for every dim (no named tensors). - nbytes [same] — numel * itemsize. - ndim [same] — The number of dimensions (len(shape)). - output_nr [same] — 0: the output index of this tensor in the op that made it (always 0 here). - real [same] — self (a real tensor is its own real part). - requires_grad [same] — Whether autograd records operations on this tensor (settable; float dtypes). - retains_grad [same] — True after retain_grad on a non-leaf tensor (its.grad is kept by backward). - shape [same] — The shape as a tuple of ints (torch.Size). - T [same] — t: the transpose of a 0-, 1- or 2-d tensor (PyTorch also reverses the dims of higher-dimensional tensors, deprecated there; Riptorch raises). - volatile [same] — Removed in PyTorch: False, with its warning. ### Core methods - backward(self, gradient=None, retain_graph=None, create_graph=False, inputs=None) [same] — Backpropagates from the given tensor(s): the gradients of the graph's leaves accumulate into.grad (gradient= supplies the vector for a non-scalar output; retain_graph / create_graph as PyTorch). - bfloat16(self) [same] — to(bfloat16). - bool(self, memory_format=None) [same] — self.to(torch.bool). - byte(self) [same] — to(uint8). - cdouble(self, memory_format=None) [same] — self.to(torch.complex128). - cfloat(self, memory_format=None) [same] — self.to(torch.complex64). - char(self) [same] — to(int8). - clone(input, *, memory_format=None) [same] - contiguous(self, memory_format=None) [same] — self: Riptorch tensors are always contiguous. - cpu(self, *args, **kwargs) [same] — Tensor.cpu / cuda / mps / pin_memory: the tensor itself (one unified memory and one layout). - cuda(self, *args, **kwargs) [same] — Tensor.cpu / cuda / mps / pin_memory: the tensor itself (one unified memory and one layout). - data_ptr(self) [same] — A stable integer identity of the tensor (id(self)); Riptorch does not expose buffer addresses. - detach(self) [same] — The same values without autograd history (requires_grad False). - detach_(self) [same] — In place: self stops recording gradients; returns self. - dim(self) [same] — The number of dimensions (ndimension too). - double(self) [same] — to(float64). - element_size(self) [same] — Bytes per element. - expand(input, *size) [same] — A broadcast view to the given size (-1 keeps a dimension); size-1 dims repeat without copying. - expand_as(self, other) [same] — The tensor expanded to other's shape. - float(self) [same] — to(float32). - half(self) [same] — to(float16). - int(self) [same] — to(int32). - is_contiguous(self, *a, **k) [same] — True: Riptorch tensors have one row-major layout. - item(self) [same] — The value of a one-element tensor as a Python number (more elements raise, as PyTorch). - long(self) [same] — to(int64). - mps(self, *args, **kwargs) [extra] — Tensor.cpu / cuda / mps / pin_memory: the tensor itself (one unified memory and one layout). - nelement(self) [same] — The number of elements (numel). - new_empty(self, *size, dtype=None, device=None, requires_grad=False, **kw) [same] — A new tensor of the given size filled with the constant (new_ones: 1; new_zeros and new_empty: 0), self's dtype unless dtype=. - new_full(self, size, fill_value, *, dtype=None, device=None, requires_grad=False, **kw) [same] — A new tensor of the given size filled with fill_value, self's dtype unless dtype=. - new_ones(self, *size, dtype=None, device=None, requires_grad=False, **kw) [same] — A new tensor of the given size filled with the constant (new_ones: 1; new_zeros and new_empty: 0), self's dtype unless dtype=. - new_tensor(self, data, *, dtype=None, device=None, requires_grad=False, **kw) [same] — A new tensor from data, self's dtype unless dtype=. - new_zeros(self, *size, dtype=None, device=None, requires_grad=False, **kw) [same] — A new tensor of the given size filled with the constant (new_ones: 1; new_zeros and new_empty: 0), self's dtype unless dtype=. - numel(self) [same] — The number of elements. - numpy(self, *, force=False) [same] — The tensor's values as a NumPy array (a copy; PyTorch shares memory on the CPU). - register_hook(self, hook) [same] — Leaves: the hook sees the gradient before it accumulates into.grad (and autograd.grad's result). - requires_grad_(self, requires_grad=True) [same] — Sets requires_grad in place; returns self. - reshape(self, *shape) [same] — The values in a new shape (sizes or one sequence; one -1 is inferred); view is the same. - reshape_as(self, other) [same] — The tensor reshaped to other's shape (reshape_as too). - retain_grad(self) [same] — backward also keeps this non-leaf tensor's gradient in.grad (a leaf keeps its own anyway); RuntimeError on a tensor that does not require gradients, as PyTorch. - short(self) [same] — to(int16). - size(self, dim=None) [same] — The shape, or its size along dim. - storage(self) [same] — A TypedStorage over this tensor's elements (PyTorch's deprecation warning once); writes go to the tensor. - stride(self, dim=None) [same] — The row-major (contiguous) strides of the shape, or the one of dim: Riptorch tensors are always laid out contiguously. - to(self, dtype=None, *args, **kwargs) [same] — The tensor in another dtype (from a dtype, a tensor's dtype, or dtype=); a device argument changes nothing (one unified memory). - tolist(self) [same] — The values as nested Python lists (a 0-d tensor gives a number). - type(self, dtype=None) [same] — With no argument, the dtype (PyTorch returns a type string such as 'torch.FloatTensor'); with one, to(dtype). - type_as(self, other) [same] — The tensor converted to other's dtype. - untyped_storage(self) [same] — An UntypedStorage holding this tensor's bytes (a copy read when called; Riptorch shares no storage). - view(self, *shape) [same] — The values in a new shape (sizes or one sequence; one -1 is inferred); view is the same. - view_as(self, other) [same] — The tensor reshaped to other's shape (reshape_as too). ### More methods - abs(input) [same] — Elementwise absolute value. - absolute(input) [same] — Alias of Tensor.abs. - acos(input, *, out=None) [same] — Arccosine, elementwise, as atan2(sqrt(1 - x^2), x); differentiable. - acosh(input) [same] — Inverse hyperbolic cosine (NaN below 1). - add(input, other, *, alpha=1) [same] — self + alpha * other, with broadcasting and PyTorch type promotion. - addbmm(input, batch1, batch2, *, beta=1, alpha=1, out=None) [same] — beta * input + alpha * sum over the batch of batch1[i] @ batch2[i]. - addcdiv(input, tensor1, tensor2, *, value=1) [same] — input + value * tensor1 / tensor2. - addcmul(input, tensor1, tensor2, *, value=1) [same] — input + value * tensor1 * tensor2. - addmm(input, mat1, mat2, *, beta=1, alpha=1) [same] — beta * self + alpha * (mat1 @ mat2). - addmv(input, mat, vec, *, beta=1, alpha=1, out=None) [same] — torch.addmv(self, *args, **kwargs). - addr(input, vec1, vec2, *, beta=1, alpha=1, out=None) [same] — beta * input + alpha * outer(vec1, vec2). - adjoint(self) [same] — The transpose of the last two dims (conjugated for complex tensors in PyTorch). - all(Tensor self, int? dim=None, bool keepdim=False) -> Tensor [same] — Whether every element is nonzero, over all elements or along dim; returns bool. - allclose(input, other, rtol=1e-05, atol=1e-08, equal_nan=False) [same] — Whether isclose holds everywhere; a Python bool. - amax(Tensor self, int[] dim=[], bool keepdim=False) -> Tensor [same] — Maximum along the given dims (all dims when empty); gradients split evenly between tied maxima, as PyTorch. - amin(Tensor self, int[] dim=[], bool keepdim=False) -> Tensor [same] — Minimum along the given dims (all dims when empty); gradients split evenly between tied minima, as PyTorch. - aminmax(self, *, dim=None, keepdim=False) [same] — torch.aminmax(self, dim=dim, keepdim=keepdim). - angle(x) [same] — torch.angle(self, *args, **kwargs). - any(Tensor self, int? dim=None, bool keepdim=False) -> Tensor [same] — Whether any element is nonzero, over all elements or along dim; returns bool. - arccos(input, *, out=None) [same] — Alias of Tensor.acos. - arccosh(input) [same] — Inverse hyperbolic cosine (NaN below 1). - arcsin(input, *, out=None) [same] — Alias of Tensor.asin. - arcsinh(input) [same] — Inverse hyperbolic sine. - arctan(input, *, out=None) [same] — 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) [same] — The angle of (other, input) in (-pi, pi], quadrant by quadrant from atan. - arctanh(input) [same] — Inverse hyperbolic tangent (inf at +-1, NaN outside). - argmax(Tensor self, int? dim=None, bool keepdim=False) -> Tensor [same] — The first index of the maximum (as PyTorch), int64. - argmin(Tensor self, int? dim=None, bool keepdim=False) -> Tensor [same] — Index of the minimum over the flattened tensor or along dim (the first one on ties); int64. - argsort(Tensor self, int dim=-1, bool descending=False, *, bool stable=False) -> Tensor [same] — Indices that sort along dim (descending= for largest first); ties keep their original order. - argwhere(input, *, as_tuple=False) [same] — The indices of the nonzero elements, as an n x ndim int64 tensor or (as_tuple=True) one tensor per dim; argwhere too. - as_strided(input, size, stride, storage_offset=0) [same] — 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_strided_scatter(input, src, size, stride, storage_offset=None) [same] — input with the elements that as_strided(input, size, stride, storage_offset) would view replaced by src. - as_subclass(self, cls) [same] — This tensor's data as an instance of cls (a Tensor subclass); keeps autograd history. - asin(input, *, out=None) [same] — Arcsine, elementwise, as atan2(x, sqrt(1 - x^2)); differentiable. - asinh(input) [same] — Inverse hyperbolic sine. - atan(input, *, out=None) [same] — 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) [same] — The angle of (other, input) in (-pi, pi], quadrant by quadrant from atan. - atanh(input) [same] — Inverse hyperbolic tangent (inf at +-1, NaN outside). - baddbmm(input, batch1, batch2, *, beta=1, alpha=1, out=None) [same] — beta * input + alpha * (batch1 @ batch2), batched. - bernoulli(self, p=None, *, generator=None) [same] — Tensor.bernoulli: torch.bernoulli(self, p). - bincount(input, weights=None, minlength=0) [same] — 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. - bitwise_and(input, other) [same] — Bitwise AND of integers, logical AND of bools (also &, and torch.logical_and on bool casts). - bitwise_left_shift(input, other, *, out=None) [same] — Shift left: input << other, elementwise on integers, wrapping to input's width as PyTorch. - bitwise_not(input) [same] — Bitwise NOT of integers, logical NOT of bools (also ~, and logical_not on bool casts). - bitwise_or(input, other) [same] — Bitwise OR of integers, logical OR of bools (also |, and torch.logical_or on bool casts). - bitwise_right_shift(input, other, *, out=None) [same] — Shift right: input >> other (arithmetic for signed types), elementwise on integers, wrapping to input's width as PyTorch. - bitwise_xor(input, other) [same] — Bitwise XOR of integers, logical XOR of bools (also ^). - bmm(input, mat2, *, out=None) [same] — mm / bmm / mv / dot / inner / outer / addmv / baddbmm / einsum - broadcast_to(input, size) [same] — The tensor expanded to size (-1 keeps a dim), a broadcast view. - ccol_indices(self, *a, **k) [same] — Raises RuntimeError as PyTorch on a dense tensor: ccol_indices needs a sparse column compressed tensor. - ceil(input) [same] — Rounds up to an integer value (the dtype is kept). - chalf(self, memory_format=None) [different] — Raises NotImplementedError: Riptorch has no complex32. Different: Raises NotImplementedError: Riptorch has no complex32. - cholesky(A, upper=False, *, out=None) [same] — torch.cholesky (deprecated in PyTorch): linalg.cholesky(A, upper=upper). - cholesky_inverse(L, upper=False, *, out=None) [same] — torch.cholesky_inverse(L, upper=False): (L L^T)^-1 (or (U^T U)^-1). - cholesky_solve(B, L, upper=False, *, out=None) [same] — torch.cholesky_solve(B, L, upper=False): solves A X = B with A = L L^T (or U^T U). - chunk(Tensor self, int chunks, int dim=0) -> Tensor[] [same] — Splits into chunks of ceil(n / chunks) along dim (the last chunk may be smaller, or fewer chunks may come back), as PyTorch. - clamp(input, min=None, max=None) [same] — Limits values to [min, max] (either may be None; clip too). - clamp_max(input, max) [same] — min(x, max). - clamp_min(input, min) [same] — clamp(input, min=min). - clip(input, min=None, max=None) [same] — Limits values to [min, max] (either may be None; clip too). - coalesce(self, *a, **k) [different] Different: duplicate entries summed in float64 and rounded once: duplicates [1e8, 1, -1e8] give 1.0, PyTorch's float32 sum gives 0.0 - col_indices(self, *a, **k) [same] — Raises RuntimeError as PyTorch on a dense tensor: col_indices needs a sparse row compressed tensor. - conj(self) [same] — self (a real tensor is its own conjugate). - conj_physical(x) [same] — torch.conj_physical(self, *args, **kwargs). - const_data_ptr(self) [same] — data_ptr (Riptorch has no read-only pointer distinction). - copysign(input, other, *, out=None) [same] — abs(input) with the sign of other, elementwise (other's sign bit decides, so -0.0 counts as negative); float. - corrcoef(input) [same] — The Pearson correlation matrix of the rows of input, clamped to [-1, 1]. - cos(input) [different] Different: 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) - cosh(input) [same] — Hyperbolic cosine. - count_nonzero(*a, **k) [same] — The number of non-zero entries (int64), over all or along dim (an int or a tuple). - cov(input, *, correction=1, fweights=None, aweights=None) [same] — The covariance matrix of the rows (variables) of input over its columns (observations); correction=1 is Bessel's; fweights / aweights weight the observations. - cross(input, other, dim=-1) [same] — The 3-d cross product along dim (size 3), broadcasting. - crow_indices(self, *a, **k) [same] — Raises RuntimeError as PyTorch on a dense tensor: crow_indices needs a sparse row compressed tensor. - cummax(input, dim) [same] — Running maximum along dim and the index where it was reached, as (values, indices). - cummin(input, dim) [same] — Running minimum along dim and the index where it was reached, as (values, indices). - cumprod(*a, **k) [same] — Products along dim: for float32, a sequential product of slices (differentiable). - cumsum(self, dim, *, dtype=None) [same] — torch.cumsum(self, dim, dtype=dtype). - deg2rad(input) [same] — Degrees to radians. - dense_dim(self) [same] — dim: every dim of a dense tensor is dense. - dequantize(self) [different] — The float values of a quantized tensor; a float tensor is returned as it is (float16: as float32). Different: 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 - det(A, *, out=None, maths=None, exact=False) [same] - diag(input, diagonal=0) [same] — diag of a 1-d tensor: the square matrix with it on diagonal k; of a 2-d tensor: its diagonal k. - diag_embed(self, offset=0, dim1=-2, dim2=-1) [same] — torch.diag_embed(self, offset, dim1, dim2). - diagflat(input, offset=0) [same] — 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) [same] — Tensor.diagonal / torch.diagonal: the diagonal at offset between dim1 and dim2, moved to the last dim (gradients flow). - diagonal_scatter(input, src, offset=0, dim1=0, dim2=1) [different] — A copy of a 2-d input with its offset diagonal replaced by src. Different: Only 2-d input with dims (0, 1) (or (-2, -1)); others raise NotImplementedError. - diff(*a, **k) [same] — The n-th forward difference along dim, after prepend / append are joined on; bool inputs use !=. - digamma(input, *, out=None) [different] Different: 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 - dim_order(self, *, ambiguity_check=False) [same] — Dims ordered from outermost to innermost in memory (by stride). - dist(input, other, p=2) [same] — The p-norm (default 2) of input - other over all elements. - div(input, other, *, rounding_mode=None) [same] — Division, true by default; rounding_mode="trunc" or "floor" rounds the quotient. - divide(input, other, *, rounding_mode=None) [same] — Division, true by default; rounding_mode="trunc" or "floor" rounds the quotient. - dot(input, other, *, out=None) [same] — The dot product of two 1-d tensors. - dsplit(input, sections) [same] — tensor_split along dim 2. - eig(*a, _m='This function was deprecated since version 1.9 and is now removed. Please use the `torch.linalg.eig` function instead.', **k) [same] — Removed from PyTorch: raises RuntimeError as PyTorch does (This function was deprecated since version 1.9 and is now removed. - eq(input, other) [same] — Elementwise ==, with broadcasting and PyTorch type promotion; returns bool. - equal(input, other) [same] — True if both tensors have the same shape and the same values. - erf(input) [same] — The error function. - erfc(input) [same] — 1 - erf(x), accurate in the upper tail. - erfinv(input, *, out=None) [different] Different: 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 - exp(input) [same] — Elementwise e^x. - exp2(input) [same] — Elementwise 2^x. - expm1(input) [same] — Taylor series below ln 2 / 2, e^x - 1 above: no cancellation near 0. - fix(input) [same] — Rounds toward zero (fix too). - flatten(Tensor self, int start_dim=0, int end_dim=-1) -> Tensor [same] — A reshape (the dims from start_dim to end_dim become one). - flip(*a, **k) [same] — torch.flip(self, dims): dims as a sequence or as separate ints. - fliplr(input) [same] — input reversed along dim 1 (left / right). - flipud(input) [same] — input reversed along dim 0 (up / down). - float_power(self, exponent) [same] — torch.float_power(self, exponent): in float64. - floor(input) [same] — Rounds down to an integer value (the dtype is kept). - floor_divide(input, other, *, out=None) [same] — Division rounded down (torch.div with rounding_mode='floor'); integers stay integers. - fmax(input, other, *, out=None) [same] — Elementwise maximum ignoring NaN: where one side is NaN the other is returned (NaN only when both are). - fmin(input, other, *, out=None) [same] — Elementwise minimum ignoring NaN: where one side is NaN the other is returned (NaN only when both are). - fmod(input, other, *, out=None) [same] — C's fmod, the dividend's sign. - frac(input) [same] — x - trunc(x), keeping the sign. - frexp(input, *, out=None) [same] — (mantissa, exponent) with input = mantissa * 2**exponent and 0.5 <= |mantissa| < 1 (0 for 0). - gather(Tensor self, int dim, Tensor index, *, bool sparse_grad=False) -> Tensor [same] — out[i][j][k] = input[index[i][j][k]][j][k] along dim (any dtype). - gcd(input, other, *, out=None) [same] — Elementwise greatest common divisor of integer tensors, exact (Python integers), in the first input's dtype. - ge(input, other) [same] — Elementwise >=, with broadcasting and PyTorch type promotion; returns bool. - gelu(input, approximate='none', *, maths=None) [extra] — approximate="tanh": 0.5 x (1 + tanh(sqrt(2/pi) (x + 0.044715 x^3))). - geqrf(A, *, out=None) [same] - ger(input, vec2, *, out=None) [same] — torch.ger(self, *args, **kwargs). - get_device(self) [same] — -1, PyTorch's answer for a CPU tensor (Riptorch's memory is unified). - greater(input, other) [same] — torch.greater(self, *args, **kwargs). - greater_equal(input, other) [same] — Alias of Tensor.ge. - gt(input, other) [same] — Elementwise >, with broadcasting and PyTorch type promotion; returns bool. - hardshrink(input, lambd=0.5) [same] — x where |x| > lambd, else 0. - hash_tensor(input, dim=(), *, keepdim=False, mode=0) [same] — XOR of the elements' bit patterns (floats as float64 bits, integers as int64), over dim (all when empty). - heaviside(input, values, *, out=None) [same] — The step function: 0 where input < 0, 1 where input > 0, values where input == 0; input's dtype. - histc(input, bins=100, min=0, max=0, *, out=None) [same] — Counts in `bins` equal-width bins over [min, max] (the data's range when min == max); values outside and nan are skipped. - histogram(input, bins=100, *, range=None, weight=None, density=False, out=None) [same] — torch.histogram(self, *args, **kwargs). - hsplit(input, sections) [same] — tensor_split along dim 1 (dim 0 for a 1-d input). - hspmm(self, mat2) [extra] — torch.hspmm(self, mat2): sparse self @ dense mat2 as a hybrid COO tensor. - hypot(input, other) [same] — sqrt(a^2 + b^2) elementwise. - i0(input, *, out=None) [different] Different: correctly rounded float32 values (computed in float64, rounded once); 1500 inputs in [0, 75]: worst 3 ulp vs 0; MLX has no i0 - igamma(input, other, *, out=None) [same] — The regularized lower incomplete gamma function P(a, x) (input a, other x), in float64 and rounded once. - igammac(input, other, *, out=None) [same] — The regularized upper incomplete gamma function Q(a, x) = 1 - P(a, x), in float64 and rounded once. - index(self, positions, dims) [different] — Binds dims to first-class Dim objects (functorch.dim) in PyTorch; not supported: NotImplementedError. Different: Binds dims to first-class Dim objects (functorch.dim) in PyTorch; not supported: NotImplementedError. - index_add(input, dim, index, source, *, alpha=1) [different] Different: repeated indices summed in float64 and rounded once: [1e8, 1, -1e8] at one index gives 1.0, PyTorch's float32 sum gives 0.0 - index_copy(input, dim, index, source) [same] — A copy of input with source's slices written at index along dim. - index_fill(input, dim, index, value) [same] — A copy of input with value written into the slices at index along dim. - index_put(input, indices, values, accumulate=False) [different] Different: accumulate=True sums repeated positions in float64 and rounds once: [1e8, 1, -1e8] at one position gives 1.0, PyTorch gives 0.0 - index_reduce(self, dim, index, source, reduce, *, include_self=True) [same] — 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. - index_select(*a, **k) [same] — The slices of input along dim at index (1-d, int); differentiable. - indices(self, *a, **k) [same] — Raises RuntimeError as PyTorch on a dense tensor: indices needs a sparse coordinate tensor. - inner(input, other, *, out=None) [same] — Inner product over the last dims (a scalar input multiplies). - int_repr(input) [same] — The stored integers of a quantized tensor (raises for a float tensor, as PyTorch). - inverse(self) [same] — linalg.inv(self) (integer tensors give the exact inverse as a FractionTensor). - ipu(self, device=None, non_blocking=False, memory_format=None) [same] — Raises RuntimeError: no IPU support (PyTorch's message). - is_coalesced(self, *a, **k) [same] — Raises RuntimeError as PyTorch on a dense tensor: is_coalesced needs a sparse coordinate tensor. - is_complex(self) [same] — Whether this is a complex tensor. - is_conj(self) [same] — False: Riptorch never keeps a lazy conjugate bit. - is_distributed(self) [same] — False (no distributed tensors). - is_floating_point(input) [same] - is_inference(self) [same] — False: Riptorch makes no inference tensors. - is_neg(self) [same] — False: Riptorch never keeps a lazy negation bit. - is_nonzero(self) [same] — The truth value of a one-element tensor; more elements raise RuntimeError as PyTorch. - is_pinned(self, *a) [same] — False: unified memory, nothing is pinned. - is_same_size(self, other) [same] — Whether other has self's shape. - is_set_to(self, t) [same] — Whether t is this very tensor (Riptorch tensors never share storage). - is_shared(self) [same] — False: Riptorch tensors are not in shared memory (they cross processes by copy). - is_signed(self) [same] — Whether the dtype holds negative values (floats and signed integers). - isclose(input, other, rtol=1e-05, atol=1e-08, equal_nan=False) [same] — |input - other| <= atol + rtol * |other| elementwise (equal_nan=True counts NaN == NaN); returns bool. - isfinite(input) [same] — 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) [extra] — torch.isin(self, *args, **kwargs). - isinf(input) [same] — True where the element is +inf or -inf (always False for integer and bool tensors). - isnan(input) [same] — Tensor.isnan / torch.isnan: True where the element is NaN (x != x); always False for integer and bool tensors. - isneginf(x) [same] — torch.isneginf(self, *args, **kwargs). - isposinf(x) [same] — torch.isposinf(self, *args, **kwargs). - isreal(self) [same] — Elementwise: True where the imaginary part is zero (all True for real tensors). - istft(input, n_fft, hop_length=None, win_length=None, window=None, center=True, normalized=False, onesided=None, length=None, return_complex=False) [same] — Inverse of stft: the inverse FFT of each frame, windowed, overlap-added and divided by the summed squared window. - kron(input, other, *, out=None) [same] — torch.kron(a, b): the Kronecker product (dims aligned from the right), differentiable. - kthvalue(Tensor self, int k, int dim=-1, bool keepdim=False) -> (Tensor values, Tensor indices) [same] — The k-th smallest (1-based); among equal values the one the stable order puts k-th. - lcm(input, other, *, out=None) [same] — Elementwise least common multiple of integer tensors (0 where either is 0), in the first input's dtype. - ldexp(input, other, *, out=None) [same] — input * 2**other, elementwise, as a float tensor. - le(input, other) [same] — Elementwise <=, with broadcasting and PyTorch type promotion; returns bool. - lerp(input, end, weight) [same] — input + weight * (end - input). - less(input, other) [same] — torch.less(self, *args, **kwargs). - less_equal(input, other) [same] — Alias of Tensor.le. - lgamma(input, *, out=None) [same] — log|Gamma(x)|, per element: computed in float64 and rounded once to the input's float dtype (integer inputs give float32); differentiable. - log(input) [same] — Elementwise natural log (-inf at 0, NaN below 0). - log10(input) [same] — Elementwise log base 10. - log1p(input) [same] — 2 atanh(x / (2 + x)) below 1/4, log(1 + x) with the rounding of 1 + x put back above. - log2(input) [same] — Elementwise log base 2. - log_softmax(Tensor input, int? dim=None, *, dtype? dtype=None) -> Tensor [same] — log(softmax(x)) along dim, computed stably (x - logsumexp); dtype= casts the input first. - logaddexp(input, other) [same] — log(exp(a) + exp(b)) computed stably. - logaddexp2(input, other, *, out=None) [same] — log2(2^input + 2^other) without overflow: max + log2(1 + 2^-|input - other|). - logcumsumexp(*a, **k) [same] — log(cumsum(exp(input))) along dim, shifted by the maximum so large values don't overflow; integer inputs give float32 (PyTorch raises for them). - logdet(A) [same] — torch.logdet(A): log det A (nan for a negative determinant, -inf for zero). - logical_and(input, other, *, out=None) [same] — Elementwise AND of the inputs' truth values (nonzero is True); bool. - logical_not(*args, **kw) [same] — logical_not: the inputs as bool, then bitwise_not (a bool result, as PyTorch's logical ops). - logical_or(input, other, *, out=None) [same] — Elementwise OR of the inputs' truth values (nonzero is True); bool. - logical_xor(input, other, *, out=None) [same] — Elementwise XOR of the inputs' truth values (nonzero is True); bool. - logit(input) [same] — log(x / (1 - x)). - logsumexp(input, dim=None, keepdim=False, *, out=None) [different] — log(sum(exp(x))) over dim with the largest value taken out first; out= written. Different: dim=[] reduces every dim, as sum(dim=[]) does; PyTorch CPU and MPS raise RuntimeError - lstsq(*a, _m='torch.lstsq is deprecated in favor of torch.linalg.lstsq and will be removed in a future PyTorch release.', **k) [same] — 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.) - lt(input, other) [same] — Elementwise <, with broadcasting and PyTorch type promotion; returns bool. - lu(self, pivot=True, get_infos=False) [same] — (LU, pivots) from linalg.lu_factor, plus zero infos with get_infos=True (deprecated in PyTorch). - lu_solve(b, LU_data, LU_pivots, *, out=None) [same] — torch.lu_solve(b, LU_data, LU_pivots) (deprecated in PyTorch): linalg.lu_solve with the arguments in the old order. - masked_fill(input, mask, value) [same] — value where mask is true, else the input; the result keeps the input's dtype. - masked_scatter(input, mask, source) [same] — 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) [same] — The elements of input where mask (broadcast with it) is True, as a 1-d tensor in row-major order. - matmul(input, other) [different] Different: 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) - matrix_exp(A) [same] — linalg.matrix_exp(A): Pade-13 scaling and squaring (Higham 2005). - matrix_power(A, n, *, out=None) [same] — linalg.matrix_power(A, n): repeated squaring (n < 0: of the inverse); n = 0 gives the identity. - max(*a, **k) [same] — max(Tensor self, dim=None, bool keepdim=False) - maximum(input, other) [same] — Elementwise maximum of two tensors; a NaN in either input gives NaN, as in PyTorch. - mean(Tensor self, int[]? dim=None, bool keepdim=False, *, dtype? dtype=None) -> Tensor [same] — Mean over all elements or along dim; dtype= casts first. - median(input, dim=None, keepdim=False, *, out=None) [same] — The lower median (PyTorch's: not the mean of the two middle values), and with dim its index; NaN propagates. - min(*a, **k) [same] — min(Tensor self, dim=None, bool keepdim=False) - minimum(input, other) [same] — Elementwise minimum of two tensors; a NaN in either input gives NaN, as in PyTorch. - mm(input, mat2, *, out=None) [different] — Matrix product of two 2-d tensors; a sparse operand goes to the sparse product (dense result for sparse @ dense, as PyTorch). Different: exact integer products like torch.matmul; PyTorch keeps the input dtype and wraps (200 of 200 int8 entries wrong on 10x64 @ 64x20) - mode(input, dim=-1, keepdim=False, *, out=None) [same] — The most frequent value along dim (the smallest on ties) and an index of it (its last occurrence, as PyTorch's CPU). - module_load(self, other, assign=False) [same] — What load_state_dict copies into this parameter: other (detached when assign=True). - moveaxis(input, source, destination) [same] — input with the dims at source moved to destination (ints or sequences), the others in order; a view. - movedim(*a, **k) [same] — input with the dims at source moved to destination (ints or sequences), the others in order; a view. - msort(input) [same] — Sorts along dim 0 (ascending). - mtia(self, device=None, non_blocking=False, memory_format=None) [same] — Raises AssertionError: no MTIA (as PyTorch does on a Mac). - mul(input, other) [same] — Elementwise product, with broadcasting and PyTorch type promotion. - multinomial(self, num_samples, replacement=False, *, generator=None) [same] — Tensor.multinomial: torch.multinomial(self, num_samples, replacement). - multiply(input, other) [same] — torch.multiply(self, *args, **kwargs). - mv(input, vec, *, out=None) [same] — Matrix-vector product (2-d @ 1-d); other ranks raise as PyTorch. - mvlgamma(input, p, *, out=None) [same] — 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) [same] — NaN, +inf and -inf replaced by nan, posinf and neginf (default: 0 and the dtype's largest / smallest finite values). - nanmean(input, dim=None, keepdim=False, *, dtype=None, out=None) [same] — Mean of the non-NaN elements, over dim or over all elements (NaN where every element is NaN). - nanmedian(input, dim=None, keepdim=False, *, out=None) [same] — The lower median of the non-NaN elements (NaN only when all are NaN); with dim, (values, indices). - nanquantile(input, q, dim=None, keepdim=False, *, interpolation='linear', out=None) [same] — quantile ignoring NaN: NaN only where a row has no other values. - nansum(input, dim=None, keepdim=False, *, dtype=None) [same] — Sum with NaN counted as zero, over dim or over all elements. - narrow(Tensor self, int dim, int start, int length) -> Tensor [same] — The slice [start, start + length) along dim. - narrow_copy(self, dim, start, length) [same] — narrow(dim, start, length) as a new tensor. - ndimension(self) [same] — The number of dimensions (ndimension too). - ne(input, other) [same] — Elementwise !=, with broadcasting and PyTorch type promotion; returns bool. - neg(input) [same] — -x. - negative(input) [same] — -x (alias of neg). - new(self, *args) [same] — Legacy constructor in self's dtype: new(data_list) builds from data, new(*size) a zero-filled tensor. - new_empty_strided(self, size, stride, *, dtype=None, **kw) [same] — A zero-filled tensor of size in self's dtype; stride is ignored (contiguous layout). - nextafter(input, other, *, out=None) [same] — 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. - nonzero(self, *, as_tuple=False) [same] — torch.nonzero(self, as_tuple=as_tuple). - nonzero_static(input, *, size, fill_value=-1) [same] — nonzero cut or padded to exactly size rows (padding rows filled with fill_value), int64 (n, input.dim). - norm(self, p: float | str | None = 'fro', dim=None, keepdim=False, dtype=None) [same] — 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. - not_equal(input, other) [same] — Alias of Tensor.ne. - orgqr(A, tau, *, out=None) [same] — linalg.householder_product(A, tau): the first n columns of H_1... - ormqr(input, tau, other, left=True, transpose=False, *, out=None) [same] — torch.ormqr(a, tau, C, left=True, transpose=False): C multiplied by Q from geqrf's reflectors. - outer(input, vec2, *, out=None) [same] — The outer product of two vectors (ger too). - permute(input, *dims) [same] — Reorders the dimensions. - pin_memory(self, *args, **kwargs) [same] — Tensor.cpu / cuda / mps / pin_memory: the tensor itself (one unified memory and one layout). - pinverse(input, rcond=1e-15) [same] — torch.pinverse: linalg.pinv with rtol=rcond. - polygamma(self, n) [same] — torch.polygamma(n, self): the n-th derivative of digamma. - positive(input) [same] — x unchanged. - pow(self, exponent) [same] — torch.pow(self, exponent). - prelu(self, weight) [same] — nn.functional.prelu(self, weight). - prod(input, dim=None, keepdim=False, *, dtype=None) [same] — Product of the elements, over dim or over all of them; dtype= casts first. - put(input, index, source, accumulate=False) [same] — A copy of input with the flat positions index set to source's values (accumulate=True: added instead). - q_per_channel_axis(input) [same] — The per-channel axis of a quantized tensor (raises for a float tensor, as PyTorch). - q_per_channel_scales(input) [same] — The per-channel scales of a quantized tensor (raises for a float tensor, as PyTorch). - q_per_channel_zero_points(input) [same] — The per-channel zero points of a quantized tensor (raises for a float tensor). - q_scale(input) [same] — The scale of a per-tensor quantized tensor (raises for a float tensor, as PyTorch). - q_zero_point(input) [same] — The zero point of a per-tensor quantized tensor (raises for a float tensor, as PyTorch). - qr(A, some=True, *, out=None) [same] — torch.qr (deprecated in PyTorch): linalg.qr with mode 'reduced' (some=True) or 'complete'. - qscheme(name) [same] — The quantization scheme of a quantized tensor (raises for a float tensor, as PyTorch). - quantile(input, q, dim=None, keepdim=False, *, interpolation='linear', out=None, _nan=False) [same] — The q-th quantiles (q a float or a 1-d tensor, each in [0, 1]) over dim or over all elements. - rad2deg(input) [same] — Radians to degrees. - ravel(input) [same] — input flattened to 1-d. - reciprocal(input) [same] — 1 / x. - record_stream(self, stream) [same] — Nothing to do: Riptorch has no device streams to track. - register_post_accumulate_grad_hook(self, hook) [same] - reinforce(self, reward) [same] — Removed in PyTorch: raises its RuntimeError (use torch.distributions). - relu(input, inplace=False) [same] — max(x, 0). - remainder(input, other, *, out=None) [different] Different: 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) - renorm(input, p, dim, maxnorm) [same] — 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(input, *repeats) [same] — Tensor.repeat: the tensor tiled repeats[i] times along each dim (leading new dims allowed); lazy, gradients summed back. - repeat_interleave(self, repeats=None, dim=None, *, output_size=None) [same] — torch.repeat_interleave(self, repeats, dim). - resize(self, *size) [same] — A tensor of the given size from self's elements in row-major order, cut short or extended with zeros (deprecated in PyTorch; a new tensor here). - resize_as(self, other) [same] — resize to other's shape. - resolve_conj(self) [same] — self: there is never a lazy conjugate or negation to resolve. - resolve_neg(self) [same] — self: there is never a lazy conjugate or negation to resolve. - roll(Tensor input, int[] shifts, int[] dims=()) -> Tensor [same] — Each dim rotated by its shift: two narrows joined by cat. - rot90(input, k=1, dims=(0, 1)) [same] — input rotated by 90 degrees k times in the plane of dims, from the first dim towards the second. - round(self, decimals=0) [same] — torch.round(self, decimals=decimals). - row_indices(self, *a, **k) [same] — Raises RuntimeError as PyTorch on a dense tensor: row_indices needs a sparse column compressed tensor. - rsqrt(input) [same] — Classic only: as an elementwise op it has no rational form (the rational RMSNorm is a module-level row). - scatter(input, dim, index, src=None, *, value=None, reduce=None) [same] — 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) [same] — scatter with reduce='add': repeated indices accumulate. - scatter_reduce(input, dim, index, src, reduce, *, include_self=True) [same] — 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. - select(*a, **k) [same] — The slice at index along dim, with dim removed; negative indices count from the end; IndexError outside. - select_scatter(input, src, dim, index) [same] — A copy of input with input.select(dim, index) replaced by src. - sgn(input) [same] — -1, 0 or 1 by sign (sgn too). - sigmoid(input, *, maths=None) [same] — 1 / (1 + exp(-x)). - sign(self) [same] — torch.sign(self): +-1, 0 for 0 and NaN (as PyTorch). - signbit(input, *, out=None) [same] — True where the sign bit is set: negative values and -0.0 (integers: x < 0). - sin(input) [different] Different: 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) - sinc(input, *, out=None) [same] - sinh(input) [same] — Hyperbolic sine. - slice_inverse(input, src, dim=0, start=None, end=None, step=1) [same] — The base a slice was taken from (for functionalization): src, viewed as itself. - slice_scatter(input, src, dim=0, start=None, end=None, step=1) [same] — A copy of input with the slice start:end:step of dim replaced by src. - slogdet(A, *, out=None, maths=None) [same] - smm(self, mat2) [same] — torch.smm(self, mat2): sparse self @ dense mat2, returned sparse (a dense self raises). - softmax(Tensor input, int? dim=None, *, dtype? dtype=None) -> Tensor [same] — Also takes NumPy's axis= / keepdims= for dim= / keepdim=, as PyTorch. - solve(*a, _m='torch.solve is deprecated in favor of torch.linalg.solve and will be removed in a future PyTorch release.', **k) [same] — 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.) - sort(Tensor self, int dim=-1, bool descending=False, *, bool? stable=False) -> (Tensor values, Tensor indices) [same] — Always stable (equal values keep their order), so stable=False gives the stable order too. - sparse_dim(self) [same] — 0: a dense tensor has no sparse dims. - sparse_mask(d, mask) [same] — dense.sparse_mask(mask): mask's pattern with d's values there. - split(Tensor self, split_size_or_sections, int dim=0) -> Tensor[] [same] — Pieces are narrows: lazy views with gradients on float32 tensors. - split_with_sizes(input, split_sizes, dim=0) [same] — Consecutive pieces of input along dim with the given sizes, as a tuple. - sqrt(input) [same] — Elementwise square root (NaN below 0). - square(input) [same] — x * x. - squeeze(Tensor self, dim=None) -> Tensor [same] — Removes size-1 dimensions (all, or the given dim / dims when they have size 1). - sspaddmm(self, mat1, mat2, *, beta=1, alpha=1) [same] — torch.sspaddmm(self, mat1, mat2): beta * self + alpha * (mat1 @ mat2), sparse. - std(input, dim=None, unbiased=None, keepdim=False, *, correction=None, out=None) [same] — Standard deviation over dim (all elements when dim is None): the square root of torch.var. - 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) [same] — Short-time Fourier transform of a 1-d signal or a batch of them, through torch.fft. - storage_offset(self) [same] — 0: a Riptorch tensor always starts at the beginning of its own storage. - storage_type(self) [same] — The legacy storage class of this tensor's dtype (torch.FloatStorage for float32,...). - sub(input, other, *, alpha=1) [same] — self - alpha * other, with broadcasting and PyTorch type promotion. - subtract(input, other, *, alpha=1) [same] — torch.subtract(self, *args, **kwargs). - sum(*a, **k) [different] Different: 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) - sum_to_size(input, *size) [same] — input summed down to size: leading extra dims summed away, dims that are 1 in size summed with keepdim (the reverse of broadcasting). - svd(A, some=True, compute_uv=True, *, out=None) [same] — 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. - swapaxes(Tensor self, int dim0, int dim1) -> Tensor [same] — Swaps two dimensions (swapaxes too). - swapdims(Tensor self, int dim0, int dim1) -> Tensor [same] — Alias of Tensor.transpose. - symeig(*a, _m='This function was deprecated since version 1.9 and is now removed. Please use the `torch.linalg.eigh` function instead.', **k) [same] — Removed from PyTorch: raises RuntimeError as PyTorch does (This function was deprecated since version 1.9 and is now removed. - t(self) [same] — The transpose of a 2-d tensor; 0-d and 1-d tensors are returned as they are; more dims raise. - take(input, index) [same] — input's elements at the given flat indices (input read as 1-d), shaped like index. - take_along_dim(*a, **k) [same] — input's values at indices along dim, input and indices broadcast on the other dims; dim=None takes from the flattened input. - tan(input) [same] — Elementwise tangent. - tanh(input, *, maths=None) [same] - tensor_split(input, indices_or_sections, dim=0) [same] — 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) [same] — input repeated dims[i] times along each dimension; a dims shorter than input's rank is padded with leading 1s. - to_dense(self, dtype=None, *, masked_grad=None) [different] Different: duplicate entries summed in float64 and rounded once: duplicates [1e8, 1, -1e8] give 1.0, PyTorch gives 0.0 - to_mkldnn(self, dtype=None) [same] — Raises RuntimeError("MKL-DNN build is disabled"), as PyTorch does on a Mac. - to_padded_tensor(self, padding, output_size=None) [same] — torch.nested.to_padded_tensor(self, padding, output_size) (a dense self raises as PyTorch). - to_sparse(self, *args, layout=None, blocksize=None, dense_dim=None) [same] — This dense tensor as a sparse one: COO by default (args[0] = sparse_dim: the leading dims that become sparse), or layout= (blocksize= for BSR / BSC). - to_sparse_bsc(self, blocksize, dense_dim=None) [same] — This dense tensor in the BSC sparse layout (zeros not stored; blocksize = (rows, cols)). - to_sparse_bsr(self, blocksize, dense_dim=None) [same] — This dense tensor in the BSR sparse layout (zeros not stored; blocksize = (rows, cols)). - to_sparse_coo(self) [same] — This dense tensor in the COO sparse layout (zeros not stored). - to_sparse_csc(self, dense_dim=None) [same] — This dense tensor in the CSC sparse layout (zeros not stored). - to_sparse_csr(self, dense_dim=None) [same] — This dense tensor in the CSR sparse layout (zeros not stored). - topk(Tensor self, int k, int dim=-1, bool largest=True, bool sorted=True) -> (Tensor values, Tensor indices) [same] — Partial selection on every core (no full sort for small k) or the GPU; values keep gradients. - trace(input) [same] — The sum of the main diagonal. - transpose(Tensor self, int dim0, int dim1) -> Tensor [same] — Swaps two dimensions (swapaxes too). - triangular_solve(b, A, upper=True, transpose=False, unitriangular=False, *, out=None) [same] — torch.triangular_solve(b, A, upper=True, transpose=False, unitriangular=False) (deprecated in PyTorch). - tril(self, diagonal=0) [same] — torch.tril(self, diagonal). - triu(self, diagonal=0) [same] — torch.triu(self, diagonal). - true_divide(input, other, *, rounding_mode=None) [same] — Division, true by default; rounding_mode="trunc" or "floor" rounds the quotient. - trunc(input) [same] — Rounds toward zero (fix too). - unbind(*a, **k) [same] — A tuple of the slices along dim, each without dim. - unflatten(input, dim, sizes) [same] — input with dim replaced by the given sizes (one of them may be -1). - unfold(input, dimension, size, step) [same] — Tensor.unfold: every window of `size` along `dimension`, `step` apart, as a new last dim. - unique(input, sorted=True, return_inverse=False, return_counts=False, dim=None) [same] — The distinct values (or distinct slices along dim), sorted; optionally the inverse indices and the counts. - unique_consecutive(input, return_inverse=False, return_counts=False, dim=None) [different] — input with runs of equal consecutive values collapsed to one; optionally the inverse indices and run lengths. Different: input with runs of equal consecutive values collapsed to one; optionally the inverse indices and run lengths. dim= raises NotImplementedError. - unsafe_chunk(self, chunks, dim=0) [same] — chunk (the same pieces; nothing is unsafe here). - unsafe_split(self, split_size, dim=0) [same] — split (the same pieces; nothing is unsafe here). - unsafe_split_with_sizes(self, sizes, dim=0) [same] — split_with_sizes (the same pieces; nothing is unsafe here). - unsqueeze(Tensor self, int dim) -> Tensor [same] — Inserts a size-1 dimension at dim (negative dims count from the end of the result). - values(self) [same] — Raises RuntimeError as PyTorch on a dense tensor: values needs a sparse tensor. - var(Tensor self, int[]? dim=None, *, float correction=1, bool keepdim=False, bool? unbiased=None) -> Tensor [same] — Variance over all elements or along dim with Bessel's correction (correction=, or unbiased=). - vdot(input, other, *, out=None) [same] — Dot product of the flattened inputs: sum(input * other). - vsplit(input, sections) [same] — tensor_split along dim 0. - where(self, condition, other) [same] — Tensor.where(condition, other): self where condition holds, else other. - xlogy(input, other) [same] — x * log(y), 0 where x is 0. - xpu(self, device=None, non_blocking=False, memory_format=None) [same] — Raises AssertionError: no XPU (as PyTorch does on a Mac). ### In-place methods - abs_(input) [same] — In-place form: the out-of-place result written into self. - absolute_(input) [same] — absolute in place: self takes the result of absolute(self,...); returns self. - acos_(input, *, out=None) [same] — acos in place: self takes the result of acos(self,...); returns self. - acosh_(input) [same] — acosh in place: self takes the result of acosh(self,...); returns self. - add_(input, other, *, alpha=1) [same] — In-place form: the out-of-place result written into self. - addbmm_(self, b1, b2, *, beta=1, alpha=1) [same] — addbmm in place on self; returns self. - addcdiv_(input, tensor1, tensor2, *, value=1) [same] — In-place form: the out-of-place result written into self. - addcmul_(input, tensor1, tensor2, *, value=1) [same] — In-place form: the out-of-place result written into self. - addmm_(input, mat1, mat2, *, beta=1, alpha=1) [same] — addmm in place: self takes the result of addmm(self,...); returns self. - addmv_(input, mat, vec, *, beta=1, alpha=1, out=None) [same] — addmv in place: self takes the result of addmv(self,...); returns self. - addr_(input, vec1, vec2, *, beta=1, alpha=1, out=None) [same] — addr in place: self takes the result of addr(self,...); returns self. - apply_(self, fn) [same] — In place: each element x becomes fn(x) (a Python callable, run on the values read back). - arccos_(input, *, out=None) [same] — arccos in place: self takes the result of arccos(self,...); returns self. - arccosh_(input) [same] — arccosh in place: self takes the result of arccosh(self,...); returns self. - arcsin_(input, *, out=None) [same] — arcsin in place: self takes the result of arcsin(self,...); returns self. - arcsinh_(input) [same] — arcsinh in place: self takes the result of arcsinh(self,...); returns self. - arctan2_(input, other, *, out=None) [same] — arctan2 in place: self takes the result of arctan2(self,...); returns self. - arctan_(input, *, out=None) [same] — arctan in place: self takes the result of arctan(self,...); returns self. - arctanh_(input) [same] — arctanh in place: self takes the result of arctanh(self,...); returns self. - as_strided_(input, size, stride, storage_offset=None) [same] — In-place as_strided: the tensor becomes the strided view's values (Riptorch copies; no shared storage). - asin_(input, *, out=None) [same] — asin in place: self takes the result of asin(self,...); returns self. - asinh_(input) [same] — asinh in place: self takes the result of asinh(self,...); returns self. - atan2_(input, other, *, out=None) [same] — In-place Tensor.atan2: the result written into self (self's dtype kept). - atan_(input, *, out=None) [same] — In-place Tensor.atan: the result written into self (self's dtype kept). - atanh_(input) [same] — atanh in place: self takes the result of atanh(self,...); returns self. - baddbmm_(input, batch1, batch2, *, beta=1, alpha=1, out=None) [same] — baddbmm in place: self takes the result of baddbmm(self,...); returns self. - bernoulli_(self, p=0.5, *, generator=None) [same] — Tensor.bernoulli_(p=0.5): fills with 1 with probability p (a float or a tensor broadcast to self), else 0. - bitwise_and_(input, other) [same] — bitwise_and in place: self takes the result of bitwise_and(self,...); returns self. - bitwise_left_shift_(self, other) [same] — bitwise_left_shift in place; returns self. - bitwise_not_(input) [same] — bitwise_not in place: self takes the result of bitwise_not(self,...); returns self. - bitwise_or_(input, other) [same] — bitwise_or in place: self takes the result of bitwise_or(self,...); returns self. - bitwise_right_shift_(self, other) [same] — bitwise_right_shift in place; returns self. - bitwise_xor_(input, other) [same] — bitwise_xor in place: self takes the result of bitwise_xor(self,...); returns self. - cauchy_(self, median=0.0, sigma=1.0, *, generator=None) [same] — Tensor.cauchy_(median=0, sigma=1): fills with Cauchy draws, median + sigma tan(pi (U - 1/2)). - ceil_(input) [same] — ceil in place: self takes the result of ceil(self,...); returns self. - clamp_(input, min=None, max=None) [same] — In-place form: the out-of-place result written into self. - clamp_max_(input, max) [same] — clamp_max in place: self takes the result of clamp_max(self,...); returns self. - clamp_min_(input, min) [same] — In-place form: the out-of-place result written into self. - clip_(input, min=None, max=None) [same] — clip in place: self takes the result of clip(self,...); returns self. - conj_physical_(input) [same] — In-place conjugate; real tensors are returned unchanged. - copy_(self, src, non_blocking=False) [same] — Writes src (broadcast, converted to this dtype) into this tensor in place; a view writes through. - copysign_(input, other, *, out=None) [same] — copysign in place: self takes the result of copysign(self,...); returns self. - cos_(input) [different] — cos in place: self takes the result of cos(self,...); returns self. Different: 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) - cosh_(input) [same] — cosh in place: self takes the result of cosh(self,...); returns self. - cumprod_(self, *a, **k) [same] — In-place Tensor.cumprod: the result written into self (self's dtype kept). - cumsum_(self, dim, *, dtype=None) [same] — In-place torch.cumsum(self, dim, dtype=dtype); the dtype is kept. - deg2rad_(input) [same] — deg2rad in place: self takes the result of deg2rad(self,...); returns self. - digamma_(self) [different] — In-place torch.digamma: the result written into self (self's dtype kept). Different: 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 - div_(input, other, *, rounding_mode=None) [same] — In-place form: the out-of-place result written into self. - divide_(input, other, *, rounding_mode=None) [same] — divide in place: self takes the result of divide(self,...); returns self. - eq_(input, other) [same] — eq in place: self takes the result of eq(self,...); returns self. - erf_(input) [same] — erf in place: self takes the result of erf(self,...); returns self. - erfc_(input) [same] — erfc in place: self takes the result of erfc(self,...); returns self. - erfinv_(self) [different] — In-place torch.erfinv: the result written into self (self's dtype kept). Different: 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 - exp2_(input) [same] — exp2 in place: self takes the result of exp2(self,...); returns self. - exp_(input) [same] — In-place form: the out-of-place result written into self. - expm1_(input) [same] — expm1 in place: self takes the result of expm1(self,...); returns self. - exponential_(self, lambd=1.0, *, generator=None) [same] — Tensor.exponential_(lambd=1): fills with Exponential(rate lambd) draws, -log1p(-U) / lambd. - fill_(tensor, val) [same] — Fills the tensor in place with val (Tensor.fill_ too). - fill_diagonal_(self, fill_value, wrap=False) [same] — In place: the main diagonal (all indices equal) set to fill_value; wrap=True continues a tall 2-d matrix's diagonal every ncols + 1 rows, as PyTorch. - fix_(input) [same] — fix in place: self takes the result of fix(self,...); returns self. - float_power_(input, exponent) [same] — float_power in place: self takes the result of float_power(self,...); returns self. - floor_(input) [same] — floor in place: self takes the result of floor(self,...); returns self. - floor_divide_(input, other, *, out=None) [same] — In-place Tensor.floor_divide: the result written into self (self's dtype kept). - fmod_(input, other, *, out=None) [same] — In-place Tensor.fmod: the result written into self (self's dtype kept). - frac_(input) [same] — In-place Tensor.frac: the result written into self (self's dtype kept). - gcd_(input, other, *, out=None) [same] — gcd in place: self takes the result of gcd(self,...); returns self. - ge_(input, other) [same] — ge in place: self takes the result of ge(self,...); returns self. - geometric_(self, p, *, generator=None) [same] — Tensor.geometric_(p): fills with Geometric(p) draws (trials to the first success, from 1). - greater_(input, other) [same] — greater in place: self takes the result of greater(self,...); returns self. - greater_equal_(input, other) [same] — greater_equal in place: self takes the result of greater_equal(self,...); returns self. - gt_(input, other) [same] — gt in place: self takes the result of gt(self,...); returns self. - heaviside_(input, values, *, out=None) [same] — heaviside in place: self takes the result of heaviside(self,...); returns self. - hypot_(input, other) [same] — hypot in place: self takes the result of hypot(self,...); returns self. - i0_(self) [different] — In-place torch.i0: the result written into self (self's dtype kept). Different: correctly rounded float32 values (computed in float64, rounded once); 1500 inputs in [0, 75]: worst 3 ulp vs 0; MLX has no i0 - igamma_(input, other, *, out=None) [same] — igamma in place: self takes the result of igamma(self,...); returns self. - igammac_(input, other, *, out=None) [same] — igammac in place: self takes the result of igammac(self,...); returns self. - index_add_(input, dim, index, source, *, alpha=1) [different] — In-place Tensor.index_add: the result written into self (self's dtype kept). Different: repeated indices summed in float64 and rounded once: [1e8, 1, -1e8] at one index gives 1.0, PyTorch's float32 sum gives 0.0 - index_copy_(input, dim, index, source) [same] — In-place Tensor.index_copy: the result written into self (self's dtype kept). - index_fill_(input, dim, index, value) [same] — In-place Tensor.index_fill: the result written into self (self's dtype kept). - index_put_(input, indices, values, accumulate=False) [different] — index_put in place: self takes the result of index_put(self,...); returns self. Different: accumulate=True sums repeated positions in float64 and rounds once: [1e8, 1, -1e8] at one position gives 1.0, PyTorch gives 0.0 - index_reduce_(self, dim, index, source, reduce, *, include_self=True) [same] — index_reduce in place; returns self. - lcm_(input, other, *, out=None) [same] — lcm in place: self takes the result of lcm(self,...); returns self. - ldexp_(input, other, *, out=None) [same] — ldexp in place: self takes the result of ldexp(self,...); returns self. - le_(input, other) [same] — le in place: self takes the result of le(self,...); returns self. - lerp_(input, end, weight) [same] — In-place form: the out-of-place result written into self. - less_(input, other) [same] — less in place: self takes the result of less(self,...); returns self. - less_equal_(input, other) [same] — less_equal in place: self takes the result of less_equal(self,...); returns self. - lgamma_(self) [same] — In-place torch.lgamma: the result written into self (self's dtype kept). - log10_(input) [same] — log10 in place: self takes the result of log10(self,...); returns self. - log1p_(input) [same] — log1p in place: self takes the result of log1p(self,...); returns self. - log2_(input) [same] — log2 in place: self takes the result of log2(self,...); returns self. - log_(input) [same] — log in place: self takes the result of log(self,...); returns self. - log_normal_(self, mean=1.0, std=2.0, *, generator=None) [same] — Tensor.log_normal_(mean=1, std=2): fills with exp(N(mean, std)) draws. - logical_and_(self, *a, **k) [same] — logical_and in place: self takes the result of logical_and(self,...); returns self. - logical_not_(self, *a, **k) [same] — logical_not in place: self takes the result of logical_not(self,...); returns self. - logical_or_(self, *a, **k) [same] — logical_or in place: self takes the result of logical_or(self,...); returns self. - logical_xor_(input, other, *, out=None) [same] — logical_xor in place: self takes the result of logical_xor(self,...); returns self. - logit_(input) [same] — logit in place: self takes the result of logit(self,...); returns self. - lt_(input, other) [same] — lt in place: self takes the result of lt(self,...); returns self. - map2_(self, x, y, fn) [same] — In place: each element a becomes fn(a, b, c), b and c the matching elements of x and y broadcast to self. - map_(self, other, fn) [same] — In place: each element x becomes fn(x, y), y the matching element of other broadcast to self. - masked_fill_(input, mask, value) [same] — masked_fill in place. - masked_scatter_(input, mask, source) [same] — masked_scatter in place: self takes the result of masked_scatter(self,...); returns self. - mul_(input, other) [same] — In-place form: the out-of-place result written into self. - multiply_(input, other) [same] — multiply in place: self takes the result of multiply(self,...); returns self. - mvlgamma_(input, p, *, out=None) [same] — mvlgamma in place: self takes the result of mvlgamma(self,...); returns self. - nan_to_num_(input, nan=0.0, posinf=None, neginf=None) [same] — nan_to_num in place: self takes the result of nan_to_num(self,...); returns self. - ne_(input, other) [same] — ne in place: self takes the result of ne(self,...); returns self. - neg_(input) [same] — In-place form: the out-of-place result written into self. - negative_(input) [same] — negative in place: self takes the result of negative(self,...); returns self. - nextafter_(input, other, *, out=None) [same] — nextafter in place: self takes the result of nextafter(self,...); returns self. - normal_(tensor, mean=0.0, std=1.0, generator=None) [same] — Fills the tensor in place with normal draws N(mean, std). - not_equal_(input, other) [same] — not_equal in place: self takes the result of not_equal(self,...); returns self. - polygamma_(n, input, *, out=None) [same] — polygamma in place: self takes the result of polygamma(self,...); returns self. - pow_(input, exponent) [same] — In-place form: the out-of-place result written into self. - put_(input, index, source, accumulate=False) [same] — put in place: self takes the result of put(self,...); returns self. - rad2deg_(input) [same] — rad2deg in place: self takes the result of rad2deg(self,...); returns self. - random_(self, from_=0, to=None, *, generator=None) [same] — Tensor.random_([from_,] to): fills with integers drawn uniformly from [from_, to); without to, from [0, the largest integer the dtype holds exactly + 1) as PyTorch (2^24 + 1 for float32, 2^63 for int6 - reciprocal_(input) [same] — reciprocal in place: self takes the result of reciprocal(self,...); returns self. - relu_(Tensor self, bool inplace=False) -> Tensor [same] — In-place form: the out-of-place result written into self. - remainder_(input, other, *, out=None) [different] — In-place Tensor.remainder: the result written into self (self's dtype kept). Different: 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) - renorm_(input, p, dim, maxnorm) [same] — renorm in place: self takes the result of renorm(self,...); returns self. - resize_(self, *size) [same] — In place: self takes the given size, keeping its elements in row-major order (cut short, or extended with zeros where PyTorch leaves memory uninitialized); returns self. - resize_as_(self, other) [same] — resize_ to other's shape. - resize_as_sparse_(self, the_template) [same] — torch.resize_as_sparse_(self, the_template) (both sparse COO). - round_(input) [same] — round in place: self takes the result of round(self,...); returns self. - rsqrt_(input) [same] — rsqrt in place: self takes the result of rsqrt(self,...); returns self. - scatter_(input, dim, index, src=None, *, value=None, reduce=None) [same] — In-place Tensor.scatter: the result written into self (self's dtype kept). - scatter_add_(input, dim, index, src) [same] — In-place Tensor.scatter_add: the result written into self (self's dtype kept). - scatter_reduce_(input, dim, index, src, reduce, *, include_self=True) [same] — In-place Tensor.scatter_reduce: the result written into self (self's dtype kept). - set_(self, source=None, storage_offset=0, size=None, stride=None) [same] — self takes source's data (a tensor or a storage; with size / stride: that view of it). - sgn_(input) [same] — sgn in place: self takes the result of sgn(self,...); returns self. - share_memory_(self) [same] — self, unchanged: Riptorch tensors cross processes by copy, not shared memory. - sigmoid_(input, *, maths=None) [same] — In-place form: the out-of-place result written into self. - sign_(input) [same] — sign in place: self takes the result of sign(self,...); returns self. - sin_(input) [different] — sin in place: self takes the result of sin(self,...); returns self. Different: 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) - sinc_(self) [same] — In-place torch.sinc: the result written into self (self's dtype kept). - sinh_(input) [same] — sinh in place: self takes the result of sinh(self,...); returns self. - sparse_resize_(self, *a, **k) [same] — Raises RuntimeError as PyTorch on a dense tensor: sparse_resize_ needs a sparse coordinate tensor. - sparse_resize_and_clear_(self, *a, **k) [same] — Raises RuntimeError as PyTorch on a dense tensor: sparse_resize_and_clear_ needs a sparse coordinate tensor. - sqrt_(input) [same] — In-place form: the out-of-place result written into self. - square_(input) [same] — square in place: self takes the result of square(self,...); returns self. - squeeze_(self, *dim) [same] — squeeze in place; returns self. - sub_(input, other, *, alpha=1) [same] — In-place form: the out-of-place result written into self. - subtract_(input, other, *, alpha=1) [same] — subtract in place: self takes the result of subtract(self,...); returns self. - swapaxes_(self, a, b) [same] — transpose(a, b) in place; returns self. - swapdims_(self, a, b) [same] — transpose(a, b) in place; returns self. - t_(self) [same] — t in place; returns self. - tan_(input) [same] — tan in place: self takes the result of tan(self,...); returns self. - tanh_(input, *, maths=None) [same] — In-place form: the out-of-place result written into self. - transpose_(self, a, b) [same] — transpose(a, b) in place; returns self. - tril_(self, diagonal=0) [same] — In-place torch.tril(self, diagonal). - triu_(self, diagonal=0) [same] — In-place torch.triu(self, diagonal). - true_divide_(input, other, *, rounding_mode=None) [same] — true_divide in place: self takes the result of true_divide(self,...); returns self. - trunc_(input) [same] — trunc in place: self takes the result of trunc(self,...); returns self. - uniform_(tensor, a=0.0, b=1.0, generator=None) [same] — Fills the tensor in place with uniform draws in [a, b). - unsqueeze_(self, dim) [same] — unsqueeze in place; returns self. - xlogy_(input, other) [same] — xlogy in place: self takes the result of xlogy(self,...); returns self. - zero_(tensor) [same] — Fills the tensor in place with zeros (Tensor.zero_ too). ## torch.nn ### Containers - Module(*args: Any, **kwargs: Any) -> None [same] — torch.nn.Module: parameters, buffers and submodules in their own tables (_parameters, _buffers, _modules), reached as attributes; forward hooks; state_dict with persistent buffers. - ModuleDict(modules=None) [same] — torch.nn.ModuleDict: modules by name, registered as submodules in insertion order. - ModuleList(mods=None) [same] — Submodules by position ("0", "1",...), in order. - ParameterDict(parameters=None) [same] — Parameters by key, registered under the keys; plain tensors become parameters. - ParameterList(values=None) [same] — Parameters by position, registered as "0", "1",...; plain floating tensors become parameters. - Sequential(*mods) [same] — Runs its modules in order, each one's output the next one's input. ### Parameters and buffers - Buffer(data=None, *, persistent=True) [same] — nn.Buffer(data, persistent=True): a tensor that a module registers as a buffer when assigned to an attribute. - Parameter(data=None, requires_grad=True) [same] — nn.Parameter(t): a leaf of t's values and dtype that needs gradients (floating dtypes; an integer parameter records none, as PyTorch allows with requires_grad=False), marked as a parameter. - UninitializedBuffer(requires_grad=False, device=None, dtype=None, persistent=True) [same] — A buffer not yet initialised: materialize(shape) turns it into a tensor. - UninitializedParameter(requires_grad=True, device=None, dtype=None) [same] — A parameter not yet initialised (Lazy modules): materialize(shape) turns it into a Parameter. ### Convolution layers - Conv1d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros', device=None, dtype=None, output_padding=0) [same] — nn.Conv1d: a 1-d convolution with weight and bias drawn as PyTorch (U(-k, k), k = 1 / sqrt(fan_in)). - Conv2d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros', device=None, dtype=None, output_padding=0) [same] — nn.Conv2d: a 2-d convolution (stride, padding incl. - Conv3d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros', device=None, dtype=None, output_padding=0) [same] — nn.Conv3d: a 3-d convolution with weight and bias drawn as PyTorch. - ConvTranspose1d(in_channels, out_channels, kernel_size, stride=1, padding=0, output_padding=0, groups=1, bias=True, dilation=1, padding_mode='zeros', device=None, dtype=None) [same] — nn.ConvTranspose1d: the transposed 1-d convolution (output_padding as PyTorch). - ConvTranspose2d(in_channels, out_channels, kernel_size, stride=1, padding=0, output_padding=0, groups=1, bias=True, dilation=1, padding_mode='zeros', device=None, dtype=None) [same] — nn.ConvTranspose2d: the transposed 2-d convolution. - ConvTranspose3d(in_channels, out_channels, kernel_size, stride=1, padding=0, output_padding=0, groups=1, bias=True, dilation=1, padding_mode='zeros', device=None, dtype=None) [same] — nn.ConvTranspose3d: the transposed 3-d convolution. - Fold(output_size: Union[int, tuple[int, ...]], kernel_size: Union[int, tuple[int, ...]], dilation: Union[int, tuple[int, ...]] = 1, padding: Union[int, tuple[int, ...]] = 0, stride: Union[int, tuple[int, ...]] = 1) -> None [same] - LazyConv1d(out_channels: int, kernel_size: Union[int, tuple[int]], stride: Union[int, tuple[int]] = 1, padding: Union[int, tuple[int]] = 0, dilation: Union[int, tuple[int]] = 1, groups: int = 1, bias: bool = True, padding_mode: Literal['zeros', 'reflect', 'replicate', 'circular'] = 'zeros', device=None, dtype=None) -> None [same] - LazyConv2d(out_channels: int, kernel_size: Union[int, tuple[int, int]], stride: Union[int, tuple[int, int]] = 1, padding: Union[int, tuple[int, int]] = 0, dilation: Union[int, tuple[int, int]] = 1, groups: int = 1, bias: bool = True, padding_mode: Literal['zeros', 'reflect', 'replicate', 'circular'] = 'zeros', device=None, dtype=None) -> None [same] - LazyConv3d(out_channels: int, kernel_size: Union[int, tuple[int, int, int]], stride: Union[int, tuple[int, int, int]] = 1, padding: Union[int, tuple[int, int, int]] = 0, dilation: Union[int, tuple[int, int, int]] = 1, groups: int = 1, bias: bool = True, padding_mode: Literal['zeros', 'reflect', 'replicate', 'circular'] = 'zeros', device=None, dtype=None) -> None [same] - LazyConvTranspose1d(out_channels: int, kernel_size: Union[int, tuple[int]], stride: Union[int, tuple[int]] = 1, padding: Union[int, tuple[int]] = 0, output_padding: Union[int, tuple[int]] = 0, groups: int = 1, bias: bool = True, dilation: Union[int, tuple[int]] = 1, padding_mode: Literal['zeros', 'reflect', 'replicate', 'circular'] = 'zeros', device=None, dtype=None) -> None [same] - LazyConvTranspose2d(out_channels: int, kernel_size: Union[int, tuple[int, int]], stride: Union[int, tuple[int, int]] = 1, padding: Union[int, tuple[int, int]] = 0, output_padding: Union[int, tuple[int, int]] = 0, groups: int = 1, bias: bool = True, dilation: int = 1, padding_mode: Literal['zeros', 'reflect', 'replicate', 'circular'] = 'zeros', device=None, dtype=None) -> None [same] - LazyConvTranspose3d(out_channels: int, kernel_size: Union[int, tuple[int, int, int]], stride: Union[int, tuple[int, int, int]] = 1, padding: Union[int, tuple[int, int, int]] = 0, output_padding: Union[int, tuple[int, int, int]] = 0, groups: int = 1, bias: bool = True, dilation: Union[int, tuple[int, int, int]] = 1, padding_mode: Literal['zeros', 'reflect', 'replicate', 'circular'] = 'zeros', device=None, dtype=None) -> None [same] - Unfold(kernel_size: Union[int, tuple[int, ...]], dilation: Union[int, tuple[int, ...]] = 1, padding: Union[int, tuple[int, ...]] = 0, stride: Union[int, tuple[int, ...]] = 1) -> None [same] ### Pooling layers - AdaptiveAvgPool1d(output_size) [same] — nn.AdaptiveAvgPool1d: F.adaptive_avg_pool1d to output_size. - AdaptiveAvgPool2d(output_size: Union[int, NoneType, tuple[int | None, ...]]) -> None [same] — nn.AdaptiveAvgPool2d: the module form of torch.nn.functional.adaptive_avg_pool2d; forward(*inputs) calls it with the arguments given at construction (output_size). - AdaptiveAvgPool3d(output_size: Union[int, NoneType, tuple[int | None, ...]]) -> None [same] - AdaptiveMaxPool1d(output_size: Union[int, NoneType, tuple[int | None, ...]], return_indices: bool = False) -> None [same] - AdaptiveMaxPool2d(output_size: Union[int, NoneType, tuple[int | None, ...]], return_indices: bool = False) -> None [same] - AdaptiveMaxPool3d(output_size: Union[int, NoneType, tuple[int | None, ...]], return_indices: bool = False) -> None [same] - AvgPool1d(kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True) [same] — nn.AvgPool1d: F.avg_pool1d with the stored window arguments. - AvgPool2d(kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True, divisor_override=None) [same] — nn.AvgPool2d: F.avg_pool2d with the stored kernel_size, stride, padding, ceil_mode, count_include_pad and divisor_override. - AvgPool3d(kernel_size: Union[int, tuple[int, int, int]], stride: Union[int, tuple[int, int, int], NoneType] = None, padding: Union[int, tuple[int, int, int]] = 0, ceil_mode: bool = False, count_include_pad: bool = True, divisor_override: int | None = None) -> None [same] - FractionalMaxPool2d(kernel_size, output_size=None, output_ratio=None, return_indices=False, _random_samples=None) [same] — nn.FractionalMaxPool2d / 3d: F.fractional_max_pool2d / 3d as a module (output_size or output_ratio, return_indices, _random_samples kept as a buffer). - FractionalMaxPool3d(kernel_size, output_size=None, output_ratio=None, return_indices=False, _random_samples=None) [same] — nn.FractionalMaxPool2d / 3d: F.fractional_max_pool2d / 3d as a module (output_size or output_ratio, return_indices, _random_samples kept as a buffer). - LPPool1d(norm_type: float, kernel_size: Union[int, tuple[int, ...]], stride: Union[int, tuple[int, ...], NoneType] = None, ceil_mode: bool = False) -> None [same] - LPPool2d(norm_type: float, kernel_size: Union[int, tuple[int, ...]], stride: Union[int, tuple[int, ...], NoneType] = None, ceil_mode: bool = False) -> None [same] - LPPool3d(norm_type: float, kernel_size: Union[int, tuple[int, ...]], stride: Union[int, tuple[int, ...], NoneType] = None, ceil_mode: bool = False) -> None [same] - MaxPool1d(kernel_size: Union[int, tuple[int, ...]], stride: Union[int, tuple[int, ...], NoneType] = None, padding: Union[int, tuple[int, ...]] = 0, dilation: Union[int, tuple[int, ...]] = 1, return_indices: bool = False, ceil_mode: bool = False) -> None [same] - MaxPool2d(kernel_size: Union[int, tuple[int, ...]], stride: Union[int, tuple[int, ...], NoneType] = None, padding: Union[int, tuple[int, ...]] = 0, dilation: Union[int, tuple[int, ...]] = 1, return_indices: bool = False, ceil_mode: bool = False) -> None [different] — nn.MaxPool2d: the module form of torch.nn.functional.max_pool2d; forward(*inputs) calls it with the arguments given at construction (kernel_size, stride, padding, dilation, ceil_mode, return_indices). Different: nn.MaxPool2d: the module form of torch.nn.functional.max_pool2d; forward(*inputs) calls it with the arguments given at construction (kernel_size, stride, padding, dilation, ceil_mode, return_indices). max_pool2d: Any window, stride and padding (padding counts as -inf): the max over the kh x kw shift - MaxPool3d(kernel_size: Union[int, tuple[int, ...]], stride: Union[int, tuple[int, ...], NoneType] = None, padding: Union[int, tuple[int, ...]] = 0, dilation: Union[int, tuple[int, ...]] = 1, return_indices: bool = False, ceil_mode: bool = False) -> None [same] ### Padding layers - CircularPad1d(padding, value=0.0) [same] - CircularPad2d(padding, value=0.0) [same] - CircularPad3d(padding, value=0.0) [same] - ConstantPad1d(padding, value=0.0) [same] - ConstantPad2d(padding, value=0.0) [same] - ConstantPad3d(padding, value=0.0) [same] - ReflectionPad1d(padding, value=0.0) [same] - ReflectionPad2d(padding, value=0.0) [same] - ReflectionPad3d(padding, value=0.0) [same] - ReplicationPad1d(padding, value=0.0) [same] - ReplicationPad2d(padding, value=0.0) [same] - ReplicationPad3d(padding, value=0.0) [same] - ZeroPad1d(padding, _nd=1) [same] - ZeroPad2d(padding, _nd=2) [same] - ZeroPad3d(padding, _nd=3) [same] ### Non-linear activations - AdaptiveLogSoftmaxWithLoss(in_features, n_classes, cutoffs, div_value=4.0, head_bias=False, device=None, dtype=None) [same] — Efficient softmax approximation (Grave et al.): a head over the shortlist and one entry per cluster, and a two-layer projection per tail cluster. - CELU(alpha: float = 1.0, inplace: bool = False) -> None [same] — nn.CELU: the module form of torch.nn.functional.celu; forward(*inputs) calls it with the arguments given at construction (alpha, inplace). - ELU(alpha: float = 1.0, inplace: bool = False) -> None [same] — nn.ELU: the module form of torch.nn.functional.elu; forward(*inputs) calls it with the arguments given at construction (alpha, inplace). - GELU(approximate: str = 'none') -> None [same] — nn.GELU: the module form of torch.nn.functional.gelu; forward(*inputs) calls it with the arguments given at construction (approximate). - GLU(dim: int = -1) -> None [same] — nn.GLU: the module form of torch.nn.functional.glu; forward(*inputs) calls it with the arguments given at construction (dim). - Hardshrink(lambd: float = 0.5) -> None [same] — nn.Hardshrink: the module form of torch.nn.functional.hardshrink; forward(*inputs) calls it with the arguments given at construction (lambd). - Hardsigmoid(inplace: bool = False) -> None [same] — nn.Hardsigmoid: the module form of torch.nn.functional.hardsigmoid; forward(*inputs) calls it with the arguments given at construction (inplace). - Hardswish(inplace: bool = False) -> None [same] — nn.Hardswish: the module form of torch.nn.functional.hardswish; forward(*inputs) calls it with the arguments given at construction (inplace). - Hardtanh(min_val: float = -1.0, max_val: float = 1.0, inplace: bool = False, min_value: float | None = None, max_value: float | None = None) -> None [same] — nn.Hardtanh: the module form of torch.nn.functional.hardtanh; forward(*inputs) calls it with the arguments given at construction (min_val, max_val, inplace). - LeakyReLU(negative_slope: float = 0.01, inplace: bool = False) -> None [same] — nn.LeakyReLU: the module form of torch.nn.functional.leaky_relu; forward(*inputs) calls it with the arguments given at construction (negative_slope, inplace). - LogSigmoid(*args: Any, **kwargs: Any) -> None [same] — nn.LogSigmoid: the module form of torch.nn.functional.logsigmoid; forward(*inputs) calls it with the arguments given at construction. - LogSoftmax(dim: int | None = None) -> None [same] — nn.LogSoftmax: the module form of torch.nn.functional.log_softmax; forward(*inputs) calls it with the arguments given at construction (dim). - Mish(inplace: bool = False) -> None [same] — nn.Mish: the module form of torch.nn.functional.mish; forward(*inputs) calls it with the arguments given at construction (inplace). - MultiheadAttention(embed_dim, num_heads, dropout=0.0, bias=True, add_bias_kv=False, add_zero_attn=False, kdim=None, vdim=None, batch_first=False, device=None, dtype=None) [same] — nn.MultiheadAttention: multi-head attention with PyTorch's parameters (in_proj_weight or separate q / k / v weights, out_proj, bias_k / bias_v, add_zero_attn). - PReLU(num_parameters=1, init=0.25, device=None, dtype=None) [same] — nn.PReLU: a learnable negative slope (num_parameters of them, initialised to init) applied with F.prelu. - ReLU(inplace: bool = False) -> None [same] — nn.ReLU: the module form of torch.nn.functional.relu; forward(*inputs) calls it with the arguments given at construction (inplace). - ReLU6(inplace: bool = False) -> None [same] — nn.ReLU6: the module form of torch.nn.functional.relu6; forward(*inputs) calls it with the arguments given at construction (inplace). - RReLU(lower: float = 0.125, upper: float = 0.3333333333333333, inplace: bool = False) -> None [same] - SELU(inplace: bool = False) -> None [same] — nn.SELU: the module form of torch.nn.functional.selu; forward(*inputs) calls it with the arguments given at construction (inplace). - Sigmoid(*args: Any, **kwargs: Any) -> None [same] — nn.Sigmoid: the module form of torch.nn.functional.sigmoid_fn; forward(*inputs) calls it with the arguments given at construction. - SiLU(inplace: bool = False) -> None [same] — nn.SiLU: the module form of torch.nn.functional.silu; forward(*inputs) calls it with the arguments given at construction (inplace). - Softmax(dim: int | None = None) -> None [same] — nn.Softmax: the module form of torch.nn.functional.softmax; forward(*inputs) calls it with the arguments given at construction (dim). - Softmax2d(*args: Any, **kwargs: Any) -> None [same] - Softmin(dim: int | None = None) -> None [same] — nn.Softmin: the module form of torch.nn.functional.softmin; forward(*inputs) calls it with the arguments given at construction (dim). - Softplus(beta: float = 1.0, threshold: float = 20.0) -> None [same] — nn.Softplus: the module form of torch.nn.functional.softplus; forward(*inputs) calls it with the arguments given at construction (beta, threshold). - Softshrink(lambd: float = 0.5) -> None [same] — nn.Softshrink: the module form of torch.nn.functional.softshrink; forward(*inputs) calls it with the arguments given at construction (lambd). - Softsign(*args: Any, **kwargs: Any) -> None [same] — nn.Softsign: the module form of torch.nn.functional.softsign; forward(*inputs) calls it with the arguments given at construction. - Tanh(*args: Any, **kwargs: Any) -> None [same] — nn.Tanh: the module form of torch.nn.functional.tanh; forward(*inputs) calls it with the arguments given at construction. - Tanhshrink(*args: Any, **kwargs: Any) -> None [same] — nn.Tanhshrink: the module form of torch.nn.functional.tanhshrink; forward(*inputs) calls it with the arguments given at construction. - Temperature(s0=None) [extra] — A learned temperature for one layer: a scalar parameter s and, by riptorch.set_maths(temperature=...), T = 1 + s^2 ("learned", order 2, T >= 1) or 1/T = 1 + s + s^2/2 ("learned_inv", 1/T >= 1/2). - Threshold(threshold: float, value: float, inplace: bool = False) -> None [same] — nn.Threshold: the module form of torch.nn.functional.threshold; forward(*inputs) calls it with the arguments given at construction (threshold, value, inplace). ### Normalization layers - BatchNorm1d(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True, device=None, dtype=None) [same] — nn.BatchNorm1d: batch norm over (N, C) or (N, C, L) input. - BatchNorm2d(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True, device=None, dtype=None) [same] — nn.BatchNorm2d: batch norm over (N, C, H, W) input. - BatchNorm3d(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True, device=None, dtype=None) [same] — nn.BatchNorm3d: batch norm over (N, C, D, H, W) input. - GroupNorm(num_groups, num_channels, eps=1e-05, affine=True, device=None, dtype=None) [same] — nn.GroupNorm: F.group_norm with learnable per-channel weight (ones) and bias (zeros) when affine. - InstanceNorm1d(num_features, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False, device=None, dtype=None) [same] — nn.InstanceNorm1d: instance norm over (N, C, L) or unbatched (C, L) input. - InstanceNorm2d(num_features, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False, device=None, dtype=None) [same] — nn.InstanceNorm2d: instance norm over (N, C, H, W) or unbatched (C, H, W) input. - InstanceNorm3d(num_features, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False, device=None, dtype=None) [same] — nn.InstanceNorm3d: instance norm over (N, C, D, H, W) or unbatched input. - LayerNorm(normalized_shape, eps=1e-05, elementwise_affine=True, bias=True, device=None, dtype=None) [same] — nn.LayerNorm: normalized_shape an int or a shape (the last dims); weight ones / bias zeros of that shape. - LazyBatchNorm1d(eps=1e-05, momentum=0.1, affine=True, track_running_stats=True, device=None, dtype=None, *, bias=True) -> None [same] - LazyBatchNorm2d(eps=1e-05, momentum=0.1, affine=True, track_running_stats=True, device=None, dtype=None, *, bias=True) -> None [same] - LazyBatchNorm3d(eps=1e-05, momentum=0.1, affine=True, track_running_stats=True, device=None, dtype=None, *, bias=True) -> None [same] - LazyInstanceNorm1d(eps=1e-05, momentum=0.1, affine=True, track_running_stats=True, device=None, dtype=None, *, bias=True) -> None [same] - LazyInstanceNorm2d(eps=1e-05, momentum=0.1, affine=True, track_running_stats=True, device=None, dtype=None, *, bias=True) -> None [same] - LazyInstanceNorm3d(eps=1e-05, momentum=0.1, affine=True, track_running_stats=True, device=None, dtype=None, *, bias=True) -> None [same] - LocalResponseNorm(size: int, alpha: float = 0.0001, beta: float = 0.75, k: float = 1.0) -> None [same] - RMSNorm(normalized_shape, eps=None, elementwise_affine=True, device=None, dtype=None) [same] — nn.RMSNorm: F.rms_norm over the last dims with a learnable weight (ones). - SyncBatchNorm(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True, device=None, dtype=None) [same] — nn.BatchNorm2d: batch norm over (N, C, H, W) input. ### Recurrent layers - GRU(input_size, hidden_size, num_layers=1, bias=True, batch_first=False, dropout=0.0, bidirectional=False, proj_size=0, device=None, dtype=None, nonlinearity='tanh', mode=None) [same] — nn.GRU: a multi-layer gated recurrent unit. - GRUCell(input_size, hidden_size, bias=True, nonlinearity='tanh', device=None, dtype=None) [same] — nn.GRUCell: one GRU step. - LSTM(input_size, hidden_size, num_layers=1, bias=True, batch_first=False, dropout=0.0, bidirectional=False, proj_size=0, device=None, dtype=None, nonlinearity='tanh', mode=None) [same] — nn.LSTM: a multi-layer long short-term memory RNN; forward(input, (h0, c0)) returns (output, (h_n, c_n)). - LSTMCell(input_size, hidden_size, bias=True, nonlinearity='tanh', device=None, dtype=None) [same] — nn.LSTMCell: one LSTM step; returns (h, c). - RNN(input_size, hidden_size, num_layers=1, bias=True, batch_first=False, dropout=0.0, bidirectional=False, proj_size=0, device=None, dtype=None, nonlinearity='tanh', mode=None) [same] — nn.RNN: a multi-layer Elman RNN with tanh or relu. - RNNBase(input_size, hidden_size, num_layers=1, bias=True, batch_first=False, dropout=0.0, bidirectional=False, proj_size=0, device=None, dtype=None, nonlinearity='tanh', mode=None) [different] — The base of nn.RNN / LSTM / GRU: stacked (optionally bidirectional) layers with PyTorch's parameter names and U(-k, k) init, k = 1 / sqrt(hidden_size); proj_size and PackedSequence input raise NotImpl Different: The base of nn.RNN / LSTM / GRU: stacked (optionally bidirectional) layers with PyTorch's parameter names and U(-k, k) init, k = 1 / sqrt(hidden_size); proj_size and PackedSequence input raise NotImplementedError. - RNNCell(input_size, hidden_size, bias=True, nonlinearity='tanh', device=None, dtype=None) [same] — nn.RNNCell: one Elman RNN step with tanh or relu. - RNNCellBase(input_size, hidden_size, bias=True, nonlinearity='tanh', device=None, dtype=None) [same] — The base of nn.RNNCell / LSTMCell / GRUCell: one time step with weight_ih, weight_hh and biases. ### Transformer layers - Transformer(d_model=512, nhead=8, num_encoder_layers=6, num_decoder_layers=6, dim_feedforward=2048, dropout=0.1, activation='relu', custom_encoder=None, custom_decoder=None, layer_norm_eps=1e-05, batch_first=False, norm_first=False, bias=True, device=None, dtype=None) [same] — The encoder-decoder Transformer (Vaswani et al.): an encoder and a decoder stack with final norms; weights of rank > 1 initialised Xavier-uniform. - TransformerDecoder(decoder_layer, num_layers, norm=None) [same] — num_layers copies of a decoder layer, then an optional norm. - TransformerDecoderLayer(d_model, nhead, dim_feedforward=2048, dropout=0.1, activation='relu', layer_norm_eps=1e-05, batch_first=False, norm_first=False, bias=True, device=None, dtype=None) [same] — Self-attention, attention over the encoder memory, then a feed-forward block, each with a residual connection and LayerNorm (norm_first puts the norm first). - TransformerEncoder(encoder_layer, num_layers, norm=None, enable_nested_tensor=True, mask_check=True) [same] — num_layers copies of an encoder layer, then an optional norm. - TransformerEncoderLayer(d_model, nhead, dim_feedforward=2048, dropout=0.1, activation='relu', layer_norm_eps=1e-05, batch_first=False, norm_first=False, bias=True, device=None, dtype=None) [same] — Self-attention then a feed-forward block, each with a residual connection and LayerNorm (norm_first puts the norm before each block). ### Linear layers - Bilinear(in1_features, in2_features, out_features, bias=True, device=None, dtype=None) [same] — y = x1^T W x2 + b; weight (out, in1, in2) and bias uniform in +-1/sqrt(in1), as PyTorch. - Identity(*args: Any, **kwargs: Any) -> None [same] — nn.Identity: returns its input; constructor arguments are accepted and ignored, as in PyTorch. - LazyLinear(out_features: int, bias: bool = True, device=None, dtype=None) -> None [same] - Linear(in_features, out_features, bias=True) [same] — y = x @ W.T + b, W shape (out, in), as in torch.nn.Linear. ### Dropout layers - AlphaDropout(p: float = 0.5, inplace: bool = False) -> None [same] - Dropout(p: float = 0.5, inplace: bool = False) -> None [same] — nn.Dropout: the module form of torch.nn.functional.dropout; forward(*inputs) calls it with the arguments given at construction (p, inplace), and training= following train / eval. - Dropout1d(p: float = 0.5, inplace: bool = False) -> None [same] - Dropout2d(p: float = 0.5, inplace: bool = False) -> None [same] - Dropout3d(p: float = 0.5, inplace: bool = False) -> None [same] - FeatureAlphaDropout(p: float = 0.5, inplace: bool = False) -> None [same] ### Sparse layers - Embedding(num_embeddings, embedding_dim, padding_idx=None, max_norm=None, norm_type=2.0, scale_grad_by_freq=False, sparse=False, _weight=None, _freeze=False, device=None, dtype=None) [same] — nn.Embedding: weight ~ N(0, 1) (the padding row zeroed), forward = F.embedding. - EmbeddingBag(num_embeddings, embedding_dim, max_norm=None, norm_type=2.0, scale_grad_by_freq=False, mode='mean', sparse=False, _weight=None, include_last_offset=False, padding_idx=None, device=None, dtype=None) [same] — Embedding table whose forward reduces bags of indices (F.embedding_bag); weight ~ N(0, 1). ### Distance functions - CosineSimilarity(dim: int = 1, eps: float = 1e-08) -> None [same] — nn.CosineSimilarity: the module form of torch.nn.functional.cosine_similarity; forward(*inputs) calls it with the arguments given at construction (dim, eps). - PairwiseDistance(p: float = 2.0, eps: float = 1e-06, keepdim: bool = False) -> None [same] — nn.PairwiseDistance: the module form of torch.nn.functional.pairwise_distance; forward(*inputs) calls it with the arguments given at construction (p, eps, keepdim). ### Loss functions - BCELoss(*args, reduction='mean', size_average=None, reduce=None, **kw) [same] — nn.BCELoss: the loss as a module; forward calls the functional form with reduction and the constructor arguments. - BCEWithLogitsLoss(*args, reduction='mean', size_average=None, reduce=None, **kw) [same] — nn.BCEWithLogitsLoss: the loss as a module; forward calls the functional form with reduction and the constructor arguments. - CosineEmbeddingLoss(margin: float = 0.0, size_average=None, reduce=None, reduction: str = 'mean') -> None [same] - CrossEntropyLoss(weight: torch.Tensor | None = None, size_average=None, ignore_index: int = -100, reduce=None, reduction: str = 'mean', label_smoothing: float = 0.0) -> None [different] — nn.CrossEntropyLoss: the module form of torch.nn.functional.cross_entropy; forward(*inputs) calls it with the arguments given at construction (ignore_index, reduction, label_smoothing). Different: nn.CrossEntropyLoss: the module form of torch.nn.functional.cross_entropy; forward(*inputs) calls it with the arguments given at construction (ignore_index, reduction, label_smoothing). cross_entropy: input [N, C] with class-index targets [N]; rows whose target is ignore_index count for nothing (the - CTCLoss(blank: int = 0, reduction: str = 'mean', zero_infinity: bool = False) -> None [same] - GaussianNLLLoss(*, full: bool = False, eps: float = 1e-06, reduction: str = 'mean') -> None [same] - HingeEmbeddingLoss(margin: float = 1.0, size_average=None, reduce=None, reduction: str = 'mean') -> None [same] - HuberLoss(*args, reduction='mean', size_average=None, reduce=None, **kw) [same] — nn.HuberLoss: the loss as a module; forward calls the functional form with reduction and the constructor arguments. - KLDivLoss(*args, reduction='mean', size_average=None, reduce=None, **kw) [same] — nn.KLDivLoss: the loss as a module; forward calls the functional form with reduction and the constructor arguments. - L1Loss(*args, reduction='mean', size_average=None, reduce=None, **kw) [same] — nn.L1Loss: the loss as a module; forward calls the functional form with reduction and the constructor arguments. - LinearCrossEntropyLoss(in_features, num_classes, *, out_features=(), bias=False, device=None, dtype=None, reduction='mean', weight=None, ignore_index=None, label_smoothing=0.0, options=None) [same] — Cross entropy of a linear layer's logits (in_features -> num_classes * prod(out_features)). - MarginRankingLoss(*args, reduction='mean', size_average=None, reduce=None, **kw) [same] — nn.MarginRankingLoss: the loss as a module; forward calls the functional form with reduction and the constructor arguments. - MSELoss(size_average=None, reduce=None, reduction: str = 'mean') -> None [same] — Mean squared error, mean((a - b)^2). - MultiLabelMarginLoss(size_average=None, reduce=None, reduction: str = 'mean') -> None [same] - MultiLabelSoftMarginLoss(weight: torch.Tensor | None = None, size_average=None, reduce=None, reduction: str = 'mean') -> None [same] - MultiMarginLoss(p: int = 1, margin: float = 1.0, weight: torch.Tensor | None = None, size_average=None, reduce=None, reduction: str = 'mean') -> None [same] - NLLLoss(weight: torch.Tensor | None = None, size_average=None, ignore_index: int = -100, reduce=None, reduction: str = 'mean') -> None [same] - PoissonNLLLoss(log_input: bool = True, full: bool = False, size_average=None, eps: float = 1e-08, reduce=None, reduction: str = 'mean') -> None [same] - SmoothL1Loss(*args, reduction='mean', size_average=None, reduce=None, **kw) [same] — nn.SmoothL1Loss: the loss as a module; forward calls the functional form with reduction and the constructor arguments. - SoftMarginLoss(*args, reduction='mean', size_average=None, reduce=None, **kw) [same] — nn.SoftMarginLoss: the loss as a module; forward calls the functional form with reduction and the constructor arguments. - TripletMarginLoss(margin: float = 1.0, p: float = 2.0, eps: float = 1e-06, swap: bool = False, size_average=None, reduce=None, reduction: str = 'mean') -> None [same] - TripletMarginWithDistanceLoss(*, distance_function: collections.abc.Callable[[torch.Tensor, torch.Tensor], torch.Tensor] | None = None, margin: float = 1.0, swap: bool = False, reduction: str = 'mean') -> None [same] ### Vision layers - ChannelShuffle(groups: int) -> None [same] - PixelShuffle(upscale_factor: int) -> None [same] — nn.PixelShuffle: the module form of torch.nn.functional.pixel_shuffle; forward(*inputs) calls it with the arguments given at construction (upscale_factor). - PixelUnshuffle(downscale_factor: int) -> None [same] — nn.PixelUnshuffle: the module form of torch.nn.functional.pixel_unshuffle; forward(*inputs) calls it with the arguments given at construction (downscale_factor). - Upsample(size=None, scale_factor=None, mode='nearest', align_corners=None, recompute_scale_factor=None) [same] — nn.Upsample: F.interpolate with the stored size or scale_factor, mode and align_corners. - UpsamplingBilinear2d(size=None, scale_factor=None) [same] — nn.UpsamplingBilinear2d: Upsample with mode "bilinear" and align_corners=True. - UpsamplingNearest2d(size=None, scale_factor=None) [same] — nn.UpsamplingNearest2d: Upsample with mode "nearest". ### Utilities - clip_grad_norm_(parameters, max_norm, norm_type=2.0, error_if_nonfinite=False, foreach=None) [extra] — Scales the gradients so their combined 2-norm is at most max_norm; returns the norm before scaling. - factory_kwargs(kwargs) [same] — The device / dtype / memory_format entries of kwargs (PyTorch's helper for module constructors). - fan_in_values(rnd, n, fan_in) [extra] — n initial values with variance 1/(3 fan_in) (torch.nn.Linear's and Conv2d's). - Flatten(start_dim=1, end_dim=-1) [same] — Flattens dims start_dim to end_dim (default: the last) into one. - Unflatten(dim, unflattened_size) [same] — Expands dim into unflattened_size (torch.unflatten as a module). ### Initialisation (nn.init) - calculate_gain(nonlinearity, param=None) [same] — The recommended gain for a nonlinearity: 1 (linear, conv, sigmoid), 5/3 (tanh), sqrt(2) (relu), sqrt(2 / (1 + slope^2)) (leaky_relu, param = slope, default 0.01), 3/4 (selu); ValueError otherwise. - constant(tensor, val) [same] — Fills the tensor in place with val (Tensor.fill_ too). - constant_(tensor, val) [same] — Fills the tensor in place with val (Tensor.fill_ too). - dirac(*args: _P.args, **kwargs: _P.kwargs) -> ~_R [same] — The identity convolution: in each group, output channel d takes input channel d at the kernel's centre. - dirac_(tensor, groups=1) [same] — The identity convolution: in each group, output channel d takes input channel d at the kernel's centre. - eye(tensor) [same] — Fills a 2-d tensor in place with the identity (ones on the diagonal). - eye_(tensor) [same] — Fills a 2-d tensor in place with the identity (ones on the diagonal). - kaiming_normal(tensor, a=0, mode='fan_in', nonlinearity='leaky_relu', generator=None) [same] — He normal fill: N(0, std) with std = gain / sqrt(fan), fan from mode, gain from nonlinearity and a. - kaiming_normal_(tensor, a=0, mode='fan_in', nonlinearity='leaky_relu', generator=None) [same] — He normal fill: N(0, std) with std = gain / sqrt(fan), fan from mode, gain from nonlinearity and a. - kaiming_uniform(tensor, a=0, mode='fan_in', nonlinearity='leaky_relu', generator=None) [same] — He uniform fill: U(-b, b) with b = gain * sqrt(3 / fan), fan from mode, gain from nonlinearity and a. - kaiming_uniform_(tensor, a=0, mode='fan_in', nonlinearity='leaky_relu', generator=None) [same] — He uniform fill: U(-b, b) with b = gain * sqrt(3 / fan), fan from mode, gain from nonlinearity and a. - normal(tensor, mean=0.0, std=1.0, generator=None) [same] — Fills the tensor in place with normal draws N(mean, std). - normal_(tensor, mean=0.0, std=1.0, generator=None) [same] — Fills the tensor in place with normal draws N(mean, std). - ones_(tensor) [same] — Fills the tensor in place with ones. - orthogonal(*args: _P.args, **kwargs: _P.kwargs) -> ~_R [same] — A (semi-)orthogonal matrix from the QR factorisation of a normal draw, signs fixed by R's diagonal. - orthogonal_(tensor, gain=1, generator=None) [same] — A (semi-)orthogonal matrix from the QR factorisation of a normal draw, signs fixed by R's diagonal. - sparse(*args: _P.args, **kwargs: _P.kwargs) -> ~_R [same] — Normal(0, std) entries with ceil(sparsity * rows) zeros in each column, at random rows. - sparse_(tensor, sparsity, std=0.01, generator=None) [same] — Normal(0, std) entries with ceil(sparsity * rows) zeros in each column, at random rows. - trunc_normal(tensor, mean=0.0, std=1.0, a=-2.0, b=2.0, generator=None) [extra] — Fills the tensor in place with N(mean, std) draws truncated to [a, b]. - trunc_normal_(tensor, mean=0.0, std=1.0, a=-2.0, b=2.0, generator=None) [same] — Fills the tensor in place with N(mean, std) draws truncated to [a, b]. - uniform(tensor, a=0.0, b=1.0, generator=None) [same] — Fills the tensor in place with uniform draws in [a, b). - uniform_(tensor, a=0.0, b=1.0, generator=None) [same] — Fills the tensor in place with uniform draws in [a, b). - xavier_normal(tensor, gain=1.0, generator=None) [same] — Glorot normal fill: N(0, std) with std = gain * sqrt(2 / (fan_in + fan_out)). - xavier_normal_(tensor, gain=1.0, generator=None) [same] — Glorot normal fill: N(0, std) with std = gain * sqrt(2 / (fan_in + fan_out)). - xavier_uniform(tensor, gain=1.0, generator=None) [same] — Glorot uniform fill: U(-a, a) with a = gain * sqrt(6 / (fan_in + fan_out)). - xavier_uniform_(tensor, gain=1.0, generator=None) [same] — Glorot uniform fill: U(-a, a) with a = gain * sqrt(6 / (fan_in + fan_out)). - zeros_(tensor) [same] — Fills the tensor in place with zeros (Tensor.zero_ too). ### Utilities (nn.utils) - clip_grad_norm(parameters, max_norm, norm_type=2.0, error_if_nonfinite=False, foreach=None) [same] — Scales the gradients so their combined norm (any order; inf = largest entry) is at most max_norm; returns the norm before scaling. - clip_grad_norm_(parameters, max_norm, norm_type=2.0, error_if_nonfinite=False, foreach=None) [same] — Scales the gradients so their combined norm (any order; inf = largest entry) is at most max_norm; returns the norm before scaling. - clip_grad_value_(parameters, clip_value, foreach=None) [same] — Clamps every gradient to [-clip_value, clip_value]. - clip_grads_with_norm_(parameters, max_norm, total_norm, foreach=None) [same] — Scales every gradient by min(1, max_norm / (total_norm + 1e-6)), given the total norm. - convert_conv2d_weight_memory_format(module, memory_format) [same] — Returns module unchanged: Riptorch tensors have one layout (memory_format has no effect). - convert_conv3d_weight_memory_format(module, memory_format) [same] — Returns module unchanged: Riptorch tensors have one layout (memory_format has no effect). - fuse_conv_bn_eval(conv, bn, transpose=False) [same] — A copy of conv with bn (in eval mode) folded into its weight and bias. - fuse_conv_bn_weights(conv_w, conv_b, bn_rm, bn_rv, bn_eps, bn_w, bn_b, transpose=False) [same] — Folds batch-norm statistics into convolution weights: (w * gamma / sqrt(var + eps), (b - mean) * gamma / sqrt(var + eps) + beta) as Parameters (transpose=True scales dim 1). - fuse_linear_bn_eval(linear, bn) [same] — A copy of linear with bn (in eval mode) folded into its weight and bias. - fuse_linear_bn_weights(linear_w, linear_b, bn_rm, bn_rv, bn_eps, bn_w, bn_b) [same] — Folds batch-norm statistics into a linear layer's weight and bias, as Parameters. - get_total_norm(tensors, norm_type=2.0, error_if_nonfinite=False, foreach=None) [same] — The norm (norm_type; inf = largest absolute entry) of the norms of tensors, as if all were one vector. - parameters_to_vector(parameters) [same] — The parameters flattened and concatenated into one 1-d tensor. - remove_spectral_norm(module, name='weight') [same] — Undoes spectral_norm: name becomes a plain parameter with the current normalised value. - remove_weight_norm(module, name='weight') [same] — Undoes weight_norm: name becomes a plain parameter with the current normalised value. - skip_init(module_cls, *args, **kwargs) [same] — module_cls(*args, **kwargs). - spectral_norm(module, name='weight', n_power_iterations=1, eps=1e-12, dim=None) [same] — The older hook form of spectral normalisation: name_orig parameter, name_u / name_v buffers, name = W / sigma recomputed before each forward (power iteration in training). - vector_to_parameters(vec, parameters) [same] — Copies consecutive slices of vec into the parameters (the inverse of parameters_to_vector). - weight_norm(module, name='weight', dim=0) [same] — The older hook form of weight normalisation: replaces name with name_g and name_v parameters and recomputes name = g * v / ||v|| before each forward. ### More - Container(*args, **kwargs) [same] — torch.nn.Module: parameters, buffers and submodules in their own tables (_parameters, _buffers, _modules), reached as attributes; forward hooks; state_dict with persistent buffers. - CrossMapLRN2d(size: int, alpha: float = 0.0001, beta: float = 0.75, k: float = 1) -> None [same] - DataParallel(module, device_ids=None, output_device=None, dim=0) [same] — nn.DataParallel without CUDA: forward calls the module. - LinearCrossEntropyOptions(allow_retain_graph: bool = False, batch_chunk_size: Optional[int] = None, chunking_method: Optional[str] = 'auto', acc_policy: str = 'auto', acc_dtype: Any = None) -> None [same] — Configuration of the chunked linear_cross_entropy (batch_chunk_size rows at a time). - MaxUnpool1d(kernel_size: Union[int, tuple[int]], stride: Union[int, tuple[int], NoneType] = None, padding: Union[int, tuple[int]] = 0) -> None [same] - MaxUnpool2d(kernel_size: Union[int, tuple[int, int]], stride: Union[int, tuple[int, int], NoneType] = None, padding: Union[int, tuple[int, int]] = 0) -> None [same] - MaxUnpool3d(kernel_size: Union[int, tuple[int, int, int]], stride: Union[int, tuple[int, int, int], NoneType] = None, padding: Union[int, tuple[int, int, int]] = 0) -> None [same] - NLLLoss2d(*args, **kwargs) [same] ## torch.nn.functional ### Convolution functions - conv1d(input, weight, bias=None, stride=(1,), padding=(0,), dilation=(1,), groups=1) [different] Different: exact integer convolution (NTT + CRT) that raises instead of wrapping; PyTorch wraps 51 of 72 int64 outputs (inputs < 2^40, weights < 2^24), MLX has no integer convolution - conv2d(input, weight, bias=None, stride=(1,), padding=(0,), dilation=(1,), groups=1) [same] — 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] - conv_tbc(input, weight, bias, pad=0) [same] — 1-d convolution over (time, batch, channels) inputs with a (kernel, in, out) weight. - conv_transpose1d(input, weight, bias=None, stride=(1,), padding=(0,), output_padding=(0,), groups=1, dilation=(1,)) [same] - conv_transpose2d(input, weight, bias=None, stride=(1,), padding=(0,), output_padding=(0,), groups=1, dilation=(1,)) [same] - conv_transpose3d(input, weight, bias=None, stride=(1,), padding=(0,), output_padding=(0,), groups=1, dilation=(1,)) [same] - fold(input, output_size, kernel_size, dilation=1, padding=0, stride=1) [same] — col2im: the inverse placement of unfold, overlapping entries summed. - unfold(input, kernel_size, dilation=1, padding=0, stride=1) [same] — im2col: (N, C, H, W) -> (N, C * kh * kw, L), each column one sliding block (channels, then kernel rows). ### Pooling functions - adaptive_avg_pool1d(input, output_size) [same] — F.adaptive_avg_pool1d: averages over output_size equal-ish windows of the last dim (area interpolation). - adaptive_avg_pool2d(Tensor input, int[] output_size) -> Tensor [same] — When the input size is a multiple of the output size (the windows don't overlap): a reshape and a mean. - adaptive_avg_pool3d(input, output_size) [same] — 3-d adaptive average pooling to output_size (windows as adaptive_max_pool1d). - adaptive_max_pool1d(input, output_size, return_indices=False) [same] — Max over adaptive windows giving output_size positions (window i spans floor(i n / o) to ceil((i + 1) n / o)). - adaptive_max_pool1d_with_indices(input, output_size, return_indices=True) [same] — adaptive_max_pool1d returning (values, flat indices). - adaptive_max_pool2d(input, output_size, return_indices=False) [same] — 2-d adaptive max pooling to output_size (an int, a pair, None keeps that size); see adaptive_max_pool1d. - adaptive_max_pool2d_with_indices(input, output_size, return_indices=True) [same] — adaptive_max_pool2d returning (values, flat indices in each H x W plane). - adaptive_max_pool3d(input, output_size, return_indices=False) [same] — 3-d adaptive max pooling to output_size; see adaptive_max_pool1d. - adaptive_max_pool3d_with_indices(input, output_size, return_indices=True) [same] — adaptive_max_pool3d returning (values, flat indices in each D x H x W volume). - avg_pool1d(input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True) [same] — F.avg_pool1d: the mean over windows along the last dim (a 2-d pool of height 1). - avg_pool2d(Tensor input, int[] kernel_size, int[]? stride=None, int[] padding=(0,), bool ceil_mode=False, bool count_include_pad=True, int? divisor_override=None) -> Tensor [different] — 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. Different: avg_pool2d(Tensor input, int[] kernel_size, int[]? stride=None, int[] padding=(0,), bool ceil_mode=False, bool count_include_pad=True, int? divisor_override=None) -> Tensor A depthwise convolution with a constant kernel: sums over each window divided by its size, or (count_include_pad=False) by the - avg_pool3d(input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True, divisor_override=None) [same] — 3-d average pooling over (N, C, D, H, W) or (C, D, H, W). - fractional_max_pool2d(input, kernel_size, output_size=None, output_ratio=None, return_indices=False, _random_samples=None) [same] — Fractional max pooling over (N, C, H, W) or (C, H, W): kernel_size windows at pseudo-random increasing positions giving output_size (or output_ratio of the input). - fractional_max_pool2d_with_indices(input, kernel_size, output_size=None, output_ratio=None, return_indices=False, _random_samples=None) [same] — fractional_max_pool2d returning (values, flat indices in each H x W plane). - fractional_max_pool3d(input, kernel_size, output_size=None, output_ratio=None, return_indices=False, _random_samples=None) [same] — Fractional max pooling over (N, C, D, H, W) or (C, D, H, W); see fractional_max_pool2d. - fractional_max_pool3d_with_indices(input, kernel_size, output_size=None, output_ratio=None, return_indices=False, _random_samples=None) [same] — fractional_max_pool3d returning (values, flat indices in each D x H x W volume). - lp_pool1d(input, norm_type, kernel_size, stride=None, ceil_mode=False) [same] — Power-average pooling: (sum over the window of x^p)^(1/p), p = norm_type. - lp_pool2d(input, norm_type, kernel_size, stride=None, ceil_mode=False) [same] — 2-d power-average pooling: (sum over the window of x^p)^(1/p). - lp_pool3d(input, norm_type, kernel_size, stride=None, ceil_mode=False) [same] — 3-d power-average pooling: (sum over the window of x^p)^(1/p). - max_pool1d(*args, **kwargs) [same] — 1-d max pooling over the last dim of (N, C, L) or (C, L); stride defaults to kernel_size. - max_pool1d_with_indices(input: torch.Tensor, kernel_size: None, stride: NoneType = None, padding: None = 0, dilation: None = 1, ceil_mode: bool = False, return_indices: bool = False) -> tuple[torch.Tensor, torch.Tensor] [same] — max_pool1d returning (values, indices). - max_pool2d(*args, **kwargs) [same] — torch.max_pool2d. - max_pool2d_with_indices(input, kernel_size, stride=None, padding=0, dilation=1, ceil_mode=False, return_indices=True) [same] — 2-d max pooling returning (values, indices); indices are flat positions in each H x W plane. - max_pool3d(*args, **kwargs) [same] — 3-d max pooling over the last three dims of (N, C, D, H, W) or (C, D, H, W); options as max_pool1d. - max_pool3d_with_indices(input: torch.Tensor, kernel_size: None, stride: NoneType = None, padding: None = 0, dilation: None = 1, ceil_mode: bool = False, return_indices: bool = False) -> tuple[torch.Tensor, torch.Tensor] [same] — max_pool3d returning (values, indices). - max_unpool1d(input, indices, kernel_size, stride=None, padding=0, output_size=None) [same] — Inverse of max_pool1d: puts each value at its index in a zero tensor of the pooled input's size (output_size overrides it). - max_unpool2d(input, indices, kernel_size, stride=None, padding=0, output_size=None) [same] — Inverse of max_pool2d: scatters values to their flat indices in zero H x W planes. - max_unpool3d(input, indices, kernel_size, stride=None, padding=0, output_size=None) [same] — Inverse of max_pool3d: scatters values to their flat indices in zero D x H x W volumes. ### Attention - multi_head_attention_forward(query, key, value, embed_dim_to_check, num_heads, in_proj_weight, in_proj_bias, bias_k, bias_v, add_zero_attn, dropout_p, out_proj_weight, out_proj_bias, training=True, key_padding_mask=None, need_weights=True, attn_mask=None, use_separate_proj_weight=False, q_proj_weight=None, k_proj_weight=None, v_proj_weight=None, static_k=None, static_v=None, average_attn_weights=True, is_causal=False) [same] — F.multi_head_attention_forward through an nn.MultiheadAttention holding these weights. - scaled_dot_product_attention(q, k, v, attn_mask=None, dropout_p=0.0, is_causal=False, scale=None, *args, temperature=None, **kw) [same] ### Non-linear activations - celu(input, alpha=1.0, inplace=False) [same] — max(0, x) + min(0, alpha * (exp(x / alpha) - 1)). - elu(input, alpha=1.0, inplace=False) [same] — x for x > 0, alpha * (exp(x) - 1) otherwise. - elu_(input, *a, **k) [same] — In-place F.elu: writes F.elu(input,...) into input and returns it. - gelu(input, approximate='none', *, maths=None) [same] — approximate="tanh": 0.5 x (1 + tanh(sqrt(2/pi) (x + 0.044715 x^3))). - glu(input, dim=-1) [same] — a * sigmoid(b), with a and b the two halves of input along dim. - gumbel_softmax(logits, tau=1.0, hard=False, eps=1e-10, dim=-1) [same] — softmax((logits + Gumbel noise) / tau) along dim; hard=True returns one-hot samples with the soft gradient (straight-through). - hardshrink(input, lambd=0.5) [same] — x where |x| > lambd, else 0. - hardsigmoid(input, inplace=False) [same] — relu6(x + 3) / 6. - hardswish(input, inplace=False) [same] — x * relu6(x + 3) / 6. - hardtanh(Tensor input, float min_val=-1.0, float max_val=1.0, bool inplace=False) -> Tensor A quantized input runs the quantized kernel (same parameters). [same] - hardtanh_(input, *a, **k) [same] — In-place F.hardtanh: writes F.hardtanh(input,...) into input and returns it. - leaky_relu(input, negative_slope=0.01, inplace=False) [same] — max(x, 0) + negative_slope * min(x, 0). - leaky_relu_(input, *a, **k) [same] — In-place F.leaky_relu: writes F.leaky_relu(input,...) into input and returns it. - log_softmax(input, dim=None, *, dtype=None) [same] — log(softmax(x)) along dim, computed stably (x - logsumexp); dtype= casts the input first. - logsigmoid(input) [same] — log(sigmoid(x)), computed stably. - mish(input, inplace=False) [same] — x * tanh(softplus(x)). - prelu(input, weight) [same] — weight has 1 or C (= input.shape[1]) entries, broadcast over dim 1. - relu(Tensor self, bool inplace=False) -> Tensor [same] — max(x, 0). - relu6(Tensor input, bool inplace=False) -> Tensor [same] — min(max(x, 0), 6). - relu_(input, *a, **k) [same] — In-place F.relu: writes F.relu(input,...) into input and returns it. - rrelu(input, lower=0.125, upper=0.3333333333333333, training=False, inplace=False) [same] — Randomized leaky ReLU: negative slopes drawn uniformly from [lower, upper] in training, their mean in eval. - rrelu_(input, *a, **k) [same] — In-place F.rrelu: writes F.rrelu(input,...) into input and returns it. - selu(input, inplace=False) [same] — scale * elu(x, alpha) with the SELU constants. - sigmoid(input, *, maths=None) [same] — F.sigmoid / nn.Sigmoid: 1 / (1 + exp(-x)). - silu(input, inplace=False, *, maths=None) [same] - softmax(input, dim=None, *args, **kw) [same] - softmin(input, dim=None, *, dtype=None) [same] — softmax(-x) along dim. - softplus(input, beta=1.0, threshold=20.0) [same] — log(1 + exp(beta * x)) / beta, linear above threshold. - softshrink(input, lambd=0.5) [same] — x - lambd above lambd, x + lambd below -lambd, else 0. - softsign(input) [same] — x / (1 + |x|). - tanh(input, *, maths=None) [same] - tanhshrink(input) [same] — x - tanh(x). - threshold(input, threshold, value, inplace=False) [same] — x where x > threshold, else value. - threshold_(input, *a, **k) [same] — In-place F.threshold: writes F.threshold(input,...) into input and returns it. ### Linear functions - bilinear(input1, input2, weight, bias=None) [same] — y = x1^T W x2 + b for weight (out, in1, in2): einsum("...i,oij,...j->...o"). - linear(input, weight, bias=None) [same] — x @ weight.T + bias. ### Dropout functions - alpha_dropout(input, p=0.5, training=False, inplace=False, _feature=False) [same] — Dropout for SELU networks: dropped elements take SELU's negative saturation value and an affine correction keeps mean and variance. - dropout(input, p=0.5, training=True, inplace=False) [same] — nn.Dropout passes training=self.training. - dropout1d(input, p=0.5, training=True, inplace=False) [same] — Zeroes whole channels of (N, C, L) or (C, L) with probability p in training, scaling the rest by 1/(1-p). - dropout2d(input, p=0.5, training=True, inplace=False) [same] — Zeroes whole channels of (N, C, H, W) or (C, H, W) with probability p in training, scaling by 1/(1-p). - dropout3d(input, p=0.5, training=True, inplace=False) [same] — Zeroes whole channels of (N, C, D, H, W) or (C, D, H, W) with probability p in training, scaling by 1/(1-p). - feature_alpha_dropout(input, p=0.5, training=False, inplace=False) [same] — alpha_dropout over whole channels. ### Sparse functions - embedding(input, weight, padding_idx=None, max_norm=None, norm_type=2.0, scale_grad_by_freq=False, sparse=False) [different] — Rows of weight picked by the ids (any integer dtype). Different: embedding(Tensor input, Tensor weight, int? padding_idx=None, float? max_norm=None, float norm_type=2.0, bool scale_grad_by_freq=False, bool sparse=False) -> Tensor Rows of weight picked by the ids (any integer dtype). padding_idx: that row gets no gradient, as in PyTorch. max_norm / scale_grad_by_f - embedding_bag(input, weight, offsets=None, max_norm=None, norm_type=2, scale_grad_by_freq=False, mode='mean', sparse=False, per_sample_weights=None, include_last_offset=False, padding_idx=None) [same] — Sums, means or maxes (mode) the embeddings of each bag without building the per-index rows tensor. - one_hot(input, num_classes=-1) [same] — int64 one-hot vectors of num_classes (inferred from the maximum when -1). ### Distance functions - cosine_similarity(x1, x2, dim=1, eps=1e-08, *, maths=None) [same] - cross_similarity(x1, x2, dim=1, eps=1e-08) -> Tensor [extra] — The signed cross `sign(u·v) (u·v)² / (Q(u) Q(v))`: `1 − spread` with the sign of `u·v`, in `[−1, 1]`. - pairwise_distance(x1, x2, p=2.0, eps=1e-06, keepdim=False, *, maths=None) [same] — ||x1 - x2 + eps||_p along the last dim (PyTorch adds eps to the difference). - pdist(input, p=2) [same] — Pairwise p-norm distances between the rows of an (N, M) input, upper triangle flattened: N (N - 1) / 2 values. - spread(x1, x2, dim=1, eps=1e-08) -> Tensor [extra] — The spread between vectors along `dim`: `1 − (u·v)² / (Q(u) Q(v))`, where `Q(u) = u·u`. ### Loss functions - binary_cross_entropy(input: torch.Tensor, target: torch.Tensor, weight: torch.Tensor | None = None, size_average: bool | None = None, reduce: bool | None = None, reduction: str = 'mean') -> torch.Tensor [same] — F.binary_cross_entropy: -(t log p + (1 - t) log(1 - p)), logs clamped at -100 as PyTorch, optional weight, reduced. - binary_cross_entropy_with_logits(input: torch.Tensor, target: torch.Tensor, weight: torch.Tensor | None = None, size_average: bool | None = None, reduce: bool | None = None, reduction: str = 'mean', pos_weight: torch.Tensor | None = None) -> torch.Tensor [same] — F.binary_cross_entropy_with_logits: binary cross entropy of sigmoid(input) computed stably from the logits; pos_weight weighs the positive term. - cosine_embedding_loss(input1, input2, target, margin=0.0, size_average=None, reduce=None, reduction='mean') [same] — 1 - cos(x1, x2) for target 1, max(0, cos(x1, x2) - margin) for target -1; reduced by reduction. - cross_entropy(input, target, *args, temperature=None, **kw) [same] — cross_entropy with every PyTorch option: class-index targets (weight, ignore_index, label smoothing, K-dim) or class-probability targets. - ctc_loss(log_probs, targets, input_lengths, target_lengths, blank=0, reduction='mean', zero_infinity=False) [same] — Connectionist temporal classification: the forward (alpha) recursion in log space over the extended target (blanks interleaved), written with Riptorch ops per time step (differentiable). - gaussian_nll_loss(input, target, var, full=False, eps=1e-06, reduction='mean') [same] — 0.5 (log var + (x - y)^2 / var), var clamped to eps (full adds 0.5 log 2 pi); var may omit the last dim. - hinge_embedding_loss(input, target, margin=1.0, size_average=None, reduce=None, reduction='mean') [same] — x for target 1, max(0, margin - x) for target -1; reduced by reduction. - huber_loss(input: torch.Tensor, target: torch.Tensor, reduction: str = 'mean', delta: float = 1.0, weight: torch.Tensor | None = None) -> torch.Tensor [same] — F.huber_loss: 0.5 d^2 where |d| < delta, else delta (|d| - 0.5 delta), reduced. - kl_div(input: torch.Tensor, target: torch.Tensor, size_average: bool | None = None, reduce: bool | None = None, reduction: str = 'mean', log_target: bool = False) -> torch.Tensor [same] — 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. - l1_loss(input: torch.Tensor, target: torch.Tensor, size_average: bool | None = None, reduce: bool | None = None, reduction: str = 'mean', weight: torch.Tensor | None = None) -> torch.Tensor [same] — F.l1_loss: the mean (or sum / none) absolute difference between input and target. - margin_ranking_loss(input1: torch.Tensor, input2: torch.Tensor, target: torch.Tensor, margin: float = 0, size_average: bool | None = None, reduce: bool | None = None, reduction: str = 'mean') -> torch.Tensor [same] — F.margin_ranking_loss: max(0, -target * (input1 - input2) + margin), reduced. - model_cross_entropy(logits, target, temperature=None) [extra] — -mean log p_k under the model's configured map, no gradient (Riptorch extension: the side cross-entropy). - mse_loss(a, b, size_average=None, reduce=None, reduction='mean') [same] — The mean squared error (a - b)^2, reduced by 'mean', 'sum' or 'none'; computed in float32 under autocast. - multi_margin_loss(input, target, p=1, margin=1.0, weight=None, size_average=None, reduce=None, reduction='mean') [same] — Multi-class hinge loss: sum over i != y of max(0, margin - x[y] + x[i])^p / C (optional class weights). - multilabel_margin_loss(input, target, size_average=None, reduce=None, reduction='mean') [same] — Multi-label hinge loss: target rows list the label indices, ended by the first -1. - multilabel_soft_margin_loss(input, target, weight=None, size_average=None, reduce=None, reduction='mean') [same] — Mean over classes of the binary logistic losses -(y log sigmoid(x) + (1 - y) log sigmoid(-x)). - nll_loss(input, target, weight=None, size_average=None, ignore_index=-100, reduce=None, reduction='mean') [same] — -input[n, target[n]] (times weight[target[n]]), over N, C, d1,... - poisson_nll_loss(input, target, log_input=True, full=False, size_average=None, eps=1e-08, reduce=None, reduction='mean') [same] — Poisson negative log likelihood: exp(x) - y x (log_input=True) or x - y log(x + eps); full adds Stirling's term for y > 1. - smooth_l1_loss(input: torch.Tensor, target: torch.Tensor, size_average: bool | None = None, reduce: bool | None = None, reduction: str = 'mean', beta: float = 1.0) -> torch.Tensor [same] — F.smooth_l1_loss: 0.5 d^2 / beta where |d| < beta, else |d| - 0.5 beta (d = input - target), reduced. - soft_margin_loss(input: torch.Tensor, target: torch.Tensor, size_average: bool | None = None, reduce: bool | None = None, reduction: str = 'mean') -> torch.Tensor [same] — F.soft_margin_loss: log(1 + exp(-target * input)), reduced. - triplet_margin_loss(anchor, positive, negative, margin=1.0, p=2, eps=1e-06, swap=False, size_average=None, reduce=None, reduction='mean') [same] — max(0, margin + d(a, p) - d(a, n)) with p-norm pairwise distances; swap uses min(d(a, n), d(p, n)). - triplet_margin_with_distance_loss(anchor, positive, negative, *, distance_function=None, margin=1.0, swap=False, reduction='mean') [same] — triplet_margin_loss with any distance_function (default pairwise_distance). ### Vision functions - affine_grid(theta, size, align_corners=None, *, align=False) [same] — theta [N, 2, 3] (4-d size) or [N, 3, 4] (5-d): the base grid of normalised pixel centres (or corners) times theta^T. - channel_shuffle(input, groups) [same] — Splits the C channels into groups and interleaves them: (N, g, C/g,...) transposed to (N, C/g, g,...). - grid_sample(input, grid, mode='bilinear', padding_mode='zeros', align_corners=None, *, align=False) [same] — 4-d input; modes bilinear / nearest / bicubic (bicubic with zeros padding), padding zeros / border / reflection. - interpolate(Tensor input, Any size=None, Any scale_factor=None, str? mode="nearest", Any align_corners=None, Any recompute_scale_factor=None, bool antialias=False, *, int[] factors=(), int[] out_size=(), float[] scales=(), int mode_code=-1, bool align=False) -> Tensor [different] — A quantized input runs the quantized kernel (same parameters). Different: some arguments are not supported yet (they raise NotImplementedError). - pad(input, pad, mode='constant', value=None) [same] — Pairs from the last dim backwards (negative amounts crop). - pixel_shuffle(input, upscale_factor) [same] — Rearranges (C r^2, H, W) to (C, H r, W r). - pixel_unshuffle(input, downscale_factor) [same] — Rearranges (C, H r, W r) to (C r^2, H, W). - upsample(input, size=None, scale_factor=None, mode='nearest', align_corners=None) [same] — F.upsample (deprecated in PyTorch): F.interpolate. - upsample_bilinear(input, size=None, scale_factor=None) [same] — F.upsample_bilinear: F.interpolate with mode "bilinear", align_corners=True. - upsample_nearest(input, size=None, scale_factor=None) [same] — F.upsample_nearest: F.interpolate with mode "nearest". ### Normalization - batch_norm(input, running_mean, running_var, weight=None, bias=None, training=False, momentum=0.1, eps=1e-05) [same] — Over every dim but 1 (channels). - group_norm(input, num_groups, weight=None, bias=None, eps=1e-05) [same] — Normalises each group of channels over its channels and spatial dims, then applies weight and bias per channel. - 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) [same] — Each (sample, channel) normalised over its spatial dims (or by running statistics with use_input_stats=False). - layer_norm(input, normalized_shape, weight=None, bias=None, eps=1e-05, *, maths=None) [same] — Over the last len(normalized_shape) dims; weight / bias of that shape (or none). - local_response_norm(input, size, alpha=0.0001, beta=0.75, k=1.0) [same] — Divides each element by (k + alpha * mean of squares over size neighbouring channels)^beta. - normalize(input, p=2.0, dim=1, eps=1e-12, *, maths=None) [same] — x / max(||x||_p, eps) along dim. - rms_norm(input, normalized_shape, weight=None, eps=None, *, maths=None) [same] — x / sqrt(mean(x^2 over the normalized dims) + eps) * weight; eps defaults to float32's machine epsilon. ### More - assert_int_or_pair(arg, arg_name, message) [same] — Accepts anything (PyTorch's helper only asserts in TorchScript). - boolean_dispatch(arg_name, arg_index, default, if_true, if_false, module_name, func_name) [same] — A function calling if_true or if_false by the boolean argument arg_name (keyword or position arg_index, else default), as PyTorch's helper for return_indices variants. - Callable() [same] — Deprecated alias to collections.abc.Callable. - celu_(input, *a, **k) [same] — In-place F.celu: writes F.celu(input,...) into input and returns it. - custom [extra] - DType(name, code, size, ctype, floating, signed=True, fmt=None) [same] — A dtype. - grouped_mm(mat_a, mat_b, *, offs=None, bias=None, out_dtype=None) [same] — Matrix products per group: 3-d x 3-d batched; with offs (cumulative group ends), a 2-d operand splits along its rows (2-d A x 3-d B), its columns (3-d A x 2-d B) or the shared dimension (2-d x 2-d). - handle_torch_function(public_api, relevant_args, *args, **kwargs) [same] — Calls public_api(*args, **kwargs) (no overrides to dispatch to). - has_torch_function(*a) [same] — False: Riptorch tensors have no __torch_function__ overrides to dispatch to. - has_torch_function_unary(*a) [same] — False: Riptorch tensors have no __torch_function__ overrides to dispatch to. - has_torch_function_variadic(*a) [same] — False: Riptorch tensors have no __torch_function__ overrides to dispatch to. - install_maths_routes(F) [extra] — Puts the exponential-equivalent router in front of F.cross_entropy, F.softmax and F.scaled_dot_product_attention (called once at import, after the generated ops are installed). - linear_cross_entropy(input, linear_weight, target, *, linear_bias=None, weight=None, reduction='mean', ignore_index=None, label_smoothing=0.0, options=None) [same] — cross_entropy(linear(input, linear_weight, linear_bias), target,...) (the logits' class dimension is dim 1 for batched inputs, as cross_entropy reads them). - maths_custom() [extra] — True when the maths configuration is neither preset (see riptorch.set_maths). - model_probs(logits, temperature=None) [extra] — The model's probabilities under the configured output map. - native_channel_shuffle(input, groups) [same] — Splits the C channels into groups and interleaves them: (N, g, C/g,...) transposed to (N, C/g, g,...). - Optional(*args, **kwds) [same] — Optional[X] is equivalent to Union[X, None]. - scaled_addmm(input, mat1, mat2, scale_a, scale_recipe_a, scale_b, scale_recipe_b, swizzle_a=None, swizzle_b=None, contraction_dim=(), use_fast_accum=False, *, beta=1.0, alpha=1.0) [same] — beta * input + alpha * (scale_a A) @ (scale_b B) for low-precision mat1 / mat2, in input's dtype. - scaled_addmm_(input, mat1, mat2, scale_a, scale_recipe_a, scale_b, scale_recipe_b, swizzle_a=None, swizzle_b=None, contraction_dim=(), use_fast_accum=False, *, beta=1.0, alpha=1.0) [same] — In-place scaled_addmm: writes the result into input and returns it. - scaled_grouped_mm(mat_a, mat_b, scale_a, scale_recipe_a, scale_b, scale_recipe_b, swizzle_a=None, swizzle_b=None, bias=None, offs=None, output_dtype=riptorch.bfloat16, contraction_dim=(), use_fast_accum=False) [same] — grouped_mm of scaled low-precision operands (offs splits the groups), plus bias, in output_dtype. - scaled_mm(mat_a, mat_b, scale_a, scale_recipe_a, scale_b, scale_recipe_b, swizzle_a=None, swizzle_b=None, bias=None, output_dtype=riptorch.bfloat16, contraction_dim=(), use_fast_accum=False) [same] — (scale_a * A) @ (scale_b * B) (+ bias) for fp8 / fp4 A and B (tensor-wise or row-wise scales), in output_dtype. - ScalingType(*values) [same] - selu_(input, *a, **k) [same] — In-place F.selu: writes F.selu(input,...) into input and returns it. - SwizzleType(*values) [same] - Tensor(handle) [same] — A tensor: values of one dtype in a shape, held by Riptorch's Raya core. ## torch.optim ### Base class - Optimizer(params, defaults) [same] — torch.optim.Optimizer: param_groups (each a dict with "params" and the options), state (per parameter), zero_grad, add_param_group, state_dict / load_state_dict, step pre / post hooks. ### Optimizers - Adadelta(params, lr=1.0, rho=0.9, eps=1e-06, weight_decay=0, foreach=None, *, capturable=False, maximize=False, differentiable=False) [same] — torch.optim.Adadelta: step sizes from running averages of squared gradients and squared updates (rho); lr scales the update. - Adafactor(params, lr=0.01, beta2_decay=-0.8, eps=(None, 0.001), d=1.0, weight_decay=0.0, *, foreach=None, maximize=False) [same] — torch.optim.Adafactor: factored second moments (row and column variances) for matrices, a full one for vectors; step size min(lr, 1/sqrt(t)) scaled by the parameter's RMS (at least eps[1]), update cli - Adagrad(params, lr=0.01, lr_decay=0, weight_decay=0, initial_accumulator_value=0, eps=1e-10, foreach=None, *, maximize=False, differentiable=False, fused=None) [same] — torch.optim.Adagrad: per-element lr / (sqrt(sum of squared gradients) + eps), lr decaying as lr / (1 + (t - 1) lr_decay). - Adam(params, lr=0.001, betas=(0.9, 0.999), eps=1e-08, weight_decay=0.0, amsgrad=False, *, foreach=None, maximize=False, capturable=False, differentiable=False, fused=None, decoupled_weight_decay=False) [same] — torch.optim.Adam. - Adamax(params, lr=0.002, betas=(0.9, 0.999), eps=1e-08, weight_decay=0, foreach=None, *, maximize=False, differentiable=False, capturable=False) [same] — torch.optim.Adamax: Adam with the infinity norm (a running max of |g|) in place of the second moment. - AdamW(params, lr=0.001, betas=(0.9, 0.999), eps=1e-08, weight_decay=0.01, amsgrad=False, *, maximize=False, foreach=None, capturable=False, differentiable=False, fused=None) [same] — torch.optim.AdamW: Adam with decoupled weight decay (default 1e-2): w -= lr * wd * w before the Adam update. - ASGD(params, lr=0.01, lambd=0.0001, alpha=0.75, t0=1000000.0, weight_decay=0, foreach=None, maximize=False, differentiable=False, capturable=False) [same] — torch.optim.ASGD: SGD with decaying step size and a running average of the parameters (state "ax") from t0. - LBFGS(params, lr=1, max_iter=20, max_eval=None, tolerance_grad=1e-07, tolerance_change=1e-09, history_size=100, line_search_fn=None, *, maximize=False) [same] — torch.optim.LBFGS: one parameter group; step(closure) runs up to max_iter iterations of limited-memory BFGS on the flattened parameters, with a fixed step (lr) or line_search_fn="strong_wolfe". - Lion(params, lr=0.0001, betas=(0.9, 0.99), weight_decay=0.0) [extra] — Lion (Chen et al. - Muon(params, lr=0.001, weight_decay=0.1, momentum=0.95, nesterov=True, ns_coefficients=(3.4445, -4.775, 2.0315), eps=1e-07, ns_steps=5, adjust_lr_fn=None) [same] — torch.optim.Muon (2-d parameters): momentum, Newton-Schulz orthogonalisation of the update, decoupled weight decay, the learning-rate adjustment by shape. - NAdam(params, lr=0.002, betas=(0.9, 0.999), eps=1e-08, weight_decay=0, momentum_decay=0.004, decoupled_weight_decay=False, *, foreach=None, maximize=False, capturable=False, differentiable=False) [same] — torch.optim.NAdam: Adam with Nesterov momentum and a momentum schedule (momentum_decay). - RAdam(params, lr=0.001, betas=(0.9, 0.999), eps=1e-08, weight_decay=0, decoupled_weight_decay=False, *, foreach=None, maximize=False, capturable=False, differentiable=False) [same] — torch.optim.RAdam: Adam whose adaptive term is switched on by the variance-rectification test (rho_t > 5). - RMSprop(params, lr=0.01, alpha=0.99, eps=1e-08, weight_decay=0, momentum=0, centered=False, capturable=False, foreach=None, maximize=False, differentiable=False) [same] — torch.optim.RMSprop: divides the gradient by a running root-mean-square (alpha); optional momentum and centered variant. - Rprop(params, lr=0.01, etas=(0.5, 1.2), step_sizes=(1e-06, 50), *, capturable=False, foreach=None, maximize=False, differentiable=False) [same] — torch.optim.Rprop: per-element step sizes grown by etas[1] when the gradient keeps its sign, shrunk by etas[0] when it flips, clamped to step_sizes; only the gradient's sign moves the weight. - SGD(params, lr=0.001, momentum=0.0, dampening=0.0, weight_decay=0.0, nesterov=False, *, maximize=False, foreach=None, differentiable=False, fused=None) [same] — torch.optim.SGD: lr, momentum, dampening, weight_decay, nesterov, maximize; parameter groups. - SparseAdam(params, lr=0.001, betas=(0.9, 0.999), eps=1e-08, maximize=False) [same] — torch.optim.SparseAdam. ### Utilities - swap_in_optimizer_params_and_state(optimizer, swapin_parameters, swapin_optim_state) [same] — Inside: the optimizer's parameters are swapin_parameters (in parameter order) and its state is swapin_optim_state ({"state": {index:...}, "param_groups": [...]}); restored on exit. ### Learning-rate schedulers (optim.lr_scheduler) - ChainedScheduler(schedulers, optimizer=None) [same] — Steps several schedulers of one optimizer together, each applying its factor in turn. - ConstantLR(optimizer, factor=0.3333333333333333, total_iters=5, last_epoch=-1) [same] — lr * factor until total_iters epochs, then the original lr. - CosineAnnealingLR(optimizer, T_max, eta_min=0.0, last_epoch=-1) [same] — lr = eta_min + (initial_lr - eta_min) (1 + cos(pi epoch / T_max)) / 2 (chainable, as PyTorch: it keeps rising past T_max rather than restarting). - CosineAnnealingWarmRestarts(optimizer, T_0, T_mult=1, eta_min=0.0, last_epoch=-1) [same] — Cosine annealing from initial_lr to eta_min over T_i epochs, restarting each time; T_i starts at T_0 and is multiplied by T_mult at every restart (SGDR). - CyclicLR(optimizer, base_lr, max_lr, step_size_up=2000, step_size_down=None, mode='triangular', gamma=1.0, scale_fn=None, scale_mode='cycle', cycle_momentum=True, base_momentum=0.8, max_momentum=0.9, last_epoch=-1) [same] — Cycles lr between base_lr and max_lr (triangular, triangular2, exp_range or a custom scale_fn), and momentum inversely between max_momentum and base_momentum when cycle_momentum. - ExponentialLR(optimizer, gamma, last_epoch=-1) [same] — lr *= gamma every epoch. - LambdaLR(optimizer, lr_lambda, last_epoch=-1) [same] — lr = initial_lr * lr_lambda(epoch); lr_lambda may be one function or one per group. - LinearLR(optimizer, start_factor=0.3333333333333333, end_factor=1.0, total_iters=5, last_epoch=-1) [same] — Scales lr linearly from start_factor to end_factor over total_iters epochs, then holds it. - LRScheduler(optimizer, last_epoch=-1) [same] — Base of the learning-rate schedules: sets param_groups[i]["lr"] on its optimizer at each step. - MultiplicativeLR(optimizer, lr_lambda, last_epoch=-1) [same] — lr *= lr_lambda(epoch) at each step after the first. - MultiStepLR(optimizer, milestones, gamma=0.1, last_epoch=-1) [same] — lr *= gamma at each milestone epoch (a repeated milestone applies gamma that many times). - OneCycleLR(optimizer, max_lr, total_steps=None, epochs=None, steps_per_epoch=None, pct_start=0.3, anneal_strategy='cos', cycle_momentum=True, base_momentum=0.85, max_momentum=0.95, div_factor=25.0, final_div_factor=10000.0, three_phase=False, last_epoch=-1) [same] — The 1cycle policy: lr rises from max_lr/div_factor to max_lr over pct_start of total_steps, then anneals to initial_lr/final_div_factor (cos or linear); momentum moves the opposite way. - PolynomialLR(optimizer, total_iters=5, power=1.0, last_epoch=-1) [same] — lr = initial_lr * (1 - min(epoch, total_iters) / total_iters) ** power. - ReduceLROnPlateau(optimizer, mode='min', factor=0.1, patience=10, threshold=0.0001, threshold_mode='rel', cooldown=0, min_lr=0, eps=1e-08) [same] — Multiplies lr by factor when a metric stops improving for patience epochs (mode "min" or "max", relative or absolute threshold), then waits cooldown epochs; never below min_lr. - SequentialLR(optimizer, schedulers, milestones, last_epoch=-1) [same] — Runs schedulers one after another, switching to the next at each milestone epoch. - StepLR(optimizer, step_size, gamma=0.1, last_epoch=-1) [same] — lr *= gamma every step_size epochs. ## torch.linalg ### Functions - cholesky(A, *, upper=False, out=None) [same] — linalg.cholesky(A, *, upper=False): A = L L^T (only A's lower triangle is read). - cholesky_ex(A, *, upper=False, check_errors=False, out=None) [same] — linalg.cholesky_ex: (L, info), info an int32 per matrix (0, or k > 0 when the leading k x k minor is not positive definite); raises only with check_errors=True. - cond(A, p=None, *, out=None) [same] — linalg.cond(A, p=None): s_max / s_min for p None / 2 (-2: the reciprocal); else norm(A, p) norm(A^-1, p). - cross(input, other, dim=-1) [same] — The 3-d cross product along dim (size 3), broadcasting. - det(A, *, out=None, maths=None, exact=False) [different] Different: exact integer determinants (Bareiss); PyTorch refuses integer input, and for [[1e9, 1e9+1], [1e9+1, 1e9+2]] PyTorch float64 gives -84.7 and MLX float64 gives 0.0 where the answer is -1 - diagonal(A, *, offset=0, dim1=-2, dim2=-1) [same] — torch.linalg.diagonal: the diagonal of the last two dims (offset, dim1=-2, dim2=-1). - eig(A, *, out=None) [same] — Hessenberg + Francis QR (EISPACK hqr2); each vector unit length with its largest component real (LAPACK geev). - eigh(A, UPLO='L', *, out=None) [same] — fixed (largest-magnitude component positive); LAPACK's is arbitrary, so compare V up to column signs. - eigvals(A, *, out=None) [same] — linalg.eigvals: the (complex) eigenvalues of square A. - eigvalsh(A, UPLO='L', *, out=None) [same] — linalg.eigvalsh: the eigenvalues of symmetric A (read from the UPLO triangle), ascending; differentiable. - householder_product(A, tau, *, out=None) [same] — linalg.householder_product(A, tau): the first n columns of H_1... - inv(A, *, out=None, maths=None, exact=False) [different] Different: exact inverses of integer matrices (a FractionTensor); PyTorch and MLX refuse integer input, and PyTorch's float64 inverse of the 12x12 Hilbert matrix is off by 3.4e-2 - inv_ex(A, *, check_errors=False, out=None) [same] — linalg.inv_ex: (inverse, info), info an int32 per matrix (0, or k > 0 when the matrix is singular); raises only with check_errors=True. - ldl_factor(A, *, hermitian=False, out=None) [same] — linalg.ldl_factor: (LD, pivots) of symmetric A, as ldl_factor_ex without info. - ldl_factor_ex(A, *, hermitian=False, check_errors=False, out=None) [different] — linalg.ldl_factor_ex: LAPACK sytrf's compact form (L strictly below the diagonal, D on it) for matrices where Bunch-Kaufman takes only 1x1 pivots without interchanges (|d_k| >= alpha * column max, alp Different: Others raise NotImplementedError (no 2x2 pivots yet). - ldl_solve(LD, pivots, B, *, hermitian=False, out=None) [same] — linalg.ldl_solve for the factors ldl_factor gives (no interchanges): L D L^T X = B. - lstsq(A, B, rcond=None, *, driver=None, out=None) [same] — least-squares solution from the SVD (all drivers; gelsy / gels / gelsd / gelss agree for full-rank A), with each driver's PyTorch outputs: residuals for gels / gelsd / gelss when m > n and A has full - lu(A, *, pivot=True, out=None) [same] - lu_factor(A, *, pivot=True, out=None) [same] — (as in PyTorch: the zero pivot stays in U). - lu_factor_ex(A, *, pivot=True, check_errors=False, out=None) [different] — linalg.lu_factor_ex: (LU, pivots, info) with partial pivoting (pivot=False raises NotImplementedError); info is 0, or k > 0 when U[k-1, k-1] is zero. Different: linalg.lu_factor_ex: (LU, pivots, info) with partial pivoting (pivot=False raises NotImplementedError); info is 0, or k > 0 when U[k-1, k-1] is zero. - lu_solve(LU, pivots, B, *, left=True, adjoint=False, out=None) [same] — linalg.lu_solve(LU, pivots, B, *, left=True, adjoint=False). - matmul(input, other) [same] - matrix_exp(A) [same] — linalg.matrix_exp(A): Pade-13 scaling and squaring (Higham 2005). - matrix_norm(A, ord='fro', dim=(-2, -1), keepdim=False, *, dtype=None, out=None, maths=None) [same] — linalg.matrix_norm(A, ord='fro'): 'fro', 'nuc', inf, -inf, 1, -1, 2, -2. - matrix_power(A, n, *, out=None) [same] — linalg.matrix_power(A, n): repeated squaring (n < 0: of the inverse); n = 0 gives the identity. - matrix_rank(A, *, atol=None, rtol=None, hermitian=False, tol=None, out=None, maths=None) [different] Different: exact rank of integer matrices; MLX has no matrix_rank; PyTorch refuses integer input, and in float64 gives rank 12 for the full-rank 16x16 integer Hilbert matrix - matrix_sqrth(A) [same] — linalg.matrix_sqrth(A): V diag(w^(1/2)) V^T from eigh (lower triangle), differentiable through eigh. - multi_dot(tensors, *, out=None) [same] — linalg.multi_dot([A, B,...]): the chain product (first 1-d as a row, last 1-d as a column), multiplied in the order that needs the fewest scalar products (dynamic programming over the chain). - norm(A, ord=None, dim=None, keepdim=False, *, out=None, dtype=None, maths=None) [same] — linalg.norm: a matrix norm for a str ord or a 2-tuple dim (or 2-d A with ord given and dim None), else a vector norm. - pinv(A, *, atol=None, rtol=None, hermitian=False, out=None) [same] — linalg.pinv(A): V diag(1/s, s > tol) U^T from the SVD (eigh when hermitian), differentiable through it. - polar(A, *, out=None) [same] - qr(A, mode='reduced', *, out=None) [same] - slogdet(A, *, out=None, maths=None) [same] - solve(A, B, *, left=True, out=None, maths=None, exact=False) [different] Different: exact solutions for integer systems (a FractionTensor); PyTorch and MLX refuse integer input, and PyTorch's float64 solve on the 12x12 Hilbert matrix is off by 5.8e-2 - solve_ex(A, B, *, left=True, check_errors=False, out=None) [same] — linalg.solve_ex: (result, info) as linalg.solve, info an int32 per matrix (0, or k > 0 when A is singular); raises only with check_errors=True. - solve_triangular(A, B, *, upper, left=True, unitriangular=False, out=None) [same] — linalg.solve_triangular(A, B, *, upper, left=True, unitriangular=False). - svd(A, full_matrices=True, *, driver=None, out=None) [same] — sign (per pair), as with LAPACK. - svdvals(A, *, driver=None, out=None) [same] — linalg.svdvals: the singular values of A, descending; differentiable. - tensorinv(A, ind=2, *, out=None) [same] — linalg.tensorinv(A, ind=2): the inverse of A viewed as a prod(shape[:ind]) x prod(shape[ind:]) matrix. - tensorsolve(A, B, dims=None, *, out=None) [same] — linalg.tensorsolve(A, B, dims=None): X with tensordot(A, X, X.ndim) == B. - vander(x, *, N=None) [same] — linalg.vander(x, N=None): columns x^0, x^1,..., x^(N-1) (increasing powers). - vecdot(x, y, *, dim=-1, out=None) [same] — linalg.vecdot: the dot product of x and y along dim (broadcast); real inputs. - vector_norm(x, ord=2, dim=None, keepdim=False, *, dtype=None, maths=None) [same] — ord 2 (default), 1, inf, -inf, 0 or any p; dims (None: all). ### Classes - LinAlgError [same] — torch.linalg.LinAlgError: a factorisation or solve failed on its input (singular, not positive-definite). ### Riptorch extras - cayley(S, *, exact=False) [extra] — The Cayley transform Q = (I - S)^-1 (I + S) of a skew-symmetric S: an orthogonal matrix with no sin / cos and (rational S gives a rational orthogonal Q exactly; 2x2 with S = [[0, -t], [t, 0]] is the r - cayley_inverse(Q, *, exact=False) [extra] — S = (Q - I)(Q + I)^-1: the skew-symmetric matrix whose Cayley transform is Q (Q orthogonal without eigenvalue -1). - FractionTensor(values, shape) [extra] — Exact results: a tensor of reduced fractions (Python ints of any size, no rounding). - givens_triangularize(A, *, exact=False) [extra] — Exact triangularisation by scaled rotations (Givens with rational parameters): G A = R, R upper triangular, G's rows orthogonal with quadrances sigma (G G^T = diag(sigma)). - ldl(A, *, exact=False) [extra] — A = L D L^T (L unit lower triangular, D the diagonal as a vector): Cholesky without its root (L_chol = L D^(1/2)). - principal_spreads(A, B) [extra] — The spreads (ascending; classically sin^2 of the principal angles) between the column spaces of A (m x k) and B (m x l), full column rank: 1 - the eigenvalues of (A^T A)^-1 A^T B (B^T B)^-1 B^T A (the crosses; of - qr_quadrance(A, *, exact=False) [extra] — Exact QR: A = Q R with Q's columns orthogonal but not normalised, R unit upper triangular, and quadrances[j] = Q(q_j) = q_j. - quadrance(x, dim=-1, keepdim=False) [extra] — Q(x) = x. - rotation(t, n=2, i=0, j=1, *, dtype=None) [extra] — The rational rotation by Cayley parameter t (= tan(angle / 2)) in the (i, j) plane of n dimensions: cos = (1 - t^2) / (1 + t^2), sin = 2t / (1 + t^2) placed as a Givens matrix. - spread(u, v, dim=-1, keepdim=False) [extra] — The spread between vectors u and v: 1 - (u. - subspace_cross(A, B, *, exact=False) [extra] — The product of the crosses (classically cos^2 of the principal angles) between the column spaces of A and B (both m x k, full column rank): det(A^T B)^2 / (det(A^T A) det(B^T B)). ## torch.fft ### Functions - fft(input, n=None, dim=-1, norm=None, *, out=None, maths=None) [same] — torch.fft.fft: the 1-d discrete Fourier transform along dim (n pads or trims, norm as PyTorch); complex64 for float32 / integer input, complex128 for float64. - fft2(input, s=None, dim=(-2, -1), norm=None, *, out=None, maths=None) [same] — torch.fft.fft2: fftn over the last two dims (or dim). - fftfreq(n, d=1.0, *, dtype=None, device=None, requires_grad=False, layout=None) [same] — torch.fft.fftfreq: the sample frequencies of an n-point DFT with spacing d (float32 unless dtype=). - fftn(input, s=None, dim=None, norm=None, *, out=None, maths=None) [same] — torch.fft.fftn: the n-d DFT over dim (all dims, or the last len(s)) with sizes s. - fftshift(input, dim=None) [same] — torch.fft.fftshift: rolls the zero frequency to the centre of each dim (all dims by default). - hfft(input, n=None, dim=-1, norm=None, *, out=None, maths=None) [same] — torch.fft.hfft: the real DFT of a Hermitian-symmetric signal given by its first half. - hfft2(input, s=None, dim=(-2, -1), norm=None, *, out=None) [same] — hfftn over the last two dims (by default). - hfftn(input, s=None, dim=None, norm=None, *, out=None) [same] — The n-d FFT of a Hermitian-symmetric signal given by its half (last dim): irfftn(conj(x)), normalisation swapped. - ifft(input, n=None, dim=-1, norm=None, *, out=None, maths=None) [same] — torch.fft.ifft: the inverse 1-d DFT along dim (norm as PyTorch); returns complex. - ifft2(input, s=None, dim=(-2, -1), norm=None, *, out=None, maths=None) [same] — torch.fft.ifft2: ifftn over the last two dims (or dim). - ifftn(input, s=None, dim=None, norm=None, *, out=None, maths=None) [same] — torch.fft.ifftn: the inverse n-d DFT over dim with sizes s. - ifftshift(input, dim=None) [same] — torch.fft.ifftshift: the inverse of fftshift. - ihfft(input, n=None, dim=-1, norm=None, *, out=None, maths=None) [same] — torch.fft.ihfft: the inverse of hfft: the half spectrum of a real signal. - ihfft2(input, s=None, dim=(-2, -1), norm=None, *, out=None) [same] — ihfftn over the last two dims (by default). - ihfftn(input, s=None, dim=None, norm=None, *, out=None) [same] — The inverse of hfftn: conj(rfftn(x)) with the normalisation swapped (a real input's spectrum is Hermitian). - irfft(input, n=None, dim=-1, norm=None, *, out=None, maths=None) [same] — torch.fft.irfft: the real inverse of rfft; n sets the output length (default 2 * (m - 1)). - irfft2(input, s=None, dim=(-2, -1), norm=None, *, out=None, maths=None) [same] — torch.fft.irfft2: irfftn over the last two dims (or dim). - irfftn(input, s=None, dim=None, norm=None, *, out=None, maths=None) [same] — torch.fft.irfftn: the real inverse of rfftn. - rfft(input, n=None, dim=-1, norm=None, *, out=None, maths=None) [same] — torch.fft.rfft: the DFT of a real input, the n // 2 + 1 non-negative frequencies; complex inputs raise, as PyTorch. - rfft2(input, s=None, dim=(-2, -1), norm=None, *, out=None, maths=None) [same] — torch.fft.rfft2: rfftn over the last two dims (or dim). - rfftfreq(n, d=1.0, *, dtype=None, device=None, requires_grad=False, layout=None) [same] — torch.fft.rfftfreq: the n // 2 + 1 non-negative sample frequencies of an rfft. - rfftn(input, s=None, dim=None, norm=None, *, out=None, maths=None) [same] — torch.fft.rfftn: the n-d DFT of a real input, halved along the last dim. ### Classes - Tensor(handle) [same] — A tensor: values of one dtype in a shape, held by Riptorch's Raya core. ### Riptorch extras - cayley_points(n) [extra] — the rational twiddles of maths="rational" for length n, as Pythagorean triples [n, 3] (a, b, c), the point (a / c, b / c) = w^k, w = e^(-2 pi i / n), with a^2 + b^2 = c^2 exactly. - ntt(input, dim=-1, modulus=998244353, inverse=False) [extra] — the number-theoretic transform of an integer tensor along dim, mod a prime p (default 998244353 = 119 2^23 + 1): A[k] = sum_j a[j] w^(jk) mod p, w a primitive n-th root of unity mod p. - polymul(a, b) [extra] — the full linear convolution of the last dims (polynomial product; leading dims equal or one side 1-d). ## torch.special ### Functions - airy_ai(input, *, out=None) [same] — The Airy function Ai(x) (its gradient is nan: not implemented), per element: computed in float64 and rounded once to the input's float dtype (integer inputs give float32); differentiable. - bessel_j0(input, *, out=None) [same] — The Bessel function of the first kind of order 0, J0(x), per element: computed in float64 and rounded once to the input's float dtype (integer inputs give float32); differentiable. - bessel_j1(input, *, out=None) [same] — The Bessel function of the first kind of order 1, J1(x), per element: computed in float64 and rounded once to the input's float dtype (integer inputs give float32); differentiable. - bessel_y0(input, *, out=None) [same] — The Bessel function of the second kind of order 0, Y0(x), per element: computed in float64 and rounded once to the input's float dtype (integer inputs give float32); differentiable. - bessel_y1(input, *, out=None) [same] — The Bessel function of the second kind of order 1, Y1(x), per element: computed in float64 and rounded once to the input's float dtype (integer inputs give float32); differentiable. - chebyshev_polynomial_t(input, n, *, out=None) [same] — The Chebyshev polynomial of the first kind T_n(x), per element for integer degree n (a tensor or number; non-integer n gives nan, negative n gives 0); computed in float64 and rounded once; not differe - chebyshev_polynomial_u(input, n, *, out=None) [same] — The Chebyshev polynomial of the second kind U_n(x), per element for integer degree n (a tensor or number; non-integer n gives nan, negative n gives 0); computed in float64 and rounded once; not differ - chebyshev_polynomial_v(input, n, *, out=None) [same] — The Chebyshev polynomial of the third kind V_n(x), per element for integer degree n (a tensor or number; non-integer n gives nan, negative n gives 0); computed in float64 and rounded once; not differe - chebyshev_polynomial_w(input, n, *, out=None) [same] — The Chebyshev polynomial of the fourth kind W_n(x), per element for integer degree n (a tensor or number; non-integer n gives nan, negative n gives 0); computed in float64 and rounded once; not differ - digamma(input, *, out=None) [same] - entr(input, *, out=None) [same] — The elementwise entropy -x log(x): 0 at 0, -inf for x < 0. - erf(input, *, out=None) [same] — The error function (torch.erf); integer inputs give float32. - erfc(input, *, out=None) [same] — The complementary error function 1 - erf(x) (torch.erfc); integer inputs give float32. - erfcx(input, *, out=None) [different] Different: correctly rounded float32 values (computed in float64, rounded once); 1500 inputs in [-5, 40]: worst 13 ulp vs 0; MLX has no erfcx - erfinv(input, *, out=None) [same] - exp2(input, *, out=None) [same] — 2^x (torch.exp2); integer inputs give float32. - expit(input, *, out=None) [same] — The logistic sigmoid 1 / (1 + exp(-x)) (torch.sigmoid); integer inputs give float32. - expm1(input, *, out=None) [same] — exp(x) - 1, accurate near 0 (torch.expm1); integer inputs give float32. - gammainc(input, other, *, out=None) [same] — The regularized lower incomplete gamma function P(a, x) (input a, other x), in float64 and rounded once. - gammaincc(input, other, *, out=None) [same] — The regularized upper incomplete gamma function Q(a, x) = 1 - P(a, x), in float64 and rounded once. - gammaln(input, *, out=None) [same] — log|Gamma(x)|, per element: computed in float64 and rounded once to the input's float dtype (integer inputs give float32); differentiable. - hermite_polynomial_h(input, n, *, out=None) [same] — The physicists' Hermite polynomial H_n(x), per element for integer degree n (a tensor or number; non-integer n gives nan, negative n gives 0); computed in float64 and rounded once; not differentiable. - hermite_polynomial_he(input, n, *, out=None) [same] — The probabilists' Hermite polynomial He_n(x), per element for integer degree n (a tensor or number; non-integer n gives nan, negative n gives 0); computed in float64 and rounded once; not differentiab - i0(input, *, out=None) [same] - i0e(input, *, out=None) [different] Different: correctly rounded float32 values (computed in float64, rounded once); 1500 inputs in [0, 105]: worst 3 ulp vs 0; MLX has no i0e - i1(input, *, out=None) [same] — The modified Bessel function of the first kind of order 1, I1(x), per element: computed in float64 and rounded once to the input's float dtype (integer inputs give float32); differentiable. - i1e(input, *, out=None) [different] Different: correctly rounded float32 values (computed in float64, rounded once); 1500 inputs in [0, 105]: worst 8 ulp vs 0; MLX has no i1e - laguerre_polynomial_l(input, n, *, out=None) [same] — The Laguerre polynomial L_n(x), per element for integer degree n (a tensor or number; non-integer n gives nan, negative n gives 0); computed in float64 and rounded once; not differentiable. - legendre_polynomial_p(input, n, *, out=None) [same] — The Legendre polynomial P_n(x), per element for integer degree n (a tensor or number; non-integer n gives nan, negative n gives 0); computed in float64 and rounded once; not differentiable. - log1p(input, *, out=None) [same] — log(1 + x), accurate near 0 (torch.log1p); integer inputs give float32. - log_ndtr(input, *, out=None) [different] Different: correctly rounded float32 values (computed in float64, rounded once); 1500 inputs in [-40, 35]: worst 162 ulp vs 1; MLX has no log_ndtr - log_softmax(input, dim, *, dtype=None) [same] — torch.log_softmax along dim, after casting to dtype if given (integer inputs give float32). - logit(input, eps=None, *, out=None) [same] — log(p / (1 - p)), with p clamped to [eps, 1 - eps] when eps is given; integer inputs give float32. - logsumexp(input, dim=None, keepdim=False, *, out=None) [same] — log(sum(exp(x))) over dim with the largest value taken out first; out= written. - modified_bessel_i0(input, *, out=None) [same] — The modified Bessel function of the first kind of order 0, I0(x), per element: computed in float64 and rounded once to the input's float dtype (integer inputs give float32); differentiable. - modified_bessel_i1(input, *, out=None) [same] — The modified Bessel function of the first kind of order 1, I1(x), per element: computed in float64 and rounded once to the input's float dtype (integer inputs give float32); differentiable. - modified_bessel_k0(input, *, out=None) [same] — The modified Bessel function of the second kind of order 0, K0(x), per element: computed in float64 and rounded once to the input's float dtype (integer inputs give float32); differentiable. - modified_bessel_k1(input, *, out=None) [same] — The modified Bessel function of the second kind of order 1, K1(x), per element: computed in float64 and rounded once to the input's float dtype (integer inputs give float32); differentiable. - multigammaln(input, p, *, out=None) [same] — The multivariate log-gamma function of dimension p: p(p-1)/4 log(pi) + sum_j lgamma(x - j/2). - ndtr(input, *, out=None) [different] Different: keeps the lower tail (erfc form, float64, rounded once): 0 ulp vs PyTorch's worst 846370998 ulp in float32; PyTorch gives ndtr(-10) = 0 even in float64; MLX has no ndtr - ndtri(input, *, out=None) [different] Different: correctly rounded float32 values (computed in float64, rounded once); 1999 inputs in [6e-8, 1.2e-4]: worst 3 ulp vs 0; MLX has no ndtri - polygamma(n, input, *, out=None) [same] — polygamma(n, x): the n-th derivative of digamma. - psi(input, *, out=None) [same] - round(input, *, decimals=0, out=None) [same] — torch.round: to the nearest integer, ties to even, or to `decimals` decimal places. - scaled_modified_bessel_k0(input, *, out=None) [same] — The exponentially scaled K0: exp(x) K0(x), per element: computed in float64 and rounded once to the input's float dtype (integer inputs give float32); differentiable. - scaled_modified_bessel_k1(input, *, out=None) [same] — The exponentially scaled K1: exp(x) K1(x), per element: computed in float64 and rounded once to the input's float dtype (integer inputs give float32); differentiable. - shifted_chebyshev_polynomial_t(input, n, *, out=None) [same] — The shifted Chebyshev polynomial of the first kind T_n(x), i.e. - shifted_chebyshev_polynomial_u(input, n, *, out=None) [same] — The shifted Chebyshev polynomial of the second kind U_n(x), i.e. - shifted_chebyshev_polynomial_v(input, n, *, out=None) [same] — The shifted Chebyshev polynomial of the third kind V_n(x), i.e. - shifted_chebyshev_polynomial_w(input, n, *, out=None) [same] — The shifted Chebyshev polynomial of the fourth kind W_n(x), i.e. - sinc(input, *, out=None) [different] Different: correct next to the integers (exact argument reduction): 0 ulp vs PyTorch's worst 859354445 ulp in float32, 30% off at sinc(1 + 2^-23); MLX has no sinc - softmax(input, dim, *, dtype=None) [same] — torch.softmax along dim, after casting to dtype if given (integer inputs give float32). - spherical_bessel_j0(input, *, out=None) [same] — The spherical Bessel function of the first kind of order 0: sin(x) / x, 1 at 0. - xlog1py(input, other, *, out=None) [same] — x * log1p(y), 0 where x == 0 (unless y is nan, as PyTorch); differentiable. - xlogy(input, other, *, out=None) [same] — x * log(y), 0 where x == 0 (unless y is nan); differentiable. - zeta(input, other, *, out=None) [same] — The Hurwitz zeta function zeta(x, q) = sum over k >= 0 of (k + q)^-x, per element in float64 and rounded once; not differentiable. ### Classes - Tensor(handle) [same] — A tensor: values of one dtype in a shape, held by Riptorch's Raya core. ## Environment variables - RIPTORCH_COMPAT (pytorch): Stock PyTorch's behaviour everywhere, the same as torch.set_compat("pytorch"). Unset (or riptorch) keeps the correct-by-default results. - RIPTORCH_MATMUL (fp32 (default), bf16, fp16, exact; on the Apple GPU also fast, high): Floating-point matrix multiply precision, the same as torch.set_matmul(...). - RIPTORCH_INT_MATMUL (auto (default), gpu, cpu): Where exact integer matrix multiplies run, the same as torch.set_int_matmul(...). - RIPTORCH_FLOAT64 (auto (default), fast, gpu, cpu): Where float64 work runs on a Mac, the same as torch.set_float64(...). - RIPTORCH_FLOAT64_MIN_WORK (a number of operations): The smallest float64 graph set_float64 sends to the GPU. - RIPTORCH_LA_METHOD (auto (default), f64, mixed, f32): For testing: how float32 linear algebra is computed: a measured table, in float64 rounded once, float32 LU refined in float64, or stock-style float32. Float64 inputs always use float64. - RIPTORCH_DEVICE (unset or auto, cpu, gpu (also metal, mps), amd): Where work runs. Unset picks the GPU when there is a usable one and falls back to the CPU with one line of explanation. cpu runs everything on the CPU. gpu asks for the Apple GPU by name and raises an error if there isn't a usable one. amd uses an AMD Instinct GPU on Linux. - RIPTORCH_HYBRID (1): Apple silicon: splits a large float32, bfloat16 or float16 matrix multiply between the GPU and the CPU's matrix unit at the same time, on the same memory. Never used for exact results (the two sides' bits differ), batches or a transposed first operand. - RIPTORCH_HYBRID_SHARE (a fraction, default 0.22): With RIPTORCH_HYBRID=1: the share of the output rows the CPU computes (the last rows) while the GPU computes the rest. - RIPTORCH_HYBRID_MIN (multiply-adds, default 2³⁰): With RIPTORCH_HYBRID=1: the smallest product that is split. - RIPTORCH_NUM_THREADS (a number): CPU threads for Riptorch's CPU kernels. Default: OMP_NUM_THREADS if set, else the performance cores (Apple silicon) or the physical cores this process may use. - RIPTORCH_CPU_CACHE_DIR (a directory): Where compiled CPU programs are cached between runs (default: the user cache directory). - RIPTORCH_CPU_CACHE_MB (megabytes, default 512): The size cap of that cache; the least recently used programs are removed above it. 0 keeps nothing on disk. - RIPTORCH_CPU_LEVEL (x86-64-v2, x86-64-v3, x86-64-v4): Linux and Windows on x86-64: which build of the CPU library to load. By default the best one this processor supports (AVX2 or AVX-512) is picked automatically. - RIPTORCH_CPU_OFF (a comma list of sme, amx, i8mm, bf16): For testing: CPU features to treat as absent, so an M4 or M5 runs the way an M1 would. - RIPTORCH_MATHS (rational): Order-2 model maths for supported operations, the same as torch.set_maths("rational"). - RIPTORCH_WEIGHT (exp, taylor2, cayley, square_linear, relu_square): The softmax weighting map (set_maths(weight=...)). - RIPTORCH_ATTENTION (as RIPTORCH_WEIGHT): The weighting map attention uses (set_maths(attention=...)). - RIPTORCH_LOSS (cross_entropy, brier, spherical): What F.cross_entropy computes (set_maths(loss=...)). - RIPTORCH_RECENTER (1): Subtract each row's mean logit before the weighting map (set_maths(recenter=True)). - RIPTORCH_TEMPERATURE (a number, learned, learned_inv): The softmax temperature (set_maths(temperature=...)). - RIPTORCH_CAYLEY_EPS (a number, default 1/32): The clamp of the Cayley weighting map (set_maths(cayley_eps=...)). - RIPTORCH_FORCE_WEIGHTS_ONLY_LOAD (1): torch.load always uses weights_only=True (as TORCH_FORCE_WEIGHTS_ONLY_LOAD=1 does in PyTorch). - RIPTORCH_LOOPS_STRICT (1): Raises an error, instead of one warning and a slower Python fallback, if Riptorch's compiled kernels for special functions (lgamma, the Bessel functions, cummax and others) can't load. - RIPTORCH_PROFILE (1): Prints a timing line for every realised graph (build, compile and run). - RIPTORCH_TRACE_ERRORS (1): Errors raised inside Riptorch's engine carry its full stack trace (for bug reports).