Skip to main content

ClikaRT::ops

namespace

Classes

NameDescription
EllipsisTag...: expands to full slices over the dims no other entry names.
IndexBoundAn integer-typed op bound, a reshape dim: either a concrete int64_t literal or a 0-D/1-D integer Tensor (e.g. a shape_host read), so a shape-consuming argument composes without pulling concrete sizes to the host. Narrower than ScalarOrTensor by design: no float ctor (reshape(x, {1.5}) fails at compile time) and bool is deleted (it would otherwise promote silently to an index).
IndexEntryOne subscript position of index / index_put, the standard tensor indexing vocabulary: an int (select), a bool (0-D mask), an integer or boolean Tensor (advanced indexing), an IndexSlice, ellipsis, or new_axis. A braced integer list indexes via a Tensor (Tensor::from_data); pass it as the Tensor arm.
IndexSliceA [start, stop, step) range at one subscript position. Each slot is an IndexBound: an int literal, a 0-D/1-D integer Tensor, or absent (open bound; absent step is 1). all below is the fully-open slice.
NewAxisTagnumpy None / a fresh size-1 dim at this position.
ScalarOrTensorA ClikaRT-level value type (NOT op-layer machinery): one optional slot that carries a scalar (double / integer) OR a tensor. Every ctor is implicit on purpose. Pass a bare double, an integer, a Tensor, or std::nullopt straight to a ScalarOrTensor parameter; spelling the wrap at a call site (ops::ScalarOrTensor(x)) is redundant noise. ops::ScalarOrTensor remains a valid spelling via the alias below.

Enumerations

enum Activation

enum class Activation : std::uint8_t

A fused activation epilogue. Identity = none. The gated kinds (SwiGlu, GeGlu, ReGlu, Situ) take a concatenated [*, 2d] gate‖up input and emit [*, d], used as a fused projection epilogue.

EnumeratorValueDescription
Identity00 on purpose: a zero-initialized field means "no activation"
Sigmoid1
Silu2
Relu3
Gelu4exact, erf-based
FastGelu5the fast approximation (binds the tanh form)
Tanh6
QuickGelu7sigmoid approximation: x·sigmoid(1.702·x)
Relu68min(max(x, 0), 6)
TanhGelu9the tanh approximation, named
SwiGlu10
GeGlu11
ReGlu12
Situ13Soft-capped gated activation; BOTH halves transform: out = β·tanh(gate/β)·sigmoid(gate) · lβ·tanh(up/lβ). The two soft-cap scalars ride ops::matmul/ops::linear as situ_beta (β, the gate cap) and situ_linear_beta (lβ, the up cap); both must be > 0 and come from the model's own config; passing Situ without them (or either scalar with any other kind) rejects. Computed at fp32 end-to-end with one demote at the store for f16/bf16 outputs.

Declared in ClikaRT/compute/op_enums.h, line 16

enum GeluMode

enum class GeluMode : std::uint8_t

GELU approximation: exact (None), Tanh (the tanh approximation), Quick (sigmoid-based), or Fast.

EnumeratorValueDescription
None0
Tanh
Quick
Fast

Declared in ClikaRT/compute/op_enums.h, line 45

enum RotaryMode

enum class RotaryMode

How a rotary embedding pairs the channels it rotates.

EnumeratorDescription
NeoXsplit-half: pair (i, i + rotary_dim/2)
Interleavedadjacent-pair: pair (2i, 2i+1)

Declared in ClikaRT/compute/op_enums.h, line 53

enum MoeRouting

enum class MoeRouting : std::uint8_t

Mixture-of-Experts routing: how the router logits select the top-k experts and produce the combine weights. Values are PINNED (ABI).

EnumeratorValueDescription
SoftmaxTopK0softmax over all experts, then top-k (Mixtral / Qwen / gemma)
TopKSoftmax1top-k of the raw logits, then softmax over the k
Sigmoid2per-expert sigmoid, then top-k
SigmoidGroupTopK3sigmoid + selection bias, group-limited (DeepSeek-V3)
SparseMixer4sparse-mixer top-2 (Phi-3.5-MoE)
PreComputed5the logits are already the probability grid

Declared in ClikaRT/compute/op_enums.h, line 60

enum SwigluFusion

enum class SwigluFusion : std::uint8_t

How the gate‖up halves are laid out in a gated MoE FC1 output. Values are PINNED (ABI).

EnumeratorValueDescription
Unfused0gate comes from a SEPARATE fc3 matrix
Interleaved1one fused [E, 2I, H]; gate = even, up = odd columns
Concat2one fused [E, 2I, H]; gate = first half, up = second

Declared in ClikaRT/compute/op_enums.h, line 71

enum RoundingMode

enum class RoundingMode : std::uint8_t

Integer-division / floor-div rounding.

EnumeratorValueDescription
None0
Trunc
Floor

Declared in ClikaRT/compute/op_enums.h, line 78

enum ModMode

enum class ModMode : std::uint8_t

mod convention: Python (sign follows divisor) or C (sign follows dividend).

EnumeratorValueDescription
Python0
C

Declared in ClikaRT/compute/op_enums.h, line 81

enum Reduction

enum class Reduction : std::uint8_t

Loss reduction over the batch.

EnumeratorValueDescription
None0
Mean
Sum

Declared in ClikaRT/compute/op_enums.h, line 84

enum PadMode

enum class PadMode : std::uint8_t

pad boundary handling. Constant fills with the given value; Reflect mirrors about the edge (edge sample not repeated); Replicate repeats the edge sample; Circular wraps around.

EnumeratorValueDescription
Constant0
Reflect
Replicate
Circular

Declared in ClikaRT/compute/op_enums.h, line 90

enum InterpMode

enum class InterpMode : std::uint8_t

Resampling mode for ops::interpolate (rank dispatch picks the spatial variant: Linear covers linear/bilinear/trilinear by input rank).

EnumeratorValueDescription
Nearest0
Linear
Bicubic
Area
NearestExact

Declared in ClikaRT/compute/op_enums.h, line 94

enum ScatterReduceMode

enum class ScatterReduceMode : std::uint8_t

scatter_reduce combine op. Sum / Prod / Mean accumulate; AMax / AMin keep the extremum.

EnumeratorValueDescription
Sum0
Prod
Mean
AMax
AMin

Declared in ClikaRT/compute/op_enums.h, line 98

enum QuantileInterp

enum class QuantileInterp : std::uint8_t

quantile interpolation between data points. Linear interpolates between the two neighbors; Lower / Higher take a neighbor; Nearest the closer one; Midpoint their mean.

EnumeratorValueDescription
Linear0
Lower
Higher
Nearest
Midpoint

Declared in ClikaRT/compute/op_enums.h, line 103

enum PixelShuffleMode

enum class PixelShuffleMode : std::uint8_t

pixel_shuffle channel ordering.

EnumeratorValueDescription
CRD0
DCR

Declared in ClikaRT/compute/op_enums.h, line 106

enum GridSampleMode

enum class GridSampleMode : std::uint8_t

grid_sample interpolation.

EnumeratorValueDescription
Bilinear0
Nearest
Bicubic

Declared in ClikaRT/compute/op_enums.h, line 109

enum GridSamplePaddingMode

enum class GridSamplePaddingMode : std::uint8_t

grid_sample out-of-bounds handling.

EnumeratorValueDescription
Zeros0
Border
Reflection

Declared in ClikaRT/compute/op_enums.h, line 112

enum MeshgridIndexing

enum class MeshgridIndexing : std::uint8_t

meshgrid output orientation: NumPy's indexing= argument. IJ (matrix indexing) keeps output shapes in the input order; XY (Cartesian) swaps the first two axes.

EnumeratorValueDescription
IJ0
XY

Declared in ClikaRT/compute/op_enums.h, line 117

enum HashTensorMode

enum class HashTensorMode : std::uint8_t

hash_tensor combine mode. XorSum xor-folds the elements' mixed hashes; order-independent, so a digest survives layout permutations.

EnumeratorValueDescription
XorSum0

Declared in ClikaRT/compute/op_enums.h, line 121

enum QComputeMode

enum class QComputeMode : std::uint8_t

How a weight-only-quantized contraction (qmatmul_woq / qlinear_woq / the *_woq conv family) contracts a floating-point activation against a quantized weight. ExactFP (the default) dequantizes the weight and runs the float dot, bit-faithful to the stored scale / zero-point. DynamicInt8 dynamically quantizes the activation to int8 and runs an integer dot, faster on dot-product hardware, at a small accuracy cost (the activation loses precision). A ROUTING HINT, not a shape contract: shapes outside a backend's fused coverage fall back to exact math.

EnumeratorValueDescription
ExactFP0
DynamicInt81

Declared in ClikaRT/compute/op_enums.h, line 131

enum RopeScaling

enum class RopeScaling

RoPE frequency-scaling family (long-context extension). Every family also folds an OPTIONAL 1-D [rotary_dim/2] freq_factors per-band divisor table into its frequencies (absent ⇒ no division); the 2-D [2, rotary_dim/2] short/long-row form belongs to the LongRoPE families alone, which REQUIRE a table in one of the two shapes.

EnumeratorDescription
Noneinv_freq = theta^(-2i/d)
Linearposition interpolation: angle uses pos / scale
NTKstatic NTK-aware base scaling
DynamicNTKNTK with a runtime sequence-length trigger.
YaRNwavelength-ramp interpolation (beta_fast/beta_slow)
Llama3Llama-3.1 piecewise inv_freq smoothing.
LongRoPEper-dim short/long factors; row + attention factor keyed on the BUILT cache length vs original_max_pos
Proportionalzero-tail: first ⌊scale·d/2⌋ bands carry real frequencies (exponent over the full d), the rest are zero (identity rotation)
LongRoPEShortLongRoPE, SHORT row pinned statically (row 0); attention factor from the config ratio (scale), never the built length.
LongRoPELongLongRoPE, LONG row pinned statically (row 1); attention factor from the config ratio (scale).

Declared in ClikaRT/compute/op_enums.h, line 138

Variables

ellipsis

EllipsisTag ellipsis {}

Declared in ClikaRT/compute/tensor.h, line 832

new_axis

NewAxisTag new_axis {}

Declared in ClikaRT/compute/tensor.h, line 835

slice_all

const IndexSlice slice_all {}

The fully-open slice (:). (all is taken by the reduction op.).

Declared in ClikaRT/compute/tensor.h, line 837

Functions

FunctionDescription
absElementwise absolute value.
abs_In-place abs: writes the result through self; same formula, arguments, and error conditions as abs(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
acosElementwise arccosine.
acos_In-place acos: writes the result through self; same formula, arguments, and error conditions as acos(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
acoshElementwise inverse hyperbolic cosine.
acosh_In-place acosh: writes the result through self; same formula, arguments, and error conditions as acosh(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
adaptive_avg_poolRank-generic adaptive average pooling to a target output size, channels-last.
adaptive_avg_pool1d1-D adaptive average pooling of [N, L, C] to [N, L', C]; the window geometry is derived from output_size. See adaptive_avg_pool.
adaptive_avg_pool2d2-D adaptive average pooling of [N, H, W, C] to [N, H', W', C]; windows derived so the output lands exactly on output_size = {H', W'}. {1, 1} is global average pooling.
adaptive_avg_pool3d3-D adaptive average pooling of [N, D, H, W, C] to [N, D', H', W', C]. See adaptive_avg_pool.
adaptive_max_poolRank-generic adaptive MAX pooling to a target output size, channels-last, the max sibling of adaptive_avg_pool.
adaptive_max_pool1d1-D adaptive max pooling of [N, L, C] to [N, L', C]. See adaptive_max_pool.
adaptive_max_pool2d2-D adaptive max pooling of [N, H, W, C] to [N, H', W', C]. {1, 1} is global max pooling. See adaptive_max_pool.
adaptive_max_pool3d3-D adaptive max pooling of [N, D, H, W, C] to [N, D', H', W', C]. See adaptive_max_pool.
add (2 overloads)Adds other (scaled) to a elementwise.
add_In-place add: writes act(x+αother)act(x + \alpha \cdot other) through x; semantics as ops::add (which also documents broadcasting/promotion). ClikaRT::Error as the value form.
add_layer_normFused residual-add + normalization, on either side of the norm. Which data flow runs is inferred from which addends you supply; there is no mode flag:residual only → {ACT(norm(x + residual)·w + b), x + residual} post_residual only → {ACT(norm(x)·w + b) + post_residual, UNDEFINED} both → {ACT(norm(x + residual)·w + b) + post_residual, x + residual} neither → raises (that is a plain rms_norm/layer_norm)
add_rms_normFused residual-add + normalization, on either side of the norm. Which data flow runs is inferred from which addends you supply; there is no mode flag:residual only → {ACT(norm(x + residual)·w + b), x + residual} post_residual only → {ACT(norm(x)·w + b) + post_residual, UNDEFINED} both → {ACT(norm(x + residual)·w + b) + post_residual, x + residual} neither → raises (that is a plain rms_norm/layer_norm)
allTrue where EVERY element over dims is nonzero (logical AND reduce).
allcloseWhether EVERY elementwise pair is approximately equal, a reduction to one verdict.
amaxMaximum value of x over dims.
aminMinimum value of x over dims.
aminmaxa 2-element array {min, max}.
anyTrue where ANY element over dims is nonzero (logical OR reduce).
arangeEvenly stepped 1-D range over the half-open interval [start, end).
argmaxIndex of the maximum of x over dims.
argminIndex of the minimum of x over dims.
argsortIndices that would sort x along dim (ascending unless descending).
asinElementwise arcsine.
asin_In-place asin: writes the result through self; same formula, arguments, and error conditions as asin(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
asinhElementwise inverse hyperbolic sine.
asinh_In-place asinh: writes the result through self; same formula, arguments, and error conditions as asinh(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
atanElementwise arctangent.
atan2Elementwise four-quadrant arc tangent of a/b (the angle of the point (b, a)), in radians. Broadcasts and promotes as add. the broadcast-shaped angles at the promoted float dtype. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
atan2_In-place atan2: writes the angles through x. ClikaRT::Error as the value form.
atan_In-place atan: writes the result through self; same formula, arguments, and error conditions as atan(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
atanhElementwise inverse hyperbolic tangent.
atanh_In-place atanh: writes the result through self; same formula, arguments, and error conditions as atanh(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
atleast_1dx with leading size-1 dims prepended until rank >= 1; a higher-rank input passes through unchanged. Returns a VIEW sharing x's storage (no copy).
atleast_2dx with leading size-1 dims prepended until rank >= 2 (see atleast_1d). Returns a view (no copy).
atleast_3dx with leading size-1 dims prepended until rank >= 3 (see atleast_1d). Returns a view (no copy).
attentionDense attention with the serving riders: per-head sink, logit soft-cap, sliding window, smoothed softmax.
attention_over_cacheAttend a KV cache WITHOUT appending to it (a read-only re-attention). q is packed varlen [ΣS_q, H, D] (or hidden-folded [ΣS_q, num_heads*D] with num_heads set); cache_key/cache_value are a cache another attention call already appended: continuous head-major [max_seqs, H_kv, max_seq, D] with a rank-1 [B] kvcache_start (the layout selector; its values are not read, and q's position derives from cu_seqlens_k), or a paged block pool [num_blocks, H_kv, block_size, D] with a rank-2 [B, max_blocks] block table. On the continuous cache slot_ids ([B] Int32, in range, pairwise distinct) names each batch row's cache row; absent, batch row b reads cache row b. cu_seqlens_k is each sequence's TOTAL cached length: per-seq [B] or cumulative [B+1]. The cache is never written. When rope_cos/rope_sin are bound, rotary applies to q only (the cached keys are already rotated). Use case: a q-only module re-attending a sibling layer's cache. head_sink is the per-head softmax sink [H_q], a virtual logit folded into the softmax denominator, the same contract as the varlen face; it rides the parameter tail here. out_attn: q's shape with the trailing dim set to the cache's value head size. The read-only face's qk-norm tail rotates and norms q ONLY; the cached keys were already rotated+normed by the call that appended them; k_norm_gain rides along untouched so one argument set serves both the appending and the read-only attention. Same travel rule: gains come WITH qk_norm_eps and require the rope planes; absent ⇒ unchanged.
attention_varlenVariable-length (packed) form of attention: the serving riders over token-packed ragged batches.
avg_poolRank-generic average pooling, channels-last.
avg_pool1d1-D average pooling over [N, L, C] (channels-last). See avg_pool; stride empty = kernel_size.
avg_pool2d2-D average pooling over [N, H, W, C] (channels-last).
avg_pool3d3-D average pooling over [N, D, H, W, C] (channels-last). See avg_pool2d; parameters extend to {kD, kH, kW} etc.
batch_normPer-channel batch normalization (inference form), channels-last.
bernoulliIndependent Bernoulli draws from per-element success probabilities.
bernoulli_In-place: overwrite self, whose values are the per-element success probabilities, with the 0/1 draws (self[i] ~ Bernoulli(self[i])).
binary_cross_entropyBinary cross-entropy on element-wise PROBABILITIES.
binary_cross_entropy_with_logitsBinary cross-entropy on RAW LOGITS (sigmoid fused, numerically stable).
bincountOccurrence count (or weight sum) of each non-negative integer value.
bitwise_andElementwise bitwise AND; the dtype law the whole bitwise family shares: integer and Bool dtypes only, and BOTH operands must carry ONE dtype (no promotion; a mixed pair is refused typed; a scalar other adopts a's dtype). Shapes broadcast per the standard rules; the output carries the shared dtype. The other bitwise ops state "dtype law as `bitwise_and`" instead of restating this. the broadcast-shaped AND at the operands' shared dtype. ClikaRT::Error (INVALID_ARGUMENT) when the operand dtypes differ, for a floating-point operand, or broadcast-incompatible shapes. auto masked = ClikaRT::ops::bitwise_and(flags, 0x0F);
bitwise_and_In-place bitwise_and: writes the AND through x. ClikaRT::Error as the value form.
bitwise_left_shiftElementwise a << other. Integer dtypes only (Bool refuses; a shifted Bool byte has no meaning); otherwise dtype law as bitwise_and. The shift is a TOTAL function: a count outside [0, bit_width), negative included, yields the fully shifted-out value (zero fill), identically on every backend. the broadcast-shaped shifted values at the shared dtype. ClikaRT::Error (INVALID_ARGUMENT) when the operand dtypes differ, for a floating-point or Bool operand, or broadcast-incompatible shapes.
bitwise_left_shift_In-place bitwise_left_shift: writes the shifted values through x. ClikaRT::Error as the value form.
bitwise_notElementwise bitwise NOT (~x; logical NOT for Bool). Integer and Bool dtypes; the output keeps x's dtype. x's shape and dtype, complemented. ClikaRT::Error (INVALID_ARGUMENT) for a floating-point operand.
bitwise_not_In-place bitwise_not: complements x in place. ClikaRT::Error as the value form.
bitwise_orElementwise bitwise OR; dtype law as bitwise_and. the broadcast-shaped OR at the operands' shared dtype. ClikaRT::Error (INVALID_ARGUMENT) when the operand dtypes differ, for a floating-point operand, or broadcast-incompatible shapes.
bitwise_or_In-place bitwise_or: writes the OR through x. ClikaRT::Error as the value form.
bitwise_right_shiftElementwise a >> other. Integer dtypes only (Bool refuses); otherwise dtype law as bitwise_and. ARITHMETIC (sign-propagating) for signed dtypes, logical for unsigned; the shift is a TOTAL function; a count outside [0, bit_width), negative included, yields the fully shifted-out value (sign fill 0/-1 for signed, 0 for unsigned), identically on every backend. the broadcast-shaped shifted values at the shared dtype. ClikaRT::Error (INVALID_ARGUMENT) when the operand dtypes differ, for a floating-point or Bool operand, or broadcast-incompatible shapes.
bitwise_right_shift_In-place bitwise_right_shift: writes the shifted values through x. ClikaRT::Error as the value form.
bitwise_xorElementwise bitwise XOR; dtype law as bitwise_and. the broadcast-shaped XOR at the operands' shared dtype. ClikaRT::Error (INVALID_ARGUMENT) when the operand dtypes differ, for a floating-point operand, or broadcast-incompatible shapes.
bitwise_xor_In-place bitwise_xor: writes the XOR through x. ClikaRT::Error as the value form.
bmmBatched matrix multiply of two rank-3 tensors, with an optional fused bias and activation epilogue.
broadcast_tensorsBroadcast every input to their common shape: dims are right-aligned, size-1 dims stretch, anything else must match.
broadcast_toAlias of expand under the NumPy name; same broadcasting rules, same view semantics.
bucketizeBucket index of each x element against a sorted 1-D boundaries.
castSame-device dtype conversion.
cast_likecast to another tensor's dtype: cast(x, reference.dtype()).
causal_conv_updateDepthwise causal short-conv serving step over a rolling per-sequence window. x [B, S, dim]; weight [dim, W] (oldest tap first); optional bias [dim]; state [B, dim, W] (same dtype as x) is read AND updated IN PLACE in both modes: S > 1 runs the prefill conv with each row's left context seeded from its window (a zero window is a fresh sequence, bit for bit; an S-token call over committed state equals S single-token steps exactly) and re-captures the window as the last W of (old window ++ the row's valid inputs; zero valid tokens leave it unchanged); S == 1 shift-inserts the new token and emits the tap dot. seq_lens ([B] Int32) bounds ragged prefill rows (their padding is zero post-activation). activation applies to the returned out [B, S, dim] only (Silu fuses in-kernel); the stored window stays pre-activation raw. slot_ids ([B] Int32, device-resident) addresses state as a SLAB [num_slots, dim, W]: batch row b reads/updates slab row slot_ids[b] in place (ids in range and DISTINCT per call, the caller's contract); absent keeps state row b.
cdistPairwise L_p distance between every ROW pair of two matrices.
ceilElementwise ceiling: the smallest integer not below x.
ceil_In-place ceil: writes the result through self; same formula, arguments, and error conditions as ceil(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
celuContinuously differentiable exponential linear unit.
celu_In-place celu: writes the result through self; same formula, arguments, and error conditions as celu(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
chunkSplit along dim into num_chunks near-equal parts (the last may be shorter). Returns VIEWS sharing the source's storage (one call, no copy); prefer it over repeated narrows.
circular_padpad in wrap-around mode: the padding continues from the opposite edge. Same (lo, hi) pair layout as constant_pad. Copies.
clampClamp x into [min, max]; an empty bound leaves that side unbounded.
clamp_In-place clamp: writes the result through self; same formula, arguments, and error conditions as clamp(). Either bound may be absent (std::nullopt), a one-sided clamp; tensor bounds broadcast against self. A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
clamp_maxElementwise upper bound.
clamp_max_In-place clamp_max: writes the result through self; same formula, arguments, and error conditions as clamp_max(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
clamp_minElementwise lower bound.
clamp_min_In-place clamp_min: writes the result through self; same formula, arguments, and error conditions as clamp_min(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
cloneDeep copy on the same device: fresh storage, identical shape, dtype, and values. Equivalent to copy(src) with the defaults.
concatJoin tensors along an EXISTING dim: all inputs share rank and off-dim extents; the dim extents add up. Copies into fresh storage.
constant_padpad with a constant fill.
contiguousPacks the tensor into row-major contiguous storage.
convConvolution family, channels-last ([N, spatial..., C]), weights output-channel-first ([O, spatial..., Ig]). stride / dilation / output_padding are PER-AXIS window attributes everywhere: length 0 (defaulted), 1 (broadcast), or spatial-rank. padding carries TWO conventions; read the one that matches the op:conv / conv_transpose*: interleaved (lo, hi) PAIRS in axis order (even length; pair i pads spatial axis i); asymmetric pads spell directly, e.g. 1-D {2, 3} = lo 2, hi 3. conv1d/2d/3d: SYMMETRIC per-axis widths (length 0/1/spatial-rank), e.g. 1-D {2} = lo 2, hi 2; an asymmetric pad needs conv or an explicit ops::pad first. The inline defaults below encode the split: conv1d pads {0}, conv_transpose1d pads {0, 0}.
conv1d1-D convolution over a channels-last input.
conv2d2-D convolution over a channels-last input.
conv3d3-D convolution over a channels-last input.
conv_transposeRank-polymorphic (1-D/2-D/3-D) transposed (fractionally-strided) convolution (learnable upsampling).
conv_transpose1d1-D transposed (fractionally-strided) convolution (learnable upsampling).
conv_transpose2d2-D transposed (fractionally-strided) convolution (learnable upsampling).
conv_transpose3d3-D transposed (fractionally-strided) convolution (learnable upsampling).
copyCopies a tensor, optionally to another device or stream.
copy_Copies src INTO self's existing storage, converting per element to self's dtype in the same single pass (never cast first; the copy IS the cast). Shapes must match after broadcasting src. Raises ClikaRT::Error where the shapes/dtypes cannot be served; returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
copy_intoWrite src into the caller-supplied out buffer (the destination-first spelling of the in-place copy; bind a persistent buffer once, write it every step with no allocation). Dtype conversion is interleaved with the write; a cross-device src is transferred first. Returns out.
copy_to_cpuMaterializes a host-resident copy of the tensor (device-to-host transfer; an owning CPU tensor even when src is already on the CPU).
copysignElementwise `
copysign_In-place copysign: writes the re-signed magnitudes through x. ClikaRT::Error as the value form.
cosElementwise cosine.
cos_In-place cos: writes the result through self; same formula, arguments, and error conditions as cos(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
coshElementwise hyperbolic cosine.
cosh_In-place cosh: writes the result through self; same formula, arguments, and error conditions as cosh(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
cosine_similarityCosine similarity along dim.
count_nonzeroNumber of nonzero elements over dims.
cross3-vector cross product along dim.
cross_entropyCross-entropy loss over class LOGITS; the class dim is LAST.
cummaxa 2-element array {values, indices}.
cummina 2-element array {values, indices}.
cumprodCumulative product along dim (inclusive scan).
cumprod_In-place cumprod: rewrites self with its inclusive prefix products along dim and returns it under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling. ClikaRT::Error as cumprod.
cumsumCumulative sum along dim (inclusive scan).
cumsum_In-place cumsum: rewrites self with its inclusive prefix sums along dim and returns it under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling. ClikaRT::Error as cumsum.
deform_convDeformable convolution, 1-D/2-D/3-D (rank derives from x), channels-last: x [N, D1..Dr, C], weight [O, K1..Kr, C/groups] (OHWI), offset [N, out-spatial..., offset_groups·∏K·r], mask [N, out-spatial..., offset_groups·∏K] (absent ⇒ unmodulated), bias [O]; returns [N, out-spatial..., O] at x's dtype. Each kernel tap samples at out·stride − pad_lo + tap·dilation + Δ (pixel units, bilinear; out-of-bounds reads 0); the offset channel for (group g, tap t, axis d) is (g·∏K + t)·r + d with taps row-major over the kernel and axes in layout order (2-D: Δh then Δw). padding is interleaved (lo, hi) pairs over the spatial axes; stride/dilation broadcast per spatial axis (empty ⇒ 1). All floating inputs must share x's dtype (f32/f64/f16/bf16; no silent promotion); activation is a fused elementwise epilogue applied after bias.
deg2radConverts degrees to radians elementwise: xπ/180x \cdot \pi / 180. x's shape at its (float-promoted) dtype. ClikaRT::Error (INVALID_ARGUMENT) for an unsupported dtype.
deg2rad_In-place deg2rad: writes the radians through x. ClikaRT::Error as the value form.
dequantize
dequantize_
diagRank-1 <-> rank-2 diagonal converter.
diag_embedEmbed the LAST dim along the diagonal of a fresh (dim1, dim2) plane: output rank = input rank + 1, both new dims sized `last +
diagonalExtract the offset-th diagonal between dim1 and dim2: the two source dims are removed and a trailing dim of the diagonal's length is appended (rank - 1 total). Copies into fresh storage (deliberately not a view).
diffn-th order finite difference along dim.
div (2 overloads)Divides a by other elementwise, with an optional quotient rounding.
div_In-place div: writes the (optionally rounded) quotient through x. ClikaRT::Error as the value form.
dotInner product of two 1-D tensors.
dynamic_quantize
einsumEinstein-summation contraction from a notation string.
eluExponential linear unit.
elu_In-place elu: writes the result through self; same formula, arguments, and error conditions as elu(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
embeddingEmbedding lookup: gathers rows of weight by indices, with an optional bias + activation epilogue.
emptyUninitialized tensor of the given shape; the contents are whatever the allocator hands back; write every element before reading any.
empty_likeUninitialized tensor with reference's shape and dtype.
empty_stridedUninitialized tensor with caller-chosen sizes AND strides (element units).
eqElementwise equality a == other, the output contract the whole comparison family shares: the result is a Bool tensor at the broadcast shape (operands promote to their dominant dtype before the compare). A scalar other compares against every element. The other comparisons state "output as `eq`" instead of restating this. the broadcast-shaped Bool mask. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible. auto hits = ClikaRT::ops::eq(ids, pad_id); // Bool mask
eq_In-place eq: writes the comparison result through x (x keeps its own dtype; true/false land as one/zero). ClikaRT::Error as the value form.
erfElementwise Gauss error function.
erf_In-place erf: writes the result through self; same formula, arguments, and error conditions as erf(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
erfcElementwise complementary error function.
erfc_In-place erfc: writes the result through self; same formula, arguments, and error conditions as erfc(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
erfinvElementwise inverse error function.
erfinv_In-place erfinv: writes the result through self; same formula, arguments, and error conditions as erfinv(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
expElementwise natural exponential.
exp_In-place exp: writes the result through self; same formula, arguments, and error conditions as exp(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
expandBroadcast x to a larger shape WITHOUT copying.
expand_asexpand to other's shape; other supplies extents only; its data is never read. Same broadcasting rules and view semantics as expand.
exponential_In-place exponential fill with rate lambd: overwrites self with draws from p(x) = lambd * exp(-lambd * x) (x >= 0) and returns it under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
eyeA 2-D identity matrix [n, m]: 1 on the diagonal, 0 elsewhere; m defaults to n (square).
fast_geluFastGELU: the tanh GELU approximation as a standalone op.
fillA new tensor with x's shape and dtype, every element set to value.
fill_In-place fill: overwrites every element of self with value; same arguments and error conditions as fill(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
fill_diagonalA copy of the 2-D matrix x with fill_value written along its diagonal.
fill_diagonal_In-place fill_diagonal: writes the diagonal through self; same arguments and error conditions as fill_diagonal(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
flattenCollapse the INCLUSIVE dim range [start_dim, end_dim] into one dim; the defaults collapse everything to 1-D.
flipReverse the element order along each dim in dims.
fliplrflip on dim 1: reverse each row's column order. Input rank must be >= 2. Copies.
flipudflip on dim 0: reverse the leading dim's order. Copies.
floorElementwise floor: the largest integer not above x.
floor_In-place floor: writes the result through self; same formula, arguments, and error conditions as floor(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
floor_divideElementwise floor(a / other), i.e. ops::div with RoundingMode::Floor. Broadcasts and promotes as add. the broadcast-shaped floored quotient. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
floor_divide_In-place floor_divide: writes the floored quotient through x. ClikaRT::Error as the value form.
fmaxElementwise IEEE 754 maximum, NaN-IGNORING: where one operand is NaN the other value wins (both NaN gives NaN). For the NaN-propagating law use ops::maximum. Broadcasts and promotes as add. the broadcast-shaped maxima. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
fminElementwise IEEE 754 minimum, NaN-IGNORING (the fmax dual). Broadcasts and promotes as add. the broadcast-shaped minima. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
fmodElementwise remainder with the sign of the DIVIDEND, i.e. ops::mod with ModMode::C. Broadcasts and promotes as add. the broadcast-shaped remainders. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
fmod_In-place fmod: writes the remainders through x. ClikaRT::Error as the value form.
foldcol2im: the inverse of unfold; it sums overlapping windows back into a channels-last image.
fracElementwise fractional part.
frac_In-place frac: writes the result through self; same formula, arguments, and error conditions as frac(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
frexpDecomposes each element into mantissa * 2^exponent with `
from_blobWrap caller-owned memory as a Tensor (no copy, no allocation).
fullA new tensor of the given shape with every element set to fill_value.
full_likeA new tensor with reference's shape and dtype, filled with fill_value.
gated_delta_updateGated delta-rule recurrence step: per token, the [B, HV, K, V] Float32 state decays by exp(g), takes the delta-rule rank-1 update (beta·k) ⊗ (v − Sᵀk), and emits o = (scale·q)ᵀ S, updated IN PLACE. The gate's RANK picks the family: [B, T, HV] = one scalar per value head; [B, T, HV, K] = per key dim. q/k [B, T, H, K] (HV % H == 0, grouped heads), v [B, T, HV, V], beta [B, T, HV]; scale defaults to K^-1/2; seq_lens ([B] Int32) bounds ragged prefill rows. slot_ids ([B] Int32, device-resident) addresses state as a SLAB [num_slots, HV, K, V]: batch row b reads/updates slab row slot_ids[b] in place (ids in range and DISTINCT per call, the caller's contract); absent keeps state row b. TWO gate forms, told apart by which inputs are bound: with gate_bias and gate_scale absent, g IS the log-space decay (Float32 or the activations' dtype); with both bound (Float32 gate_bias [HV] beside a [B, T, HV] gate or [HV, K] beside a [B, T, HV, K] one, the checkpoint's dt_bias; Float32 gate_scale [HV], the once-folded -exp(A_log)), g is the RAW gate projection slice at the activations' dtype and the kernel forms the decay gate_scale * softplus(g + gate_bias) in fp32 registers, so no add / softplus / mul pass and no fp32 transient precede the call. One without the other rejects; a backend without the raw-gate arm declines it typed.
gated_rms_normFused group RMS norm + post-norm silu(z) gate: out = rms_norm(x) · silu(z), the norm taken over the trailing normalized_shape group extent ({vd} for a per-head norm over [.., HV, vd]). weight is the optional [group] gamma applied after the normalization; an absent eps takes the runtime's rms-norm default.
gatherAxis-wise gather: read x at positions given by index along dim.
geElementwise a >= other; output as eq. the broadcast-shaped Bool mask. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
ge_In-place ge: writes the result through x (one/zero at x's dtype). ClikaRT::Error as the value form.
gegluGeGLU gated activation over a concatenated gate‖up tensor.
geluGaussian error linear unit.
gelu_In-place gelu: writes the result through self; same formula, arguments, and error conditions as gelu(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
generate_rotary_cachea 2-element array {values, indices}.
gluGated linear unit: splits x in half along dim and gates the first half with the sigmoid of the second.
grid_sampleSamples a channels-last input at arbitrary grid coordinates.
group_normGroup normalization: channels split into num_groups groups, normalized per group (channels-last).
group_query_attentionFused GQA with RoPE + KV cache. Bind out_present_key/out_present_value to the same buffers as past_key/past_value (a KVCache::keys/values(layer) view) + pass kvcache_start to append the new post-RoPE K/V IN PLACE into the cache (the decode perf path). q/k/v are hidden-folded [ΣS, heads*head_dim]; num_heads/kv_num_heads drive the in-op head split (GQA). head_sink is the per-head softmax sink [H_q], a virtual logit folded into the softmax denominator (attention-sink models bind one per layer), the same contract as the varlen face; it rides the parameter tail here. q_norm_gain/k_norm_gain engage the POST-rope per-head RMS norm: after the in-op rotation, every head's [head_dim] q (and new-k) vector is RMS-normalized with the gain BEFORE any cache append, so the cache holds rotated+normed keys. Each gain is rank-1 [head_dim] (one vector shared across heads; any other shape rejects), any float dtype, applied at its own dtype. The gains require the in-op rope planes (rope_cos/rope_sin), and they travel WITH qk_norm_eps: pass the model's own rms-norm epsilon alongside the gains, or neither (a gain without the epsilon, or an epsilon with no gain, rejects). Absent ⇒ the gain-less path, unchanged. A rope-free per-head norm composes qk_rms_norm instead. slot_ids ([B] Int32) names the cache row each batch row appends to and attends from on a continuous [max_seqs, H_kv, max_seq, D] cache: a sequence keeps its row while the batch composition changes around it. Absent, batch row b uses cache row b. Every entry must lie in [0, max_seqs) and no two rows may share one (each rejects). On that cache kvcache_start stays the rank-1 [B] layout selector whose values are not read: each row's write offset is cu_seqlens_k[b] - q_len[b]. A paged block table and the dense in-place form take no slot_ids (the block table is its own row map; the dense form addresses rows by batch index). {out_attn, present_key, present_value}.
group_query_attention_varlenThe varlen face of the fused GQA above, with the same qk-norm tail: q_norm_gain/k_norm_gain (rank-1 [head_dim], post-rope, applied before the K/V append) travel with qk_norm_eps (the model's rms-norm epsilon) and require the in-op rope planes; absent ⇒ unchanged. The same slot_ids contract: on a continuous cache it names each batch row's cache row ([B] Int32, in range, pairwise distinct; absent = row b for batch row b), and kvcache_start's values stay unread there (the write offsets derive from cu_seqlens_k).
gtElementwise a > other; output as eq. the broadcast-shaped Bool mask. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
gt_In-place gt: writes the result through x (one/zero at x's dtype). ClikaRT::Error as the value form.
hardshrinkHard shrinkage: zeroes every element within [-lambd, lambd].
hardshrink_In-place hardshrink: writes the result through self; same formula, arguments, and error conditions as hardshrink(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
hardsigmoidPiecewise-linear sigmoid approximation.
hardsigmoid_In-place hardsigmoid: writes the result through self; same formula, arguments, and error conditions as hardsigmoid(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
hardswishPiecewise-linear swish approximation (the MobileNet-v3 form).
hardswish_In-place hardswish: writes the result through self; same formula, arguments, and error conditions as hardswish(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
hardtanhClamps every element to [min_val, max_val].
hardtanh_In-place hardtanh: writes the result through self; same formula, arguments, and error conditions as hardtanh(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
hash_128128-bit sibling of hash_64; same byte/portability contract. [2] UInt64 (little-endian limb order). ClikaRT::Error when the input's dtype is not served for this operation (the machine-readable reason rides code_name()).
hash_256256-bit sibling of hash_64; same byte/portability contract. [4] UInt64 (little-endian limb order). ClikaRT::Error when the input's dtype is not served for this operation (the machine-readable reason rides code_name()).
hash_6464-bit content hash of x's packed bytes (row-major logical order; strided inputs are materialized internally). A frozen function of (seed, bytes): identical on every platform, backend, and ISA tier, so digests are safe to persist and compare across devices. seed perturbs the key; 0 selects the runtime's fixed content-addressing key.
hash_chainRowwise 128-bit CHAINED hash: for rows [N, ..] and a [2] UInt64 parent (zeros = the chain's zero element), row i's digest hashes (digest i-1 ‖ row i's packed bytes); one dispatch computes a whole sequence's rolling content hashes. Same portability contract as hash_64.
hash_tensorBitwise hash-reduction over dims (empty = all): each element's bits are mixed and combined per mode into a UInt64 digest, standard reduction shape. Order-independent under HashTensorMode::XorSum, and identical on every backend, a cheap whole-tensor fingerprint for parity checks and cache keys.
histograma 2-element array {values, indices}.
huber_lossHuber loss: quadratic near zero, linear past the delta knee.
hypotElementwise hypotenuse a2+b2\sqrt{a^2 + b^2}. Broadcasts and promotes as add. the broadcast-shaped result at the promoted float dtype. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
hypot_In-place hypot: writes the hypotenuses through x. ClikaRT::Error as the value form.
indexAdvanced indexing over the standard entry vocabulary (int / bool / integer-or-boolean Tensor / IndexSlice / ellipsis / new_axis): index(t, {1, slice_all, idx})t[1, :, idx].
index_addA copy of x with rows of src ACCUMULATED at indices along dim: out[.., indices[i], ..] += src[.., i, ..]; duplicate indices add up.
index_add_In-place index_add: self[.., indices[i], ..] += src[.., i, ..]; same arguments and error conditions as index_add(). Accumulates through self's storage (a strided view reaches its base buffer; aliases observe the write). Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
index_copyA copy of x with rows of src WRITTEN at indices along dim: out[.., indices[i], ..] = src[.., i, ..]. Prefer unique indices; a duplicated position is written more than once.
index_copy_In-place index_copy: self[.., indices[i], ..] = src[.., i, ..]; same arguments and error conditions as index_copy(). Writes through self's storage (a strided view, e.g. a cache slice, reaches its base buffer; aliases observe the write). Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
index_fillA copy of x with the rows at indices along dim set to value: out[.., indices[i], ..] = value.
index_fill_In-place index_fill: self[.., indices[i], ..] = value; same arguments and error conditions as index_fill(). Fills through self's storage (a strided view reaches its base buffer; aliases observe the write). Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
index_putA copy of x with value written (or accumulated) at the indexed positions, the out-of-place x[indices] = value.
index_put_In-place self[indices] = value (or += with accumulate); returns the mutated self so it chains.
index_selectSelect whole rows of x at index positions along dim.
innerLast-axis contraction of two tensors.
instance_normInstance normalization: statistics per (sample, channel) over the spatial dims (channels-last).
interpolateResample the spatial dims to sizes OR by scale_factors (exactly one given; entries may be int literals or 0-D Tensors, so a dynamic output size flows without a host read). Rank picks the spatial variant.
iscloseElementwise approximate equality, the elementwise map behind ops::allclose, same formula and defaults (rtol 1e-5, atol 1e-8, equal_nan false). the broadcast-shaped Bool mask. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
isfiniteElementwise finiteness test (neither infinite nor NaN); output as eq. Integer inputs are finite everywhere. x-shaped Bool mask. ClikaRT::Error (INVALID_ARGUMENT) for an unsupported dtype.
isinfElementwise infinity test (either sign); output as eq. x-shaped Bool mask. ClikaRT::Error (INVALID_ARGUMENT) for an unsupported dtype.
isnanElementwise NaN test; output as eq. x-shaped Bool mask. ClikaRT::Error (INVALID_ARGUMENT) for an unsupported dtype.
isneginfElementwise -inf test; output as eq. x-shaped Bool mask. ClikaRT::Error (INVALID_ARGUMENT) for an unsupported dtype.
isposinfElementwise +inf test; output as eq. x-shaped Bool mask. ClikaRT::Error (INVALID_ARGUMENT) for an unsupported dtype.
kl_divKullback–Leibler divergence loss.
kronKronecker product of two same-rank tensors.
kthvaluea 2-element array {values, indices}.
l1_lossMean-absolute-error loss between input and target.
layer_normLayer normalization over the trailing normalized_shape dims of x.
leElementwise a <= other; output as eq. the broadcast-shaped Bool mask. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
le_In-place le: writes the result through x (one/zero at x's dtype). ClikaRT::Error as the value form.
leaky_reluReLU with a small slope on the negative side.
leaky_relu_In-place leaky_relu: writes the result through self; same formula, arguments, and error conditions as leaky_relu(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
linearx @ weightᵀ (+ bias); weight in the [out, in] Linear layout. Same situ contract as matmul: Activation::Situ transforms both halves of the gate‖up projection under the two soft-caps (situ_beta = β, situ_linear_beta = lβ, both > 0, from the model's config); either scalar with any other activation rejects.
linspacesteps evenly spaced values from start to end, ENDPOINTS INCLUDED.
logElementwise natural logarithm.
log10Elementwise base-10 logarithm.
log10_In-place log10: writes the result through self; same formula, arguments, and error conditions as log10(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
log1pElementwise log(1 + x), accurate for small x.
log1p_In-place log1p: writes the result through self; same formula, arguments, and error conditions as log1p(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
log2Elementwise base-2 logarithm.
log2_In-place log2: writes the result through self; same formula, arguments, and error conditions as log2(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
log_In-place log: writes the result through self; same formula, arguments, and error conditions as log(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
log_sigmoidLogarithm of the sigmoid, computed stably.
log_sigmoid_In-place log_sigmoid: writes the result through self; same formula, arguments, and error conditions as log_sigmoid(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
log_softmaxLogarithm of the softmax along dim, computed stably (never log(softmax(x)) in two passes).
log_softmax_In-place log_softmax: writes the result through self; same formula, arguments, and error conditions as log_softmax(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
logaddexpElementwise log(ea+eb)\log(e^a + e^b), computed overflow-safely (the log-domain accumulation primitive). Broadcasts and promotes as add. the broadcast-shaped result at the promoted float dtype. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
logaddexp2Elementwise log2(2a+2b)\log_2(2^a + 2^b), logaddexp in base 2. Broadcasts and promotes as add. the broadcast-shaped result at the promoted float dtype. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
logical_andElementwise logical AND; non-Bool inputs read as element != 0 before the logic, and the output is always Bool (output as eq). the broadcast-shaped Bool mask. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
logical_and_In-place logical_and: writes the result through x (one/zero at x's dtype). ClikaRT::Error as the value form.
logical_notElementwise logical NOT (element == 0); output as eq. x-shaped Bool mask. ClikaRT::Error (INVALID_ARGUMENT) for an unsupported dtype.
logical_not_In-place logical_not: writes the result through x (one/zero at x's dtype). ClikaRT::Error as the value form.
logical_orElementwise logical OR (non-Bool inputs read as != 0); output as eq. the broadcast-shaped Bool mask. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
logical_or_In-place logical_or: writes the result through x (one/zero at x's dtype). ClikaRT::Error as the value form.
logical_xorElementwise logical XOR (non-Bool inputs read as != 0); output as eq. the broadcast-shaped Bool mask. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
logical_xor_In-place logical_xor: writes the result through x (one/zero at x's dtype). ClikaRT::Error as the value form.
logitElementwise log-odds.
logit_In-place logit: writes the result through self; same formula, arguments, and error conditions as logit(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
logsumexpNumerically stable log(sum(exp(x))) over dims.
ltElementwise a < other; output as eq. the broadcast-shaped Bool mask. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
lt_In-place lt: writes the result through x (one/zero at x's dtype). ClikaRT::Error as the value form.
masked_fillReplace the elements of x where mask is true with value.
masked_fill_In-place masked_fill: writes value through self where mask is true; same arguments and error conditions as masked_fill(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
masked_scatterA copy of x with the leading count(mask) elements of src (read row-major) written at the positions where mask is true.
masked_scatter_In-place masked_scatter: writes src's leading elements through self where mask is true; same arguments and error conditions as masked_scatter(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
masked_selectThe elements of x where mask is true, as a 1-D tensor.
matmula @ b (+ bias) with an optional fused activation epilogue. A gated activation (SwiGlu/GeGlu/ReGlu/Situ) takes the product as a concatenated [*, 2d] gate‖up projection and emits [*, d] in one pass. situ_beta/situ_linear_beta are Activation::Situ's two soft-cap scalars (β and lβ in β·tanh(gate/β)·sigmoid(gate) · lβ·tanh(up/lβ)); pass the model's own config values. Situ requires BOTH > 0, and either scalar with any other activation rejects (it would otherwise be silently ignored). The transform computes at fp32 end-to-end with one demote at the store for f16/bf16 outputs.
maxa 2-element array {values, indices}.
max_poolRank-generic max pooling, channels-last.
max_pool1d1-D max pooling over [N, L, C] (channels-last). See max_pool for the window semantics; stride empty = kernel_size.
max_pool1d_with_indicesa 2-element array {values, indices}.
max_pool2d2-D max pooling over [N, H, W, C] (channels-last).
max_pool2d_with_indicesa 2-element array {values, indices}.
max_pool3d3-D max pooling over [N, D, H, W, C] (channels-last). See max_pool2d; parameters extend to {kD, kH, kW} etc.
max_pool3d_with_indicesa 2-element array {values, indices}.
max_pool_with_indicesa 2-element array {values, indices}.
maximumElementwise maximum, NaN-PROPAGATING: a NaN in either operand yields NaN (use ops::fmax for the NaN-ignoring IEEE law). Broadcasts and promotes as add. the broadcast-shaped maxima. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
maximum_In-place maximum: writes the elementwise maxima through x. ClikaRT::Error as the value form.
meanArithmetic mean of x over dims.
mediana 2-element array {values, indices}.
meshgridCoordinate grids from 1-D axes: N inputs produce N N-D tensors, each input broadcast over every other axis, the NumPy meshgrid.
mina 2-element array {values, indices}.
minimumElementwise minimum, NaN-PROPAGATING (the maximum dual; use ops::fmin for NaN-ignoring). Broadcasts and promotes as add. the broadcast-shaped minima. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
minimum_In-place minimum: writes the elementwise minima through x. ClikaRT::Error as the value form.
mishMish activation.
mish_In-place mish: writes the result through self; same formula, arguments, and error conditions as mish(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
mla_attentionMulti-head Latent Attention over a compressed KV cache, latent-space end to end: q_nope [ΣS, H, Dl] (W_UK-absorbed) + q_pe [ΣS, H, Dr] score against the per-token compressed rows; the caches ([max_seqs, max_seq, Dl/Dr]) take this step's new_ckv/new_kpe appends IN PLACE (write offsets = kvcache_start [B] Int32; cu_seqlens_q [B+1] locates each sequence's packed tokens); the returned [ΣS, H, Dl] output stays latent (apply the W_UV un-absorption after). scale is REQUIRED; the absorbed query's magnitude lives in the model's un-absorbed head dim.
mmMatrix multiply of two rank-2 tensors, with an optional fused bias and activation epilogue.
modElementwise modulo with a selectable sign convention.
mod_In-place mod: writes the remainders through x. ClikaRT::Error as the value form.
moeFused Mixture-of-Experts layer: route, run the top-k experts, combine in one call, with no per-expert dispatch from the caller.
mrope_rotary_embeddingMulti-section rotary position embedding over padded layouts.
mrope_rotary_embedding_qk_varlenMulti-axis RoPE over a packed q/k pair: ONE per-token angle table serves both projections in a single call, the media-prefill pre-rotation shape. q/k are head-exposed [n_tokens, heads, head_dim] (a flat [n_tokens, heads·head_dim] projection reshapes to it as a free view; the rotation spans the TRAILING dim, so a flat row would rotate across head boundaries); position_ids is [n_axes, n_tokens] with n_axes == mrope_sections.size() (strip any trailing zero sections a checkpoint's metadata pads; the axis count follows the section list); rotary_dim bounds the rotated span (dims beyond it pass through) and defaults to the trailing dim. Rows whose per-axis positions are all EQUAL rotate exactly as the plain ops do; serve pure-text calls through rotary_embedding* (cheaper: no per-token table), and use this form for packs whose rows carry genuinely multi-axis positions, then attend with the rope inputs ABSENT so the attention op consumes (and appends) q/k exactly as given. a 2-element array {q, k}.
mrope_rotary_embedding_varlenMulti-section rotary position embedding over token-packed layouts (cu_seqlens [B+1] Int32, as in rotary_embedding_varlen).
ms_deform_attentionMulti-scale deformable attention (2-D): per query and head, gather P bilinear samples from each of L flattened feature-map levels and combine them with the given weights. value [N, S, M, D] with S = Σ_l H_l·W_l; spatial_shapes [L, 2] = per-level (H_l, W_l) and level_start_index [L] (both Int32 or Int64); sampling_locations [N, Lq, M, L, P, 2]; last dim (x, y), normalized to [0, 1] per level, sampled at loc·size − 0.5 (bilinear; out-of-bounds reads 0); attention_weights [N, Lq, M, L, P] are consumed AS GIVEN (apply softmax beforehand if wanted). Returns [N, Lq, M, D] at value's dtype; accumulation is fp32. The float inputs must share value's dtype (f32/f64/f16/bf16; no silent promotion).
mse_lossMean-squared-error loss between input and target.
mul (2 overloads)Multiplies a by other elementwise.
mul_In-place mul: writes act(xother)act(x \cdot other) through x. ClikaRT::Error as the value form.
multinomialCategorical sampling: draws num_samples category indices per row of a weight tensor.
mvMatrix-vector multiply, with an optional fused bias and activation.
nan_to_numReplaces NaN and infinities with finite values.
nan_to_num_In-place nan_to_num: writes the result through self; same formula, arguments, and error conditions as nan_to_num(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
nanmeanMean over dims, treating NaN entries as missing.
nanmediana 2-element array {values, indices}.
nanquantilequantile that treats NaN entries as missing; each slice's quantile is computed over its non-NaN values (an all-NaN slice yields NaN). Parameters and shapes as quantile.
nansumSum over dims, treating NaN entries as missing (contributing zero).
narrowlength elements from start along dim. Both are int literals or 0-D integer Tensors (a tensor-valued window never syncs to the host).
ndimThe tensor's rank as a 0-D Int64 tensor.
ndim_hostThe rank as a 0-D Int64 HOST tensor, written from metadata; the same no-sync contract as shape_host.
neElementwise a != other; output as eq. the broadcast-shaped Bool mask. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
ne_In-place ne: writes the result through x (one/zero at x's dtype). ClikaRT::Error as the value form.
negElementwise negation.
neg_In-place neg: writes the result through self; same formula, arguments, and error conditions as neg(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
nll_lossNegative-log-likelihood loss over LOG-probabilities; class dim LAST.
nmsBatched, class-aware non-max suppression (argument order mirrors the ONNX operator). boxes is [batch, num_boxes, 4]; scores is [batch, classes, num_boxes]; returns the selected indices as an Int64 [num_selected, 3] of (batch, class, box) rows. Every threshold takes a literal OR a 0-D tensor (a tensor traces symbolically). An absent max_output_boxes_per_class selects NOTHING (the reference default); a negative cap clamps to 0. A literal iou_threshold outside [0, 1] raises. center_point_box picks the [cx, cy, w, h] box encoding over the corners form.
nonzeroCoordinates of the nonzero elements: an [n, ndim] Int64 matrix, one row per nonzero element of x.
normThe p-norm of x over dims.
normalNormal draws with the given mean and standard deviation.
normal_In-place normal fill: overwrites self with N(mean, stddev^2) draws at self's shape/dtype and returns it under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling. ClikaRT::Error as normal.
normalizeL_p-normalizes x along dim: each slice is scaled to unit p-norm.
normalize_In-place normalize: rewrites self with its L_p-normalized value and returns it under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling. ClikaRT::Error as normalize.
numelThe tensor's total element count as a 0-D Int64 tensor.
numel_hostThe element count as a 0-D Int64 HOST tensor, written from metadata; the same no-sync contract as shape_host. Composes with shape-consuming arguments, e.g. reshape(x, {numel_host(x)}) flattens without reading sizes to the host.
one_hotExpands an integer index tensor into a trailing one-hot dimension.
onesA new tensor of the given shape with every element set to one.
ones_likeA one-filled tensor with reference's shape and dtype (data never read); s absent = the reference's own device.
outerOuter product of two 1-D tensors: [m] x [n] -> [m, n].
padPad each axis by interleaved (lo, hi) pairs in layout order, left-to-right: pair i pads axis i (the first pair is the leading axis). Provide fewer pairs than the rank to pad only the leading axes; a negative width crops that side. mode selects the fill; value is the Constant fill (default 0).
pairwise_distanceRow-wise L_p distance between two batched vectors.
pdistCondensed pairwise L_p distances within ONE 2-D input.
permuteReorder the dims by dims, a permutation of [0, rank).
pixel_shuffleRearranges channels into space (depth-to-space): channels-last [N, H, W, C] becomes [N, H*r, W*r, C/r^2].
pixel_unshuffleThe inverse of pixel_shuffle (space-to-depth): channels-last [N, H, W, C] becomes [N, H/r, W/r, C*r^2].
poissonIndependent Poisson draws from per-element rates.
powRaises a to exponent elementwise: aexponenta^{exponent}. Broadcasts and promotes as add; a scalar exponent keeps its weak kind (an integer exponent with an integer base stays integral). the broadcast-shaped powers at the promoted dtype. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
pow_In-place pow: writes the powers through x. ClikaRT::Error as the value form.
preluParametric ReLU: a learned negative-side slope.
prelu_In-place prelu: writes the result through self; same formula, arguments, and error conditions as prelu(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
prodProduct of x's elements over dims.
putA copy of x with source written at FLAT (row-major linearized) positions: out.flat[index[i]] = source.flat[i].
put_In-place put: writes (or accumulates) through self at flat positions; same arguments and error conditions as put(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
q_embedding
qadd (2 overloads)
qadd_ (3 overloads)
qconcat (2 overloads)
qconcat_ (2 overloads)
qconv (2 overloads)
qconv1d (2 overloads)
qconv1d_woq
qconv2d (2 overloads)
qconv2d_woq
qconv3d (2 overloads)
qconv3d_woq
qconv_ (3 overloads)
qconv_transpose (2 overloads)
qconv_transpose1d (2 overloads)
qconv_transpose1d_woq
qconv_transpose2d (2 overloads)
qconv_transpose2d_woq
qconv_transpose3d (2 overloads)
qconv_transpose3d_woq
qconv_transpose_ (3 overloads)
qconv_transpose_woq
qconv_woq
qdeform_conv (2 overloads)
qdeform_conv_woq
qdiv (2 overloads)
qdiv_ (3 overloads)
qfast_gelu (2 overloads)
qfast_gelu_ (3 overloads)
qgelu (2 overloads)
qgelu_ (3 overloads)
qhardswish (2 overloads)
qhardswish_ (3 overloads)
qk_layer_normPer-head LAYER norm over packed attention projections, the mean-subtracting sibling of qk_rms_norm.
qk_layer_norm_In-place qk_layer_norm: normalizes q (and k, when present) through their own storage (no output allocation); v is untouched. Same arguments and error conditions as qk_layer_norm(). Tensors are shared-storage handles, so the caller's operands see the writes. Returns q under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
qk_rms_normPer-head RMS norm over packed attention projections: q, k and v in ONE call, no reshapes.
qk_rms_norm_In-place qk_rms_norm: normalizes q (and k, when present) through their own storage (no output allocation); v is untouched. Same arguments and error conditions as qk_rms_norm(). Tensors are shared-storage handles, so the caller's operands see the writes. Returns q under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
qleaky_relu (2 overloads)
qleaky_relu_ (3 overloads)
qlinear (2 overloads)
qlinear_ (2 overloads)
qlinear_woq
qlinear_woq_
qmatmul (2 overloads)
qmatmul_ (3 overloads)
qmatmul_woq
qmatmul_woq_
qmoe (2 overloads)
qmoe_woq
qmul (2 overloads)
qmul_ (3 overloads)
qquick_gelu (2 overloads)
qquick_gelu_ (3 overloads)
qrelu (2 overloads)
qrelu_ (3 overloads)
qsigmoid (2 overloads)
qsigmoid_ (3 overloads)
qsilu (2 overloads)
qsilu_ (3 overloads)
qsub (2 overloads)
qsub_ (3 overloads)
qtanh (2 overloads)
qtanh_ (3 overloads)
quantileThe q-th quantile of x along dim.
quantize
quantize_ (2 overloads)
quantize_dequantize
quantize_to_scheme
quick_geluQuickGELU: the sigmoid GELU approximation.
rad2degConverts radians to degrees elementwise: x180/πx \cdot 180 / \pi. x's shape at its (float-promoted) dtype. ClikaRT::Error (INVALID_ARGUMENT) for an unsupported dtype.
rad2deg_In-place rad2deg: writes the degrees through x. ClikaRT::Error as the value form.
randUniform random tensor on [0, 1).
rand_likeUniform [0, 1) draws shaped and typed like reference.
randintUniform random integers in the half-open range [low, high).
randint_likeUniform integers in [low, high) shaped and typed like reference.
randnStandard-normal random tensor, N(0, 1).
randn_likeN(0, 1) draws shaped and typed like reference.
random_In-place uniform-INTEGER fill: overwrites self with draws from [low, high). low and high come both or neither; with both absent, the range is the dtype's full representable-integer span. A view input writes through its base storage. Returns self for chaining.
randpermA random permutation of the integers 0 .. n-1.
reciprocalElementwise reciprocal.
reciprocal_In-place reciprocal: writes the result through self; same formula, arguments, and error conditions as reciprocal(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
reflect_padpad in mirror mode: the padding reflects the tensor across each padded edge. Same (lo, hi) pair layout as constant_pad. Copies.
regluReGLU gated activation over a concatenated gate‖up input.
reluRectified linear unit.
relu6ReLU capped at 6.
relu6_In-place relu6: writes the result through self; same formula, arguments, and error conditions as relu6(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
relu_In-place relu: writes the result through self; same formula, arguments, and error conditions as relu(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
remainderElementwise remainder with the sign of the DIVISOR, i.e. ops::mod with ModMode::Python. Broadcasts and promotes as add. the broadcast-shaped remainders. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
remainder_In-place remainder: writes the remainders through x. ClikaRT::Error as the value form.
renormCaps each sub-tensor's p-norm along dim at maxnorm.
renorm_In-place renorm: rewrites self with each slice's norm capped at maxnorm and returns it under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling. ClikaRT::Error as renorm.
repeatTile x by per-dim repeat counts: sizes[i] copies along dim i.
repeat_interleaveRepeat ELEMENTS, not blocks: each element along dim appears repeats times consecutively ([a, b] with repeats 2 -> [a, a, b, b]).
replicate_padpad in edge-replicate mode: the padding repeats each padded edge's value. Same (lo, hi) pair layout as constant_pad. Copies.
requantize
requantize_ (2 overloads)
resampleAudio-domain 1-D rational resample along the LAST axis: [.., S] at orig_freq[.., ceil(S · L / M)] at new_freq, where L/M is the gcd-reduced rate pair. A kaiser-windowed-sinc polyphase FIR, the standard antialiased sample-rate converter; input outside the signal reads as zero, and equal rates pass the signal through exactly. Leading axes are batch/channels (transpose another samples axis to the back first, a view). The defaults are the kaiser preset: lowpass_filter_width sinc zero-crossings per side, rolloff of the target Nyquist, and (when beta is absent) the design beta 14.769656459379492 (~142.7 dB design stopband). Serves f32 natively and f16/bf16 through an f32 compute lane (output mirrors the input); integer and f64 signals refuse; cast to f32 first. CPU-served; device-resident inputs refuse until an accelerator kernel lands.
reshapeReshape to shape; one entry may be -1 to infer it from the element count. A dim entry is an int literal OR a 0-D/1-D integer Tensor (IndexBound); e.g. reshape(x, {shape_host(x, 1), d}) composes without reading sizes to the host.
reshape_asReshape x to other's shape (other supplies extents only; its data is never read). The element counts must match.
rfftOne-sided real FFT along the last axis: real [..., n] → interleaved (re, im) pairs [..., n_fft/2 + 1, 2]. n_fft defaults to the last axis's extent; normalized scales the spectrum by 1/sqrt(n_fft).
rms_normRoot-mean-square normalization over the trailing normalized_shape dims (no mean subtraction).
rollCircularly shift elements: shifts[i] positions along dims[i]; elements that fall off one end re-enter at the other.
rot90Rotate the plane spanned by dims by k x 90 degrees (k is taken mod 4; odd rotations swap the two dims' extents). Default plane {0, 1}. Copies.
rotary_embeddingRotary position embedding over padded [.., S, D] layouts.
rotary_embedding_qka 2-element array {values, indices}.
rotary_embedding_qk_varlena 2-element array {values, indices}.
rotary_embedding_varlenRotary position embedding over token-packed (variable-length) layouts.
roundElementwise rounding to decimals fractional digits.
round_In-place round: writes the result through self; same formula, arguments, and error conditions as round(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
rsqrtElementwise reciprocal square root.
rsqrt_In-place rsqrt: writes the result through self; same formula, arguments, and error conditions as rsqrt(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
scaled_dot_product_attentionScaled dot-product attention over dense head-major tensors.
scaled_dot_product_attention_varlenVariable-length (packed) scaled dot-product attention: ragged batches ride one token-packed tensor plus prefix-sum offsets, no padding.
scatterA copy of x with src written at positions given by index along dim, the write mirror of gather: out[index[p]][j][k] = src[p] for dim = 0 (only that axis's coordinate is redirected).
scatter_In-place scatter: writes through self at the indexed positions; same arguments and error conditions as scatter(). Writes through self's storage (a strided view reaches its base buffer). Returns self for chaining.
scatter_addscatter with ACCUMULATION: out[.., index[p], ..] += src[p]; duplicate destinations sum.
scatter_add_In-place scatter_add: accumulates through self at the indexed positions; same arguments (incl. deterministic) and error conditions as scatter_add(). A strided view reaches its base buffer. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
scatter_reducescatter with a REDUCTION at each destination: Sum / Prod / Mean / AMax / AMin (ScatterReduceMode).
scatter_reduce_In-place scatter_reduce: reduces into self at the indexed positions; same arguments and error conditions as scatter_reduce(). A strided view reaches its base buffer. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
searchsortedInsertion points of values into a sorted sequence.
selectOne position along dim (the dim is removed). index is an int literal OR a 0-D integer Tensor (e.g. a shape_host-derived index) so a data-dependent select never reads the value to the host.
seluScaled exponential linear unit: elu with the fixed SELU constants (alpha ~= 1.6733, scale ~= 1.0507) from the self-normalizing-networks formulation.
selu_In-place selu: writes the result through self; same formula, arguments, and error conditions as selu(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
sgnElementwise sign; identical to sign for real dtypes.
sgn_In-place sgn: writes the result through self; same formula, arguments, and error conditions as sgn(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
shape (2 overloads)The tensor's shape as a 1-D Int64 tensor (or one extent as 0-D).
shape_host (3 overloads)The shape of x as a HOST-resident Int64 tensor, written from metadata: no device kernel, no readback, no stream synchronize, whatever device x lives on. The cheap way to feed shape values to shape-consuming arguments (a reshape dim) instead of Tensor::shape()'s concrete ints.
sigmoidLogistic sigmoid.
sigmoid_In-place sigmoid: writes the result through self; same formula, arguments, and error conditions as sigmoid(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
signElementwise sign: -1, 0, or 1.
sign_In-place sign: writes the result through self; same formula, arguments, and error conditions as sign(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
siluSigmoid linear unit (swish).
silu_In-place silu: writes the result through self; same formula, arguments, and error conditions as silu(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
sinElementwise sine.
sin_In-place sin: writes the result through self; same formula, arguments, and error conditions as sin(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
sincElementwise normalized sinc.
sinc_In-place sinc: writes the result through self; same formula, arguments, and error conditions as sinc(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
sinhElementwise hyperbolic sine.
sinh_In-place sinh: writes the result through self; same formula, arguments, and error conditions as sinh(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
slice (2 overloads)[start, end) with step along one dim. Each bound is an int literal, a 0-D integer Tensor, or absent ({}, an open bound); absent step is 1.
smooth_l1_lossSmooth-L1 loss: quadratic within beta of zero, L1 beyond it.
snakePeriodic "snake" activation (neural vocoders), per channels-last channel.
snake_In-place snake: writes the result through self; same formula, arguments, and error conditions as snake(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
softcap_logitsFused logit soft-cap: cap * tanh(x / cap) (true division), elementwise. A number cap must be > 0 (0 or negative is rejected). A tensor cap broadcasts against x and every element must be non-zero; that precondition is the caller's contract and is not runtime-checked.
softcap_logits_In-place softcap_logits: writes the result through self; same formula, arguments, and error conditions as softcap_logits(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
softmaxSoftmax along dim, computed stably (max-subtracted).
softmax_In-place softmax: writes the result through self; same formula, arguments, and error conditions as softmax(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
softminSoftmax of the negated input: weights small values highest.
softmin_In-place softmin: writes the result through self; same formula, arguments, and error conditions as softmin(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
softplusSmooth ReLU.
softplus_In-place softplus: writes the result through self; same formula, arguments, and error conditions as softplus(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
softshrinkSoft thresholding: shrinks every element toward zero by lambd.
softshrink_In-place softshrink: writes the result through self; same formula, arguments, and error conditions as softshrink(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
softsignSoftsign activation.
softsign_In-place softsign: writes the result through self; same formula, arguments, and error conditions as softsign(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
sorta 2-element array {values, indices} of x sorted along dim.
split_by_sizeSplit along dim into pieces of chunk_size, ceil(extent / chunk_size) of them, the last possibly shorter. Returns VIEWS sharing the source's storage (no copy).
split_with_sizesSplit along dim into chunks of the given lengths; sizes must sum to the dim's extent. Each length is a literal or a 0-D integer Tensor.
sqrtElementwise square root.
sqrt_In-place sqrt: writes the result through self; same formula, arguments, and error conditions as sqrt(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
squareElementwise square.
square_In-place square: writes the result through self; same formula, arguments, and error conditions as square(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
squeezeDrop size-1 dims: the listed dims (each must be size 1; anything else raises), or EVERY size-1 dim when dim is empty (the default).
squeeze_In-place squeeze: reshapes self's handle in place; same rules and error conditions as squeeze(); the storage is untouched. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
ssd_updateMamba2 / SSD selective-state serving step over a per-sequence [H, dim, dstate] Float32 state (updated IN PLACE; the returned tensor is out [B, T, H, dim], dtype following x). Per token: the state decays by exp(dt'*A[h]) (dt' = softplus(dt + dt_bias[h]) when dt_softplus), accumulates dt'*(x (outer) B), and emits S*C + D[h]*x (optionally silu-gated by z). A/D/dt_bias are per-head Float32 parameters (A carries the NEGATIVE decay rate; fold -exp(A_log) at bind); B/C are [B, T, G, dstate] with H % G == 0. Decode is T == 1; a prefill runs the same sequential law. seq_lens ([B] Int32) bounds ragged rows. slot_ids ([B] Int32, device-resident) addresses state as a SLAB [num_slots, H, dim, dstate]: batch row b reads/updates slab row slot_ids[b] in place (ids in range and DISTINCT per call, the caller's contract); absent keeps state row b.
stackJoin tensors along a NEW dim at position dim: all inputs share one shape; output rank = input rank + 1, the new dim sized N. Copies.
stdStandard deviation of x over dims, with Bessel correction.
stftShort-time Fourier transform of a real [L] / [B, L] signal: frames of win_length (default n_fft) at hop_length strides (default n_fft/4), windowed by window when given (a [win_length] tensor; absent = rectangular). Output [T, n_freq, 2] / [B, T, n_freq, 2] with n_freq = n_fft/2 + 1; frames along the time axis first, interleaved (re, im) pairs. center pads n_fft/2 per side in pad_mode before framing; normalized scales by 1/sqrt(n_fft). Only the one-sided form is served; onesided = false refuses.
sub (2 overloads)Subtracts other (scaled) from a elementwise.
sub_In-place sub: writes act(xαother)act(x - \alpha \cdot other) through x. ClikaRT::Error as the value form.
sumSums x over dims.
swigluSwiGLU over a concatenated [*, 2d] gate‖up input → [*, d], the clamped gated form: out = (clamp(up, ±limit) + beta) · G · sigmoid(alpha·G) with G = min(gate, limit). The defaults reduce exactly to the plain silu(gate) · up. The last dim must be even.
synchronize_allBlock until every live stream in the runtime has finished, a barrier for "wait for all enqueued work to complete" (e.g. before reading a device result on the host, or timing a phase). Infallible: it never raises.
takeRead elements of self at FLAT (row-major linearized) positions.
take_along_dimgather with broadcasting between x and index on the other dims.
tanElementwise tangent.
tan_In-place tan: writes the result through self; same formula, arguments, and error conditions as tan(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
tanhElementwise hyperbolic tangent.
tanh_In-place tanh: writes the result through self; same formula, arguments, and error conditions as tanh(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
tensordotNamed-axis contraction: sums a over dims_a against b over dims_b, pairwise.
thresholdElementwise threshold: keeps values above threshold, replaces the rest with value.
threshold_In-place threshold: writes the result through self; same formula, arguments, and error conditions as threshold(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
tilerepeat that also accepts FEWER counts than the rank; missing leading entries default to 1. Counts are literals or 0-D integer Tensors (a tensor count traces symbolically). Copies.
to (3 overloads)Moves a tensor to a device or stream.
topka 2-element array {values, indices}.
traceSum of the main diagonal of a rank-2 tensor.
transposeSwap dim0 and dim1, permute for exactly two dims. Returns a view (no copy).
trilZero out the entries ABOVE the chosen diagonal of the last two axes; the lower-triangular part survives. diagonal: 0 = main, +k above, -k below. Copies.
tril_In-place tril: zeroes the upper triangle through self; same arguments and error conditions as tril(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
triuZero out the entries BELOW the chosen diagonal of the last two axes; the upper-triangular part survives. diagonal: 0 = main, +k above, -k below. Copies.
triu_In-place triu: zeroes the lower triangle through self; same arguments and error conditions as triu(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
truncElementwise truncation toward zero (drops the fraction).
trunc_In-place trunc: writes the result through self; same formula, arguments, and error conditions as trunc(). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
unflattenSplit the dim at dim into sizes, the inverse of flatten. The product of sizes must equal that dim's extent.
unfoldim2col: extracts sliding kernel windows from a channels-last input.
uniform_In-place uniform fill on [low, high): overwrites self at its own shape/dtype and returns it under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
uniquea 3-element array (see the op's semantics for each element).
unique_consecutivea 3-element array (see the op's semantics for each element).
unsqueezeInsert a size-1 dim at dim. The position is normalized against the OUTPUT rank, so -1 appends at the trailing end. Returns a view (no copy).
unsqueeze_In-place unsqueeze: reshapes self's handle in place; same rules and error conditions as unsqueeze(); the storage is untouched. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
upsample_bicubic2d2-D bicubic resize.
upsample_bilinear2d2-D bilinear resize.
upsample_linear1dinterpolate with InterpMode::Linear (linear / bilinear / trilinear by input rank) or InterpMode::Bicubic.
upsample_nearest1dinterpolate with InterpMode::Nearest over a 1d/2d/3d input.
upsample_nearest2d2-D nearest-neighbor resize.
upsample_nearest3d3-D nearest-neighbor resize.
upsample_trilinear3d3-D trilinear resize.
validate_rotary_dimChecks a rotary-embedding configuration up front: rotary_dim must be positive, even, and (when head_dim is given) no larger than head_dim.
varVariance of x over dims, with Bessel correction.
where (2 overloads)Elementwise select: condition ? x : y, with numpy-style broadcasting across all three operands.
xlog1pyElementwise alog(1+other)a \cdot \log(1 + other) with the 0log(0)=00 \cdot \log(0) = 0 convention (entropy-style sums stay finite where a is zero). Broadcasts and promotes as add. the broadcast-shaped result at the promoted float dtype. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
xlogyElementwise alog(other)a \cdot \log(other) with the 0log(0)=00 \cdot \log(0) = 0 convention. Broadcasts and promotes as add. the broadcast-shaped result at the promoted float dtype. ClikaRT::Error (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.
xlogy_In-place xlogy: writes the result through x. ClikaRT::Error as the value form.
zero_In-place zero fill: overwrites every element of self with zero (the error conditions of zeros()). A view input writes through its base storage. Returns self under the value surface, Result<void> under the Result surface; CLIKART_CHECK is the mode-stable spelling.
zerosA new tensor of the given shape with every element set to zero.
zeros_likeA zero-filled tensor with reference's shape and dtype (data never read); s absent = the reference's own device.

ClikaRT/compute/op_enums.h

#include <ClikaRT/compute/op_enums.h>

Enum parameters carried by the fused ops: the activation epilogue a matmul/linear/embedding/norm applies in one pass, and the rotary-embedding mode / scaling family. Mirror the internal enums by name and order (ABI: never reorder or remove a value; append new ones at the end).

ClikaRT/compute/ops.h

#include <ClikaRT/compute/ops.h>

Core tensor operations as free functions over Tensor. Each returns its result BY VALUE and raises ClikaRT::Error on failure (the inline wrapper throws in your own TU; the impl:: forms return a Result). Tensors pass BY VALUE, a cheap refcounted handle the runtime may donate; std::move one in when you're done with it. Composes directly: ops::relu(ops::matmul(a, b)).

ClikaRT/compute/tensor.h

#include <ClikaRT/compute/tensor.h>

The central value type: an N-dimensional array on a device, with a shape, a data type, and a placement. Build one from host data or a factory, move it between devices and dtypes with to, and read its bytes back. The op / module / runtime layers all traffic in Tensor.

Macros

#define ICLIKART_TENSOR_ACT

#define ICLIKART_TENSOR_ACT(NAME) CLIKART_RESULT(Tensor) NAME() const { CLIKART_UNWRAP(NAME##_impl()); } \ CLIKART_INPLACE_RESULT(Tensor) NAME##_() { CLIKART_INPLACE_UNWRAP(NAME##_inplace_impl(), *this); }

Declared in ClikaRT/compute/tensor.h, line 595

#define ICLIKART_TENSOR_ACT_IMPL

#define ICLIKART_TENSOR_ACT_IMPL(NAME) Result<Tensor> NAME##_impl() const; \ Result<void> NAME##_inplace_impl();

Declared in ClikaRT/compute/tensor.h, line 734